Skip to content

Add SonarAnalyzer.CSharp and tighten Roslyn analyzer rules#12

Merged
tillig merged 19 commits into
developfrom
feature/tighten-analyzers
May 29, 2026
Merged

Add SonarAnalyzer.CSharp and tighten Roslyn analyzer rules#12
tillig merged 19 commits into
developfrom
feature/tighten-analyzers

Conversation

@tillig

@tillig tillig commented May 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds SonarAnalyzer.CSharp (10.27.0.140913) to all projects
  • Introduces unified build/Source.ruleset and build/Test.ruleset with consistent analyzer configuration
  • Fixes all actionable analyzer warnings (code changes per-rule in individual commits)
  • Disables rules that are false positives or inapplicable for this project's patterns

Changes

  • New analyzer: SonarAnalyzer.CSharp added via PackageReference with PrivateAssets=all
  • Rulesets: Unified Source.ruleset and Test.ruleset covering Microsoft, Sonar, StyleCop, and xUnit analyzers
  • Code fixes: Various warning fixes committed individually by rule ID for easy review
  • Zero warnings: Build completes with no analyzer warnings

Test plan

  • CI build passes (zero errors, zero warnings)
  • All existing tests pass
  • No public API changes (verify with dotnet format --verify-no-changes)

tillig added 19 commits May 28, 2026 12:38
Adds SonarAnalyzer.CSharp 10.27.0.140913 to all projects. Replaces
existing Source.ruleset and Test.ruleset with unified versions shared
across the Autofac organization. Ensures all projects have
AnalysisMode=AllEnabledByDefault and EnforceCodeStyleInBuild=true.
Autofac intentionally maintains deprecated APIs for backward compatibility.
Tests exercise deprecated APIs to verify they still work. Warnings about
using deprecated code are not actionable in this context.
- CA1063 (Implement IDisposable correctly): enabled as Warning in both
  Source and Test rulesets for explicit enforcement.
- S3881 (IDisposable pattern): disabled because Autofac uses non-standard
  dispose patterns for container lifecycle management.
- Fixed comment/rule ordering where S1133 insertion displaced comments.
- CA1711: test classes commonly use suffixes like Impl, Handler, etc.
- CA1721: test interfaces intentionally have properties matching methods.
- S125: commented-out code in tests is acceptable for examples/notes.
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.19%. Comparing base (7ceb06c) to head (7039f9d).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #12   +/-   ##
========================================
  Coverage    86.19%   86.19%           
========================================
  Files            8        8           
  Lines          210      210           
  Branches        19       19           
========================================
  Hits           181      181           
  Misses          18       18           
  Partials        11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tillig tillig merged commit 3e70feb into develop May 29, 2026
10 checks passed
@tillig tillig deleted the feature/tighten-analyzers branch May 29, 2026 21:29
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.

1 participant