diff --git a/sample/.editorconfig b/sample/.editorconfig index f6b41fc2f..f1912841d 100644 --- a/sample/.editorconfig +++ b/sample/.editorconfig @@ -2,10 +2,11 @@ #### .NET Coding Conventions #### dotnet_diagnostic.CA1019.severity = none dotnet_diagnostic.CA1050.severity = none +dotnet_diagnostic.CA1303.severity = none +dotnet_diagnostic.CA1707.severity = none +dotnet_diagnostic.CA1822.severity = none dotnet_diagnostic.CA1848.severity = none dotnet_diagnostic.CA2254.severity = none -dotnet_diagnostic.CA1822.severity = none dotnet_diagnostic.CA5394.severity = none -dotnet_diagnostic.CA1707.severity = none resharper_virtual_member_call_in_constructor_highlighting = none resharper_nullable_warning_suppression_is_used_highlighting = none diff --git a/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs b/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs index 5bf7499ba..cb957677d 100644 --- a/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs +++ b/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs @@ -4,7 +4,7 @@ namespace Sample.Classic.Restful.Controllers; [Route("[controller]")] -public class WeatherForecastController(ILogger logger) : RestfulApiController +public class WeatherForecastController : RestfulApiController { private static readonly string[] Summaries = { diff --git a/sample/Sample.Restful/Controllers/WeatherForecastController.cs b/sample/Sample.Restful/Controllers/WeatherForecastController.cs index 5cad6d10b..eb13fa488 100644 --- a/sample/Sample.Restful/Controllers/WeatherForecastController.cs +++ b/sample/Sample.Restful/Controllers/WeatherForecastController.cs @@ -4,7 +4,7 @@ namespace Sample.Restful.Controllers; [Route("[controller]")] -public class WeatherForecastController(ILogger logger) : RestfulApiController +public class WeatherForecastController : RestfulApiController { private static readonly string[] Summaries = { diff --git a/src/Analyzers/ControllerActionBodyGenerator.cs b/src/Analyzers/ControllerActionBodyGenerator.cs index 1a31019fd..d807b0c8f 100644 --- a/src/Analyzers/ControllerActionBodyGenerator.cs +++ b/src/Analyzers/ControllerActionBodyGenerator.cs @@ -710,12 +710,8 @@ private void GenerateMethods( "Rocket.Surgery.LaunchPad.AspNetCore.Validation" }; - var usings = syntax.SyntaxTree.GetCompilationUnitRoot().Usings; - foreach (var additionalUsing in additionalUsings) - { - if (usings.Any(z => z.Name.ToString() == additionalUsing)) continue; - usings = usings.Add(UsingDirective(ParseName(additionalUsing))); - } + var usings = syntax.SyntaxTree.GetCompilationUnitRoot().Usings + .AddDistinctUsingStatements(additionalUsings.Where(z => !string.IsNullOrWhiteSpace(z))); var cu = CompilationUnit( List(), diff --git a/src/Analyzers/GraphqlMutationActionBodyGenerator.cs b/src/Analyzers/GraphqlMutationActionBodyGenerator.cs index 70abc9d5b..3316827a7 100644 --- a/src/Analyzers/GraphqlMutationActionBodyGenerator.cs +++ b/src/Analyzers/GraphqlMutationActionBodyGenerator.cs @@ -297,12 +297,8 @@ private void GenerateMethods( var additionalUsings = new[] { "MediatR" }; - var usings = syntax.SyntaxTree.GetCompilationUnitRoot().Usings; - foreach (var additionalUsing in additionalUsings) - { - if (usings.Any(z => z.Name.ToString() == additionalUsing)) continue; - usings = usings.Add(UsingDirective(ParseName(additionalUsing))); - } + var usings = syntax.SyntaxTree.GetCompilationUnitRoot().Usings + .AddDistinctUsingStatements(additionalUsings.Where(z => !string.IsNullOrWhiteSpace(z))); var cu = CompilationUnit( List(), diff --git a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs index 85b9e4f3f..26f541108 100644 --- a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs +++ b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs @@ -163,16 +163,12 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo ); classToInherit = classToInherit.AddMembers(createMethod); + var usings = declaration.SyntaxTree.GetCompilationUnitRoot().Usings + .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z))); var cu = CompilationUnit( List(), - List( - declaration.SyntaxTree.GetCompilationUnitRoot().Usings.AddRange( - namespaces - .Where(z => !string.IsNullOrWhiteSpace(z)) - .Select(z => UsingDirective(ParseName(z))) - ) - ), + List(usings), List(), SingletonList( symbol.ContainingNamespace.IsGlobalNamespace diff --git a/src/Analyzers/PropertyTrackingGenerator.cs b/src/Analyzers/PropertyTrackingGenerator.cs index ad1215ad6..82debc9e7 100644 --- a/src/Analyzers/PropertyTrackingGenerator.cs +++ b/src/Analyzers/PropertyTrackingGenerator.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + namespace Rocket.Surgery.LaunchPad.Analyzers; /// @@ -69,7 +70,13 @@ INamedTypeSymbol targetSymbol .WithModifiers(SyntaxTokenList.Create(Token(SyntaxKind.PublicKeyword))) .WithOpenBraceToken(Token(SyntaxKind.OpenBraceToken)) .WithCloseBraceToken(Token(SyntaxKind.CloseBraceToken)) - ; + .WithLeadingTrivia( + Trivia( + PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true) + .WithErrorCodes(SingletonSeparatedList(IdentifierName("CA1034"))) + ) + ); + var getChangedStateMethodInitializer = InitializerExpression(SyntaxKind.ObjectInitializerExpression); var applyChangesBody = Block(); var resetChangesBody = Block(); @@ -125,7 +132,7 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo ) ); applyChangesBody = applyChangesBody.AddStatements( - GenerateApplyChangesBodyPart(propertySymbol, IdentifierName("value"), isRecord) + GenerateApplyChangesBodyPart(propertySymbol, IdentifierName("state"), isRecord) ); resetChangesBody = resetChangesBody.AddStatements( ExpressionStatement( @@ -176,7 +183,7 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo .WithParameterList( ParameterList( SingletonSeparatedList( - Parameter(Identifier("value")).WithType( + Parameter(Identifier("state")).WithType( IdentifierName(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)) ) ) @@ -185,7 +192,7 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo .WithBody( applyChangesBody.AddStatements( ExpressionStatement(InvocationExpression(IdentifierName("ResetChanges"))), - ReturnStatement(IdentifierName("value")) + ReturnStatement(IdentifierName("state")) ) ); var resetChangesMethod = MethodDeclaration(IdentifierName(symbol.Name), "ResetChanges") @@ -215,15 +222,12 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo resetChangesImplementation ); + var usings = declaration.SyntaxTree.GetCompilationUnitRoot().Usings + .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z))); + var cu = CompilationUnit( List(), - List( - declaration.SyntaxTree.GetCompilationUnitRoot().Usings.AddRange( - namespaces - .Where(z => !string.IsNullOrWhiteSpace(z)) - .Select(z => UsingDirective(ParseName(z))) - ) - ), + List(usings), List(), SingletonList( symbol.ContainingNamespace.IsGlobalNamespace @@ -270,7 +274,7 @@ private static StatementSyntax GenerateApplyChangesBodyPart( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, IdentifierName(propertySymbol.Name), - IdentifierName(propertySymbol.Name) + PostfixUnaryExpression(SyntaxKind.SuppressNullableWarningExpression, IdentifierName(propertySymbol.Name)) ) ) ) @@ -279,7 +283,7 @@ private static StatementSyntax GenerateApplyChangesBodyPart( : AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, valueIdentifier, IdentifierName(propertySymbol.Name)), - IdentifierName(propertySymbol.Name) + PostfixUnaryExpression(SyntaxKind.SuppressNullableWarningExpression, IdentifierName(propertySymbol.Name)) ) ) ) diff --git a/src/Analyzers/SymbolExtensions.cs b/src/Analyzers/SymbolExtensions.cs index 4f0ea10ce..394d0fc56 100644 --- a/src/Analyzers/SymbolExtensions.cs +++ b/src/Analyzers/SymbolExtensions.cs @@ -1,4 +1,6 @@ using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Rocket.Surgery.LaunchPad.Analyzers; @@ -8,4 +10,15 @@ internal static class SymbolExtensions { return symbol.GetAttributes().FirstOrDefault(z => z.AttributeClass?.Name == attributeClassName); } + + public static SyntaxList AddDistinctUsingStatements(this SyntaxList usingDirectiveSyntax, IEnumerable namespaces) + { + foreach (var additionalUsing in namespaces.Where(z => !string.IsNullOrWhiteSpace(z))) + { + if (usingDirectiveSyntax.Any(z => z.Name.ToString() == additionalUsing)) continue; + usingDirectiveSyntax = usingDirectiveSyntax.Add(UsingDirective(ParseName(additionalUsing))); + } + + return usingDirectiveSyntax; + } } diff --git a/src/AspNetCore.Testing/LaunchPadExtension.cs b/src/AspNetCore.Testing/LaunchPadExtension.cs index c7c89b1d3..71d7a7623 100644 --- a/src/AspNetCore.Testing/LaunchPadExtension.cs +++ b/src/AspNetCore.Testing/LaunchPadExtension.cs @@ -12,7 +12,7 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.Testing; /// -/// An that is used for launchpad is used to get the assembly to test +/// An that is used for launchpad is used to get the assembly to test /// /// public class LaunchPadExtension : LaunchPadExtension @@ -94,5 +94,5 @@ public virtual IHostBuilder Configure(IHostBuilder builder) return builder; } } -#pragma warning enable CA1816 -#pragma warning enable CA1063 +#pragma warning restore CA1816 +#pragma warning restore CA1063 diff --git a/src/Foundation/Assigned.cs b/src/Foundation/Assigned.cs index a9c734efa..18fa7c5bb 100644 --- a/src/Foundation/Assigned.cs +++ b/src/Foundation/Assigned.cs @@ -46,8 +46,7 @@ public static implicit operator Assigned(T value) /// /// Implicitly gets the Assigned value. /// - [return: MaybeNull] - public static implicit operator T(Assigned assigned) + public static implicit operator T?(Assigned assigned) { return assigned.Value; } diff --git a/src/Spatial.NewtonsoftJson/WktGeometryConverter.cs b/src/Spatial.NewtonsoftJson/WktGeometryConverter.cs index c153e79ea..6cdd39819 100644 --- a/src/Spatial.NewtonsoftJson/WktGeometryConverter.cs +++ b/src/Spatial.NewtonsoftJson/WktGeometryConverter.cs @@ -18,7 +18,7 @@ public class WktGeometryConverter : GeometryConverter private readonly WKTReader _wktReader; /// - /// Creates an instance of this class using to create geometries. + /// Creates an instance of this class using to create geometries. /// public WktGeometryConverter() : this(Wgs84Factory) { diff --git a/test/.editorconfig b/test/.editorconfig index 8845c9b89..23a65537f 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -11,6 +11,7 @@ dotnet_diagnostic.CA1720.severity = none dotnet_diagnostic.CA1812.severity = none dotnet_diagnostic.CA1848.severity = none dotnet_diagnostic.CA1851.severity = none +dotnet_diagnostic.CA1852.severity = none dotnet_diagnostic.CA2000.severity = none dotnet_diagnostic.CA2225.severity = none dotnet_diagnostic.CA2227.severity = none diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs.txt index ec0aba611..88b2c34c0 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs.txt @@ -7,6 +7,7 @@ public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -20,20 +21,20 @@ public partial class PatchRocket {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (SerialNumber.HasBeenSet()) { - value.SerialNumber = SerialNumber; + state.SerialNumber = SerialNumber!; } if (Type.HasBeenSet()) { - value.Type = Type; + state.Type = Type!; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs.txt index ec0aba611..88b2c34c0 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs.txt @@ -7,6 +7,7 @@ public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -20,20 +21,20 @@ public partial class PatchRocket {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (SerialNumber.HasBeenSet()) { - value.SerialNumber = SerialNumber; + state.SerialNumber = SerialNumber!; } if (Type.HasBeenSet()) { - value.Type = Type; + state.Type = Type!; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs.txt index ec0aba611..88b2c34c0 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs.txt @@ -7,6 +7,7 @@ public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -20,20 +21,20 @@ public partial class PatchRocket {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (SerialNumber.HasBeenSet()) { - value.SerialNumber = SerialNumber; + state.SerialNumber = SerialNumber!; } if (Type.HasBeenSet()) { - value.Type = Type; + state.Type = Type!; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs.txt index e118fbf0b..7d4eaa6e5 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs.txt @@ -8,6 +8,7 @@ public partial record PatchRocket public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool Id { get; init; } @@ -23,25 +24,25 @@ public partial record PatchRocket {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (Id.HasBeenSet()) { - value = value with {Id = Id}; + state = state with {Id = Id!}; } if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs.txt index e118fbf0b..7d4eaa6e5 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs.txt @@ -8,6 +8,7 @@ public partial record PatchRocket public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool Id { get; init; } @@ -23,25 +24,25 @@ public partial record PatchRocket {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (Id.HasBeenSet()) { - value = value with {Id = Id}; + state = state with {Id = Id!}; } if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs.txt index e118fbf0b..7d4eaa6e5 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs.txt @@ -8,6 +8,7 @@ public partial record PatchRocket public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool Id { get; init; } @@ -23,25 +24,25 @@ public partial record PatchRocket {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Request ApplyChanges(global::Request value) + public global::Request ApplyChanges(global::Request state) { if (Id.HasBeenSet()) { - value = value with {Id = Id}; + state = state with {Id = Id!}; } if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs.txt index ecdb6fe89..6275400e4 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs.txt @@ -11,6 +11,7 @@ namespace Sample.Core.Operations.Rockets { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -24,20 +25,20 @@ namespace Sample.Core.Operations.Rockets {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request value) + public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state) { if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs.txt index dbe92fbda..0cca3f54c 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs.txt @@ -9,6 +9,7 @@ namespace Sample.Core.Operations.Rockets { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -22,20 +23,20 @@ namespace Sample.Core.Operations.Rockets {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request value) + public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state) { if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges() diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs.txt index d1c264b3c..9d7fe5cd6 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs.txt @@ -9,6 +9,7 @@ namespace Sample.Core.Operations.Rockets { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); public Rocket.Surgery.LaunchPad.Foundation.Assigned Type { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); +#pragma warning disable CA1034 public record Changes { public bool SerialNumber { get; init; } @@ -22,20 +23,20 @@ namespace Sample.Core.Operations.Rockets {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()}; } - public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request value) + public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state) { if (SerialNumber.HasBeenSet()) { - value = value with {SerialNumber = SerialNumber}; + state = state with {SerialNumber = SerialNumber!}; } if (Type.HasBeenSet()) { - value = value with {Type = Type}; + state = state with {Type = Type!}; } ResetChanges(); - return value; + return state; } public PatchRocket ResetChanges()