Skip to content
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

Fix project info reading #10623

Merged
merged 3 commits into from
Jul 16, 2024
Merged

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Jul 15, 2024

When reading RazorProjectInfo from a stream the array being used was a pooled array. The code was not correctly trimming that array for the deserializer which meant that unknown bytes were being attempted to be read and were likely wrong. This fixes the code to make sure and trim before deserializing and adds tests.

Fixes AB#2137098

@ryzngard ryzngard requested a review from a team as a code owner July 15, 2024 23:23
private static ValueTask ReadExactlyAsync(Stream stream, byte[] buffer, int length, CancellationToken cancellationToken)
=> stream.ReadExactlyAsync(buffer, 0, length, cancellationToken);
#else
private static async ValueTask ReadExactlyAsync(Stream stream, byte[] buffer, int length, CancellationToken cancellationToken)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a follow up cleanup to move these to net only instead of having a bunch of ifdefs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, none of these methods need to actually run on netstandard2.0 or NetFx. You could #ifdef the whole file for NET or change the file name to StreamExtensions.NetCore.cs so that they only compile for NET. Then, you can get rid of the non-NET branches. That will open up lots of Span-based APIs on Stream and other types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that's the plan, move the whole file over.

@ryzngard ryzngard merged commit a42dea4 into dotnet:main Jul 16, 2024
12 checks passed
@ryzngard ryzngard deleted the fix_projectinfo_reading branch July 16, 2024 01:11
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 16, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 Preview 1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants