Ensure we keep metadata for fields#113759
Merged
MichalStrehovsky merged 1 commit intodotnet:mainfrom Mar 22, 2025
Merged
Conversation
We already do this for methods but `FieldMetadataNode` was missing the matching logic (we'd only keep metadata for custom modifiers in the lines above those I'm touching).
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds logic to preserve metadata for fields by updating dependency analysis and provides a corresponding test to validate the behavior.
- Added a test in Reflection.cs to verify field and parameter metadata is preserved.
- Updated FieldMetadataNode.cs to include metadata for the field type.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs | Added TestFieldAndParamMetadata to verify field and parameter type metadata preservation. |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FieldMetadataNode.cs | Updated dependency analysis to include the field's type metadata. |
Comment on lines
+838
to
+839
| public class FieldType; | ||
|
|
There was a problem hiding this comment.
The declaration 'public class FieldType;' appears to be incomplete; in C# class declarations require a body (e.g., use '{ }' instead of a semicolon).
Suggested change
| public class FieldType; | |
| public class FieldType { } |
Comment on lines
+842
to
+843
| public class ParameterType; | ||
|
|
There was a problem hiding this comment.
The declaration 'public class ParameterType;' is incomplete and should include a body (e.g., '{ }') to be valid C# syntax.
Suggested change
| public class ParameterType; | |
| public class ParameterType { } |
agocke
approved these changes
Mar 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We already do this for methods but
FieldMetadataNodewas missing the matching logic (we'd only keep metadata for custom modifiers in the lines above those I'm touching).