Skip to content

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

@sbomer

Description

@sbomer

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions