Skip to content

Latest commit

 

History

History
226 lines (144 loc) · 11.8 KB

File metadata and controls

226 lines (144 loc) · 11.8 KB

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

[2.1.1] - 2026-02-06

Changed

  • DI001 / DI014: Reduced false positives by recognising explicit disposal inside the same lambda/local-function execution boundary while still warning when disposal is only deferred into a different boundary.
  • DI007: Reduced false positives by continuing context analysis from lambdas up to containing methods (for example Create*/Build* factory methods), instead of stopping early.
  • DI008: Reduced false positives with stricter symbol-based AddTransient detection and factory method-group detection for member-access expressions (for example FactoryMethods.Create).
  • Tests: Added dedicated regression coverage for all fixed cases plus negative guardrail scenarios to ensure diagnostics still fire for deferred-lambda disposal patterns.

[2.1.0] - 2026-02-06

Added

  • DI016: New analyser detecting BuildServiceProvider() misuse during service-registration composition (for example in ConfigureServices, IServiceCollection extension registration methods, and registration lambdas).

Changed

  • Documentation/Samples: Added DI016 rule documentation and sample coverage, including conservative false-positive guardrail notes.

[2.0.0] - 2026-02-06

Changed

  • DI015: Expanded dependency resolution from direct constructor parameters to transitive constructor chains, including open-generic dependency closures.
  • DI015: Factory registrations using GetRequiredService/GetRequiredKeyedService now resolve transitive dependency graphs and report missing leaf dependencies.
  • DI015: Added conservative cycle handling (treat cycles as resolvable) and preserved framework/factory assumptions to keep false positives low.
  • Tests: Added transitive DI015 regression coverage for constructor chains, factory-rooted chains, open-generic transitive resolution, and circular dependency paths.

[1.13.0] - 2026-02-06

Changed

  • DI002: Reduced false positives by reporting scope-escape diagnostics only when the resolved service lifetime is known and scoped.
  • DI004: Reduced false positives by reporting use-after-dispose diagnostics only when the resolved service lifetime is known and scoped/transient.
  • RegistrationCollector: Improved fallback symbol handling to track DI registrations in unresolved/ambiguous invocation cases, including Add*(typeof(...)) patterns.
  • Tests: Added and updated regression coverage for unknown-lifetime suppression and typeof-based registration tracking in collector/rule/code-fix scenarios.

[1.12.0] - 2026-02-05

Added

  • Quality Gates: Added CI coverage thresholds (line + branch) and release-time tag/version validation.
  • Community Files: Added issue templates, pull request template, and CODE_OF_CONDUCT.md.
  • Documentation: Added docs/RULES.md as the deep-dive rule reference and reshaped README.md into a quickstart-focused guide.

Changed

  • RegistrationCollector: Added all-registration tracking (AllRegistrations) so analyzers can inspect duplicate Add* registrations instead of only the last one.
  • Analyzer Coverage for Duplicates: Updated DI003, DI009, DI010, DI011, DI013, and DI015 to analyze all discovered Add* registrations.
  • DI002: Switched to symbol-based tracking and lifetime-aware filtering to reduce false positives (known singleton/transient registrations no longer trigger scope-escape diagnostics).
  • DI004: Switched to symbol-based tracking and lifetime-aware filtering (known singleton services resolved from scope are excluded from use-after-dispose diagnostics).
  • DI001 / DI014: Hardened explicit-dispose detection by requiring symbol-matched dispose calls that occur after creation, reducing false negatives from name-only matching.
  • Symbol Matching: Improved service-provider and registration matching logic to prefer robust symbol/namespace checks while preserving compatibility with test stubs.
  • Tests: Expanded regression coverage for variable shadowing, singleton scope-usage scenarios, duplicate registration analysis, and dispose-before-create edge cases.

[1.11.0] - 2026-02-05

Changed

  • DI015: Added factory method-group analysis support (for registrations such as AddSingleton<IMyService>(CreateMyService)) and corresponding test coverage.
  • DI015: Added factory-path analysis for ActivatorUtilities.CreateInstance(...) and introduced .editorconfig option dotnet_code_quality.DI015.assume_framework_services_registered for strict vs framework-assumed dependency checks.
  • DI015: Hardened factory analysis by supporting named factory arguments, limiting method-body traversal to true method-group registrations, and applying .editorconfig framework-service assumptions per syntax tree.

[1.10.0] - 2026-02-05

Added

  • DI015: New analyzer detecting registered services that depend on unregistered dependencies in constructor injection and GetRequiredService factory paths, including keyed and open-generic checks.
  • Samples: Added samples/DI015InAction, a dedicated runnable sample showing broken and fixed DI015 registration patterns.

Changed

  • DI015: Reduced false positives for multi-constructor services by only reporting when no constructor is fully resolvable, and avoided duplicate reports for factory registrations that include implementation type metadata.

[1.9.0] - 2026-02-05

Fixed

  • DI001 / DI014: Avoided false negatives where any enclosing using statement was incorrectly treated as disposing a scope/provider created elsewhere.
  • DI003: Fixed non-generic service-resolution argument mapping for reduced extension methods (GetService(typeof(...)), GetRequiredService(typeof(...))), preventing missed captive-dependency reports.
  • Constructor Selection: Added shared constructor-selection logic honoring [ActivatorUtilitiesConstructor] and preventing regressions with new analyzer tests.

Changed

  • DI003: Expanded non-generic and keyed resolution handling for factory delegates.
  • CI/Tooling: Added global.json, updated CI/release workflows to install .NET 8 and .NET 10, and aligned test infrastructure/packages with current Roslyn testing defaults.
  • Tests: Added targeted regression coverage across DI003, DI009, DI010, and DI011 for constructor-selection behavior and factory-resolution edge cases.

[1.8.0] - 2025-12-11

Fixed

  • DI012 (Conditional Registration Misuse): Keyed service registrations are now grouped by (serviceType, key) so different keys no longer trigger false duplicate/TryAdd diagnostics.

Changed

  • RegistrationCollector: Returns null when IServiceCollection is unavailable, avoiding unnecessary analysis in projects without DI references.
  • Dependencies: Upgraded Roslyn to 5.0.0 and analyzer infrastructure packages to latest stable versions.
  • Tests: Migrated from deprecated *.Testing.XUnit packages to core testing packages with XUnitVerifier, and bumped xUnit/Test SDK/Coverlet to current versions.

[1.6.0] - 2025-11-26

Changed

  • RegistrationCollector: Improved robustness for parsing ServiceDescriptor arguments, correctly handling named arguments and integer-casted ServiceLifetime values.
  • DI014 Code Fix: Enhanced to apply await using in asynchronous contexts and to preserve all leading/trailing trivia (comments, indentation) correctly.

[1.5.0] - 2025-11-26

Added

  • DI014 Code Fix: Added code fix to automatically dispose root IServiceProvider instances.

Changed

  • RegistrationCollector: Enhanced to support services registered via new ServiceDescriptor(...) and ServiceDescriptor.Describe(...). This improves detection accuracy for all analyzers relying on service registration data.

[1.4.0] - 2025-11-26

Added

  • DI013: New analyzer detecting implementation type mismatches in typeof registrations (e.g. AddSingleton(typeof(IService), typeof(BadImpl))).
  • DI014: New analyzer detecting undisposed root IServiceProvider instances created by BuildServiceProvider().

[1.3.0] - 2025-11-26

Added

  • DI003: Enhanced Captive Dependency analyzer to support factory delegate registrations (e.g., AddSingleton(sp => new Service(sp.GetRequiredService<IScoped>()))).

Changed

  • RegistrationCollector: Updated to parse and store factory expressions for analysis.

[1.2.0] - 2025-11-25

Added

  • DI010: New analyzer detecting constructor over-injection (5+ dependencies suggests class may violate SRP)
  • DI011: New analyzer detecting IServiceProvider, IServiceScopeFactory, or IKeyedServiceProvider injection
    • Excludes factory classes (name ends with "Factory") and middleware classes (has Invoke/InvokeAsync method)
  • .NET 8 Keyed Services Support: All analyzers now support keyed service patterns
    • AddKeyedSingleton, AddKeyedScoped, AddKeyedTransient registrations
    • GetKeyedService, GetRequiredKeyedService, GetKeyedServices service resolution
    • IKeyedServiceProvider detection in DI006, DI007, DI011

Changed

  • Enhanced WellKnownTypes with IKeyedServiceProvider support
  • Updated RegistrationCollector to track keyed service registrations
  • Updated DI006_StaticProviderCacheAnalyzer to detect IKeyedServiceProvider in static fields
  • Updated DI007_ServiceLocatorAntiPatternAnalyzer to detect keyed service resolution methods
  • Updated DI008_DisposableTransientAnalyzer to detect AddKeyedTransient registrations

[1.1.0] - 2025-11-25

Added

  • DI012: New analyzer detecting conditional registration misuse
    • DI012: TryAdd* called after Add* for the same service type (will be silently ignored)
    • DI012b: Multiple Add* calls for the same service type (later registration overrides earlier)
  • DI002 Code Fix: Added pragma suppression and TODO comment code fixes for scope escape diagnostics
  • Extended RegistrationCollector infrastructure to track registration order for DI012 analysis

Changed

  • Updated README with DI012 documentation and corrected DI002 code fix availability

[1.0.0] - 2025-11-24

Added

  • DI004: Support for modern using var declarations (previously only using statements were detected)
  • Additional edge case test coverage for DI001, DI004, and DI007 analyzers
  • Analyzer release tracking files for Roslyn best practices
  • CONTRIBUTING.md with contribution guidelines
  • Known Limitations section in README

Fixed

  • Build warnings RS2008 and RS1037 resolved
  • DI004 now properly detects services used after using var scope ends in nested blocks

Changed

  • Version bumped to 1.0.0 for stable release

[0.1.0] - 2024-11-24

Added

Analyzers

  • DI001: Detect undisposed IServiceScope instances
  • DI002: Detect scoped services escaping their scope lifetime
  • DI003: Detect captive dependencies (singleton capturing scoped/transient)
  • DI004: Detect service usage after scope disposal
  • DI005: Detect CreateScope() usage in async methods (should use CreateAsyncScope())
  • DI006: Detect IServiceProvider or IServiceScopeFactory cached in static members
  • DI007: Detect service locator anti-pattern
  • DI008: Detect transient services implementing IDisposable/IAsyncDisposable
  • DI009: Detect open generic singletons capturing scoped/transient dependencies

Code Fixes

  • DI001: Add using or await using statement
  • DI003: Change service lifetime to Scoped or Transient
  • DI005: Replace CreateScope() with CreateAsyncScope()
  • DI006: Remove static modifier from field/property
  • DI008: Change lifetime to Scoped or Singleton
  • DI009: Change open generic lifetime to Scoped or Transient