Skip to content

[DAM analyzer] Report DAM warnings for generics in all cases #2364

@sbomer

Description

@sbomer

This is a tracking issue for support for annotated generics in the analyzer. The DAM analyzer only validates annotations for generics at callsites to generic methods:

CheckAndReportDynamicallyAccessedMembers (targetMethod.TypeArguments[i], targetMethod.TypeParameters[i], context, invocationOperation.Syntax.GetLocation (), targetIsMethodReturn: false);

This needs to be extended to cover all type references which may reference generic instantiations, including:

  • base/interface types of a type declaration
  • variable declarations
  • field/property/event declarations
  • parameter/return types of methods

This is probably best done using the symbol-based callbacks (RegisterSymbolAction) rather than the IOperation-based ones.

I would start by enabling some of the tests in GenericParameterDataFlow (or temporarily copying them to DynamicallyAccessedMembersAnalyzerTests.cs if that's easier). For example DerivedTypeWithOpenGenericOnBase looks like a good starting point.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions