Skip to content

Ensure we keep metadata for fields #113759

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

Merged
merged 1 commit into from
Mar 22, 2025

Conversation

MichalStrehovsky
Copy link
Member

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).

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).
@Copilot Copilot AI review requested due to automatic review settings March 21, 2025 13:05
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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;

Copy link
Preview

Copilot AI Mar 21, 2025

Choose a reason for hiding this comment

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

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 { }

Copilot uses AI. Check for mistakes.

Comment on lines +842 to +843
public class ParameterType;

Copy link
Preview

Copilot AI Mar 21, 2025

Choose a reason for hiding this comment

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

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 { }

Copilot uses AI. Check for mistakes.

@MichalStrehovsky MichalStrehovsky merged commit 1f76c1f into dotnet:main Mar 22, 2025
98 of 100 checks passed
@MichalStrehovsky MichalStrehovsky deleted the fldmeta branch March 22, 2025 07:58
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants