You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method calls semanticModel.GetDeclaredSymbol(token.Parent) and optionally semanticModel.GetSymbolInfo(token.Parent) for the identifier token. Therefore an ISymbol is created, and a mapping from SyntaxNode to ISymbol is added to the semantic model. This adds a lot of pressure to any shared semantic model, as the ISymbol and the mapping need to be cached by the semantic model in a thread-safe manner. The code snippet below shows how many identifiers are present in a simple code snippet.
TokenClassifierBase.ClassifyIdentifier can only have two outcomes:
The identifier is considered TokenType.TypeName (with some special casing for types that are classified as keywords)
The identifier is considered to be unknown.
This classification can often be done on a syntactical level. In the sample above, all identifiers can be classified without querying the semantic model, saving 20 calls to the semantic model (13 identifiers, where 6 are declarations -> 13 + 7) and the allocation of 11 symbols.
To do a proper classification on the syntax level, the test infrastructure needs to be extended and made more powerful. #7289 describes how to do it, and #7108 implements this infrastructure. Therefore, this issue is blocked by #7289
Blocked by #7289, #7368
The token type analyzer calls TokenClassifierBase.ClassifyIdentifier for each identifier.
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/Rules/Utilities/TokenTypeAnalyzerBase.cs
Lines 140 to 154 in 2728acd
This method calls
semanticModel.GetDeclaredSymbol(token.Parent)
and optionallysemanticModel.GetSymbolInfo(token.Parent)
for the identifier token. Therefore anISymbol
is created, and a mapping fromSyntaxNode
toISymbol
is added to the semantic model. This adds a lot of pressure to any shared semantic model, as theISymbol
and the mapping need to be cached by the semantic model in a thread-safe manner. The code snippet below shows how many identifiers are present in a simple code snippet.TokenClassifierBase.ClassifyIdentifier
can only have two outcomes:This classification can often be done on a syntactical level. In the sample above, all identifiers can be classified without querying the semantic model, saving 20 calls to the semantic model (13 identifiers, where 6 are declarations -> 13 + 7) and the allocation of 11 symbols.
To do a proper classification on the syntax level, the test infrastructure needs to be extended and made more powerful. #7289 describes how to do it, and #7108 implements this infrastructure. Therefore, this issue is blocked by #7289
Related:
#4217
#7288
#6674
The text was updated successfully, but these errors were encountered: