Skip to content

Conversation

@gabriela-trutan-sonarsource
Copy link
Contributor

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource commented Sep 1, 2025

Copy link
Contributor

@georgii-borovinskikh-sonarsource georgii-borovinskikh-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Caching should be done at RoslynAnalysisConfigurationProvider level to simplify implementation and design;
  2. If no analyzers and no active rules have changed, RoslynAnalysisConfiguration as a whole should be cached;
  3. Cache miss scenario doesn't need to be optimized, as it only can happen on config scope or binding change

@gabriela-trutan-sonarsource
Copy link
Contributor Author

@georgii-borovinskikh-sonarsource, I have introduced the RoslynAnalysisConfiguration caching inside the RoslynAnalysisConfigurationProvider

The caching of the analyzer assembly contents should stay inside the RoslynAnalyzerProvider, because it's a different type of cache: the analyzers contents will never change and it makes sense for this service to hide to the outer services that is caching the contents. The analyzer contents being cached on a background thread at startup is an important optimization and I don't see the point to remove it (the cache miss can happen if the assemblies are not loaded yet and an analysis request is already sent).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 3, 2025

🤖 Pull Request summary

Updates Roslyn analyzer configuration to use caching and preloading.

• Adds caching to RoslynAnalysisConfigurationProvider with cache invalidation based on active rules, analysis properties, and analyzer info changes
• Modifies EmbeddedDotnetAnalyzersLocator to return analyzers grouped by both language and license level (basic/enterprise)
• Implements preloading of analyzer assemblies in SonarLintDaemonPackage initialization to improve performance
• Refactors analyzer provider to cache loaded assemblies and filter by license requirements at runtime

Review focus areas:

  • Thread safety of the new caching mechanisms and concurrent access to shared state
  • Cache invalidation logic to ensure configurations update correctly when parameters change
  • Memory implications of caching analyzer assemblies and configurations

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
98.3% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@gabriela-trutan-sonarsource gabriela-trutan-sonarsource merged commit a2d47ce into feature/sqvs-roslyn-plugin Sep 3, 2025
3 checks passed
@gabriela-trutan-sonarsource gabriela-trutan-sonarsource deleted the gt/analyzer-cache branch September 3, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants