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

ILLink analyzer doesn't warn for invalid annotations in top-level methods #101215

Open
sbomer opened this issue Apr 17, 2024 · 2 comments
Open

ILLink analyzer doesn't warn for invalid annotations in top-level methods #101215

sbomer opened this issue Apr 17, 2024 · 2 comments
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers blocked Issue/PR is blocked on something - see comments
Milestone

Comments

@sbomer
Copy link
Member

sbomer commented Apr 17, 2024

DynamicallyAccessedMembers annotations are not supported for arbitrary types. The ILLink analyzer normally produces IL2098 warnings when the annotations are applied to unsupported types, but this isn't working for top-level methods:

using System.Diagnostics.CodeAnalysis;

RequireAll(GetFoo());

// This should warn
static void RequireAll([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Foo f) {}

static Foo GetFoo() => new Foo();

class Foo {}
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 17, 2024
@sbomer sbomer added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 17, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 17, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer added this to the 9.0.0 milestone Apr 25, 2024
@sbomer sbomer removed the untriaged New issue has not been triaged by the area owner label Apr 25, 2024
@sbomer
Copy link
Member Author

sbomer commented Jun 7, 2024

This is blocked on dotnet/roslyn#14061. I can't find a way to register a symbol action in the analyzer that gets called for top-level methods. I tried adding a RegisterSymbolAction for SymbolKind.Parameter, but that faces the same problem as mentioned in dotnet/roslyn#14061 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers blocked Issue/PR is blocked on something - see comments
Projects
Status: No status
Development

No branches or pull requests

1 participant