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

Missing warnings for DynamicallyAccessedMemberTypes.All access to annotated methods #2159

Closed
sbomer opened this issue Jul 22, 2021 · 0 comments · Fixed by #2191
Closed

Missing warnings for DynamicallyAccessedMemberTypes.All access to annotated methods #2159

sbomer opened this issue Jul 22, 2021 · 0 comments · Fixed by #2191
Assignees

Comments

@sbomer
Copy link
Member

sbomer commented Jul 22, 2021

Due to the caching for MarkEntireType, we aren't producing warnings for all callsites:

using System;
using System.Diagnostics.CodeAnalysis;
using DAM = System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute;
using RUC = System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute;

public class Program {
	public static void Main() {
		Test1();
		Test2();
	}

	static void Test1() => RequireAll(typeof(Foo)); // warns
	static void Test2() => RequireAll(typeof(Foo)); // no warning

	static void RequireAll([DAM(DynamicallyAccessedMemberTypes.All)] Type t) {}
}

public class Foo {
	[RUC("RUC")]
	void Method() {}
}

NestedTypes annotations will have similar problems.

@sbomer sbomer self-assigned this Aug 2, 2021
sbomer added a commit to sbomer/linker that referenced this issue Aug 5, 2021
sbomer added a commit that referenced this issue Aug 10, 2021
* Fix warnings for DAM.All

Fixes #2159

* Add tests

* PR feedback

- Remove unnecessary helper

* Avoid redundant DAM warnings for base members

* PR feedback

- Resolve -> TryResolve
- Avoid nested yield returns
- Testcases with base instantiated over self for generic parameter with
  requirements
agocke pushed a commit to dotnet/runtime that referenced this issue Nov 16, 2022
* Fix warnings for DAM.All

Fixes dotnet/linker#2159

* Add tests

* PR feedback

- Remove unnecessary helper

* Avoid redundant DAM warnings for base members

* PR feedback

- Resolve -> TryResolve
- Avoid nested yield returns
- Testcases with base instantiated over self for generic parameter with
  requirements

Commit migrated from dotnet/linker@d8b94bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant