Skip to content

Fix dataflow annotations on TypeExtensions #116008

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 2 commits into from
May 28, 2025

Conversation

MichalStrehovsky
Copy link
Member

There was a leftover use of .All on some EditorBrowsable.Never APIs.

Cc @dotnet/illink

There was a leftover use of `.All` on some `EditorBrowsable.Never` APIs.
@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 10:52
@MichalStrehovsky MichalStrehovsky added the linkable-framework Issues associated with delivering a linker friendly framework label May 27, 2025
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 fixes the incorrect dataflow annotations on several EditorBrowsable.Never APIs in TypeExtensions by replacing the broad All flag with explicit combinations of public and nonpublic member flags.

  • Replaces DynamicallyAccessedMemberTypes.All with explicit combinations on GetMember.
  • Updates the same annotations in the ref file for consistency.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs Replaced the All member annotation with an explicit set of member types for GetMember and GetMembers.
src/libraries/System.Reflection.TypeExtensions/ref/System.Reflection.TypeExtensions.cs Updated the annotations to match the implementation changes in the source file.

@@ -168,7 +168,13 @@ public static MemberInfo[] GetMember(

[EditorBrowsable(EditorBrowsableState.Never)]
public static MemberInfo[] GetMember(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] this Type type,
[DynamicallyAccessedMembers(
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a brief inline comment explaining why the explicit set of DynamicallyAccessedMemberTypes is used here instead of All. This will help maintain clarity on the dataflow annotation requirements.

Copilot uses AI. Check for mistakes.

@@ -104,11 +104,11 @@ public static partial class TypeExtensions
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Reflection.MemberInfo[] GetMember([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicEvents | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicNestedTypes | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] this System.Type type, string name) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Reflection.MemberInfo[] GetMember([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] this System.Type type, string name, System.Reflection.BindingFlags bindingAttr) { throw null; }
public static System.Reflection.MemberInfo[] GetMember([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicEvents | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicNestedTypes | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicEvents | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicNestedTypes | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] this System.Type type, string name, System.Reflection.BindingFlags bindingAttr) { throw null; }
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider including a comment on the rationale behind splitting the annotation flags. This documentation will support future maintainers in understanding the change from using All to the explicit combination.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky MichalStrehovsky merged commit 2a47838 into dotnet:main May 28, 2025
86 checks passed
@MichalStrehovsky MichalStrehovsky deleted the noall branch May 28, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Reflection linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants