From 96339776673faf4d1156e79b38f8ab10aec1553b Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Tue, 2 Jun 2026 16:13:34 -0400 Subject: [PATCH 1/2] Add test case for class primary constructors These create mutable fields, so this test should fail but maybe doesn't --- .../D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs b/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs index c5b0089a..2062db50 100644 --- a/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs +++ b/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs @@ -1461,4 +1461,7 @@ static ClassWithCapturedMutability() { SometimesBad2 = static () => 2; } } + + [Immutable] + public class ClassPrimaryConstructor( ClassPrimaryConstructor other ); } From 796f72fd7efafaa97821e579e938eabc3e82f593 Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Tue, 2 Jun 2026 16:26:04 -0400 Subject: [PATCH 2/2] add more stuff, just poking around --- .../Specs/ImmutabilityAnalyzer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs b/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs index 2062db50..d0798b99 100644 --- a/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs +++ b/tests/D2L.CodeStyle.Analyzers.Test/Specs/ImmutabilityAnalyzer.cs @@ -1463,5 +1463,8 @@ static ClassWithCapturedMutability() { } [Immutable] - public class ClassPrimaryConstructor( ClassPrimaryConstructor other ); + public class ClassPrimaryConstructor( ClassPrimaryConstructor other ) { + private readonly int m_x; + private int m_y; + } }