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

Use build in automatic generated code detection: AnalysisContext.ConfigureGeneratedCodeAnalysis #5461

Open
3 tasks
costin-zaharia-sonarsource opened this issue Mar 7, 2022 · 4 comments
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.

Comments

@costin-zaharia-sonarsource
Copy link
Member

costin-zaharia-sonarsource commented Mar 7, 2022

Check if we can replace the in-house automatic generated code detection with AnalysisContext.ConfigureGeneratedCodeAnalysis from Roslyn.

According to the documentation:

It is recommended for the analyzer to invoke this API with the required GeneratedCodeAnalysisFlags setting.

  • Check if we can achieve the same functional requirements with the Roslyn API.
  • Check if there will be any changes in terms of performance.
  • Do the actual change.

Arguments for doing this change:

  • less code to maintain
  • theoretically, the performance should be better since:
    -- the Roslyn checks are most likely run anyway
    -- we do expensive checks on our end and rely on caching to save time, but our caching needs thread synchronization (ConcurrentDictionary) for this to work which might slow down the analysis. Outside IDEs, the rules are executed concurrently.
    -- measurement is needed
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. and removed Type: Improvement labels Mar 7, 2022
@glucaci
Copy link

glucaci commented Mar 8, 2022

How it the in-house automatic generated code detection working because with [LoggerMessage] is not working.
See #5466.

Thanks!

@costin-zaharia-sonarsource
Copy link
Member Author

Hi @glucaci,

in-house automatic generated code detection, in the current context, does not refer to code generators. It is about detecting if a code file was automatically generated by the visual studio IDE or other frameworks. E.g. designer files from windows forms.

@pavel-mikula-sonarsource
Copy link
Contributor

More context is reported by @RyanThomas73 in #6607

@martin-strecker-sonarsource
Copy link
Contributor

Related: #8298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.
Projects
None yet
Development

No branches or pull requests

4 participants