From 03b2e5e70fe21bcf8cfdfc97c902ad4721b7826e Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Thu, 28 May 2026 12:35:46 -0700 Subject: [PATCH 1/7] Add SonarAnalyzer.CSharp and unified analyzer rulesets. 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. --- build/Source.ruleset | 42 +++++-- build/Test.ruleset | 103 +++++++++++++----- ...Autofac.Extras.CommonServiceLocator.csproj | 4 + ...ac.Extras.CommonServiceLocator.Test.csproj | 5 + 4 files changed, 113 insertions(+), 41 deletions(-) diff --git a/build/Source.ruleset b/build/Source.ruleset index 459e4e0..b1e5bb6 100644 --- a/build/Source.ruleset +++ b/build/Source.ruleset @@ -1,8 +1,8 @@ - - + + - - + + @@ -12,23 +12,41 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + diff --git a/build/Test.ruleset b/build/Test.ruleset index 3c26c01..9434578 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -1,16 +1,12 @@ - - + + - - - - + + - - - + - + @@ -20,37 +16,79 @@ - - - + - + - - - + - + - + - + + + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -58,11 +96,11 @@ - + - + - + @@ -82,6 +120,13 @@ + + + + + + + diff --git a/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj b/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj index 5ff7fd6..ad099a0 100644 --- a/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj +++ b/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj @@ -64,6 +64,10 @@ all + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj b/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj index 9e1624f..23abafc 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj +++ b/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj @@ -7,6 +7,7 @@ true true ../../build/Test.ruleset + AllEnabledByDefault true false latest @@ -32,6 +33,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + all From bd8bb91529d9e7127f6a71cb238eecd4557e106b Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Thu, 28 May 2026 14:44:02 -0700 Subject: [PATCH 2/7] Disable CA1034 in Test.ruleset: nested types are standard in test fixtures. --- build/Test.ruleset | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Test.ruleset b/build/Test.ruleset index 9434578..742a68c 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -42,6 +42,8 @@ + + From 7c18a3547c0daff492fe7554ac8619a229387d49 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Thu, 28 May 2026 17:45:14 -0700 Subject: [PATCH 3/7] Disable S1133: do not warn on use of obsolete/deprecated members. 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. --- build/Source.ruleset | 2 ++ build/Test.ruleset | 2 ++ 2 files changed, 4 insertions(+) diff --git a/build/Source.ruleset b/build/Source.ruleset index b1e5bb6..1cd02ff 100644 --- a/build/Source.ruleset +++ b/build/Source.ruleset @@ -32,6 +32,8 @@ + + diff --git a/build/Test.ruleset b/build/Test.ruleset index 742a68c..7729333 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -55,6 +55,8 @@ + + From 4c80233891ec51c936b4b55906ffe72654fdaa98 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Fri, 29 May 2026 07:19:08 -0700 Subject: [PATCH 4/7] Enable CA1063, disable S3881, fix ruleset comment ordering. - 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. --- build/Source.ruleset | 4 ++++ build/Test.ruleset | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build/Source.ruleset b/build/Source.ruleset index 1cd02ff..8994858 100644 --- a/build/Source.ruleset +++ b/build/Source.ruleset @@ -4,6 +4,8 @@ + + @@ -44,6 +46,8 @@ + + diff --git a/build/Test.ruleset b/build/Test.ruleset index 7729333..cd29cf9 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -6,6 +6,8 @@ + + @@ -54,9 +56,9 @@ - + @@ -80,6 +82,8 @@ + + From a2b23668c6e96b6ca7abb0ce952c891dcd267473 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Fri, 29 May 2026 10:30:45 -0700 Subject: [PATCH 5/7] Fix analyzer issues. --- .../AutofacServiceLocatorTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs b/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs index ab9bf14..1421cbf 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs +++ b/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs @@ -9,7 +9,7 @@ namespace Autofac.Extras.CommonServiceLocator.Test; public sealed class AutofacServiceLocatorTests { - private readonly IServiceLocator _locator; + private readonly AutofacServiceLocator _locator; public AutofacServiceLocatorTests() { @@ -72,7 +72,7 @@ public void GenericOverload_GetInstance_WithName() public void GetAllInstances() { var instances = _locator.GetAllInstances(); - IList list = new List(instances); + var list = new List(instances); Assert.Equal(2, list.Count); } From 145b95aa207bc0e800d36af992db477b7d3d17d8 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Fri, 29 May 2026 10:38:56 -0700 Subject: [PATCH 6/7] Disable CA2201 in Test.ruleset: tests use generic exceptions for simulation. --- build/Test.ruleset | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Test.ruleset b/build/Test.ruleset index cd29cf9..8559de5 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -39,6 +39,8 @@ + + From 04d97528a35928b62aacca2a1af8d2fbf9853c2d Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Fri, 29 May 2026 12:58:17 -0700 Subject: [PATCH 7/7] Disable CA1711, CA1721, S125 in Test.ruleset. - 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. --- build/Test.ruleset | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/Test.ruleset b/build/Test.ruleset index 8559de5..b64a37a 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -23,6 +23,10 @@ + + + + @@ -55,6 +59,8 @@ + +