-
Notifications
You must be signed in to change notification settings - Fork 734
Parse the assets file with System.Text.Json #5627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Moved files over and addressed some PR comments * added comment * switched to true and false strings * Added ctr to specify buffer for testing purposes. * remove commented code * switch to use Utf8 preamble for BOM * Create method for checking complete * combined code for ReadStringArray * Updated buffer size to match STJ's default buffer size * Switch Utf8JsonStreamReader to be disposable. * Switch to read the value for numbers into a string directly * revert back to using private var for utf8Bom * Remove ReadStringArrayAsList * Avoid referencing buffer after returning * Actually avoid referencing _buffer after returning * Update how buffers are fed into Utf8JsonReader to avoid feeding extra empty data. * remove extra line * Reverted back to using try get int for ReadTokenAsString * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * Remove ValueTextEquals taking in string * Switched to Skip instead of TrySkip * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * Added some unit tests * fix Bom * Switched to using Moq * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * loop through stream when reading to ensure reading full bytes or to the end * update signature comment * Switched stream back to field and supress warning --------- Co-authored-by: Andy Zivkovic <[email protected]>
…ng STJ (#5541) Updated the logic for parsing the package spec to use STJ. Using a registry setting to determine if the code should use NJ or STJ for parsing.
…Json file using STJ. (#5558) Update the LockFileFormat class to use STJ for parsing the assets file.
* Moved files over and addressed some PR comments * added comment * switched to true and false strings * Added ctr to specify buffer for testing purposes. * remove commented code * switch to use Utf8 preamble for BOM * Create method for checking complete * combined code for ReadStringArray * Updated buffer size to match STJ's default buffer size * Switch Utf8JsonStreamReader to be disposable. * Switch to read the value for numbers into a string directly * revert back to using private var for utf8Bom * Remove ReadStringArrayAsList * Avoid referencing buffer after returning * Actually avoid referencing _buffer after returning * Update how buffers are fed into Utf8JsonReader to avoid feeding extra empty data. * remove extra line * Reverted back to using try get int for ReadTokenAsString * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * Remove ValueTextEquals taking in string * Switched to Skip instead of TrySkip * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * Added some unit tests * fix Bom * Switched to using Moq * Update src/NuGet.Core/NuGet.ProjectModel/Utf8JsonStreamReader.cs Co-authored-by: Andy Zivkovic <[email protected]> * loop through stream when reading to ensure reading full bytes or to the end * update signature comment * Switched stream back to field and supress warning --------- Co-authored-by: Andy Zivkovic <[email protected]>
…ng STJ (#5541) Updated the logic for parsing the package spec to use STJ. Using a registry setting to determine if the code should use NJ or STJ for parsing.
…Json file using STJ. (#5558) Update the LockFileFormat class to use STJ for parsing the assets file.
nkolev92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using STJ is the default correct?
If yes, then this looks great!
|
@jgonz120 the PR template has a section about docs. This PR introduces an environment variable, so an issue to add this new environment to the docs should be added: https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-environment-variables |
|
I linked the docs issue in the PR body. @jgonz120 fyi, if you link the docs issue, the validate-release command will "catch" all the filled, but not completed docs issue, ensuring we've documented the features we're shipping. |
|
@jgonz120 this seems to be causing two test failures in dotnet/sdk#38799 |
Bug
Fixes: NuGet/Home#12715
Regression? Last working version:
Description
Currently we use JObject to parse the assets file. This library reads the full file into memory causing performance issues with the GC. This PR switches it to use System.Text.Json, allowing up to read the file in pieces and parse it without having to load the full file into memory. This work was done in a feature branch and this is the PR to merge that feature branch into dev
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation