Skip to content

Investigate CSharpAvoidUninstantiatedInternalClasses performance #6301

@Youssef1313

Description

@Youssef1313

In a binlog I was looking at, noticed:

image

It might be caused by SemanticModel usage below?

context.RegisterSyntaxNodeAction(context =>
{
var usingDirective = (UsingDirectiveSyntax)context.Node;
if (usingDirective.Alias != null &&
usingDirective.DescendantNodes().OfType<GenericNameSyntax>().Any() &&
context.SemanticModel.GetDeclaredSymbol(usingDirective) is IAliasSymbol aliasSymbol &&
aliasSymbol.Target is INamedTypeSymbol namedTypeSymbol &&
namedTypeSymbol.IsGenericType)
{
var generics = namedTypeSymbol.TypeParameters.Zip(namedTypeSymbol.TypeArguments, (parameter, argument) => (parameter, argument));
ProcessGenericTypes(generics, instantiatedTypes);
}
}, SyntaxKind.UsingDirective);

Can this be improved?

cc @sharwell @mavasani

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions