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

Warning getting generated for lightup patterns #2392

Open
MichalStrehovsky opened this issue Nov 23, 2021 · 0 comments
Open

Warning getting generated for lightup patterns #2392

MichalStrehovsky opened this issue Nov 23, 2021 · 0 comments

Comments

@MichalStrehovsky
Copy link
Member

Type.GetType("TypeThatDoesntExist").GetMethod("Foo");

Above generates C:\trimmedapp\Program.cs(4,5): Trim analysis warning IL2075: Program.<Main>$(String[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Type.GetType(String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [C:\trimmedapp\trimmedapp.csproj].

We should ideally treat "GetType called with a known string that doesn't resolve to a type" differently from "GetType called with an unknown string".

The type might be missing because it's a lightup. This should not warn because the runtime behavior is going to be same (the type is missing before and after trimming). Hit in dotnet/runtime#61952.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant