-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Use ArrayExpansion for [InlineArray] structs
#81254
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
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Show resolved
Hide resolved
|
resolved comments @tmat |
...tor/CSharp/Test/ResultProvider/Microsoft.CodeAnalysis.CSharp.ResultProvider.UnitTests.csproj
Show resolved
Hide resolved
tmat
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.
LGTM. @dotnet/roslyn-compiler should also sign off.
src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
src/ExpressionEvaluator/Core/Source/ResultProvider/Helpers/InlineArrayHelpers.cs
Outdated
Show resolved
Hide resolved
|
Done with review pass (commit 2) #Closed |
src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs
Outdated
Show resolved
Hide resolved
AlekseyTs
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.
LGTM (commit 4)
|
Thanks @asundheimMSFT! |
# Overview [Fixed buffer fields](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code#fixed-size-buffers) look like structs with a single member in metadata, so we would use `MemberExpansion` which only shows the first element. Instead we should use `ArrayExpansion`, in a similar fashion to what we did for `[InlineArray]` in #81254. # Details - Added additional helper to `InlineArrayHelpers` that identifies generated fixed buffer types - Fixed up test mocks to handle some novel usage of certain LMR `Type` properties. # Testing Added test that validates that we get an `ArrayExpansion` for a fixed buffer. Comment in the test describes why we cannot use the typical testing approach that we use for other `ArrayExpansion` tests. <img width="784" height="156" alt="image" src="https://github.com/user-attachments/assets/8008bd22-9194-445a-b1d3-1b7a57de0a6b" />
Overview
Currently inline array structs use the default

MemberExpansion, which only shows the first element / the single field:Details
[InlineArray]attributes and decode the Length and element typeArrayExpansionfor inline arraysTesting
The real complexity of this change came when trying to write a test that exercised this case. Since all the ResultProvider expansion tests rely on instantiating objects into the test host, then decoding them via reflection in the debugger engine mocks, some additional work was necessary to support the Net8+ inline array type.
$(NetRoslyn)target toResultProvider.UnitTestsandResultProvider.Utilities$(NetRoslyn)DkmClrValueto handleGetArrayElementfor inline arrays (ish, see comments about reflection and inline arrays)Fixes: #68983