diff --git a/Directory.Packages.props b/Directory.Packages.props
index 169ffe5e8..55ed3abaa 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -74,7 +74,7 @@
-
+
diff --git a/LaunchPad.sln b/LaunchPad.sln
index e8e4315bb..2df550346 100644
--- a/LaunchPad.sln
+++ b/LaunchPad.sln
@@ -196,6 +196,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{2EB0
.vscode/tasks.json = .vscode/tasks.json
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6", "src\Analyzers.roslyn4.6\Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6.csproj", "{9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzers.Tests.roslyn4.6", "test\Analyzers.Tests.roslyn4.6\Analyzers.Tests.roslyn4.6.csproj", "{84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -872,6 +876,30 @@ Global
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x64.Build.0 = Release|Any CPU
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x86.ActiveCfg = Release|Any CPU
{4A176BF2-DC9D-4D6B-8F36-B672273CF09B}.Release|x86.Build.0 = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x64.Build.0 = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Debug|x86.Build.0 = Debug|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x64.ActiveCfg = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x64.Build.0 = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x86.ActiveCfg = Release|Any CPU
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6}.Release|x86.Build.0 = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x64.Build.0 = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Debug|x86.Build.0 = Debug|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x64.ActiveCfg = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x64.Build.0 = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x86.ActiveCfg = Release|Any CPU
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -937,6 +965,8 @@ Global
{3B269B1C-0BE2-485C-AFB7-BB24ACF0B178} = {C3A456FA-D2FE-4109-8DC3-E8191F878C1E}
{3F3EA1F9-1174-40B6-95DB-4C85FA611BBB} = {D65A8130-6A58-4693-A96C-8C1DFA3CA355}
{2EB0A486-E55F-424C-9EA3-0ABBC10D0257} = {D65A8130-6A58-4693-A96C-8C1DFA3CA355}
+ {9E08CB1A-1352-40FA-8CEB-0EBCA52689A6} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
+ {84525664-AB7C-46C7-8DDC-ABFC1BB4F6A4} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {439897C2-CCBD-44FE-B2DC-A3E4670ADA59}
diff --git a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
index fe1e41d50..2659881a0 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
@@ -25,41 +25,39 @@ public partial record Request : IRequest
///
/// The updated launch partner
///
- public string Partner { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
+ public string Partner { get; init; } = null!; // TODO: Make generator that can be used to create a writable view model
///
/// The updated launch payload
///
- public string Payload { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
+ public string Payload { get; init; } = null!; // TODO: Make generator that can be used to create a writable view model
///
/// The updated payload weight
///
- public double PayloadWeightKg { get; set; } // TODO: Make generator that can be used to create a writable view model
+ public double PayloadWeightKg { get; init; } // TODO: Make generator that can be used to create a writable view model
///
/// The updated actual launch date
///
- public Instant? ActualLaunchDate { get; set; } // TODO: Make generator that can be used to create a writable view model
+ public Instant? ActualLaunchDate { get; init; } // TODO: Make generator that can be used to create a writable view model
///
/// The scheduled launch date
///
- public Instant ScheduledLaunchDate { get; set; } // TODO: Make generator that can be used to create a writable view model
+ public Instant ScheduledLaunchDate { get; init; } // TODO: Make generator that can be used to create a writable view model
///
/// The update rocket id
///
- public RocketId RocketId { get; set; } // TODO: Make generator that can be used to create a writable view model
+ public RocketId RocketId { get; init; } // TODO: Make generator that can be used to create a writable view model
}
- public partial record PatchRequest : IRequest, IPropertyTracking
- {
- ///
- /// The rocket id
- ///
- public LaunchRecordId Id { get; init; }
- }
+ ///
+ /// The patch request
+ ///
+ /// The rocket id
+ public partial record PatchRequest(LaunchRecordId Id) : IRequest, IPropertyTracking;
private class Mapper : Profile
{
@@ -107,10 +105,11 @@ private class Handler(RocketDbContext dbContext, IMapper mapper, IMediator media
{
private async Task GetLaunchRecord(LaunchRecordId id, CancellationToken cancellationToken)
{
- var rocket = await dbContext.LaunchRecords
- .Include(z => z.Rocket)
- .FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
- .ConfigureAwait(false);
+ var rocket = await dbContext
+ .LaunchRecords
+ .Include(z => z.Rocket)
+ .FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
+ .ConfigureAwait(false);
if (rocket == null)
{
throw new NotFoundException();
@@ -136,4 +135,4 @@ public async Task Handle(Request request, CancellationToken c
return mapper.Map(rocket);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers.roslyn4.4/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.4.csproj b/src/Analyzers.roslyn4.4/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.4.csproj
index f082b2c13..9a76e252f 100644
--- a/src/Analyzers.roslyn4.4/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.4.csproj
+++ b/src/Analyzers.roslyn4.4/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.4.csproj
@@ -3,7 +3,7 @@
netstandard2.0
true
<_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Rocket.Surgery.LaunchPad.Analyzers.", ""))
- $(DefineConstants);ROSLYN4_4
+ $(DefineConstants);ROSLYN4_0;ROSLYN4_4
false
Rocket.Surgery.LaunchPad.Analyzers
true
diff --git a/src/Analyzers.roslyn4.6/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6.csproj b/src/Analyzers.roslyn4.6/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6.csproj
new file mode 100644
index 000000000..e486a2460
--- /dev/null
+++ b/src/Analyzers.roslyn4.6/Rocket.Surgery.LaunchPad.Analyzers.roslyn4.6.csproj
@@ -0,0 +1,19 @@
+
+
+ netstandard2.0
+ true
+ <_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Rocket.Surgery.LaunchPad.Analyzers.", ""))
+ $(DefineConstants);ROSLYN4_0;ROSLYN4_4;ROSLYN4_6
+ false
+ Rocket.Surgery.LaunchPad.Analyzers
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Analyzers/GraphqlMutationActionBodyGenerator.cs b/src/Analyzers/GraphqlMutationActionBodyGenerator.cs
index 3316827a7..bbb330847 100644
--- a/src/Analyzers/GraphqlMutationActionBodyGenerator.cs
+++ b/src/Analyzers/GraphqlMutationActionBodyGenerator.cs
@@ -32,7 +32,8 @@ IParameterSymbol parameter
.WithParameterList(
// ReSharper disable once NullableWarningSuppressionIsUsed
syntax.ParameterList.RemoveNodes(
- syntax.ParameterList.Parameters.SelectMany(z => z.AttributeLists), SyntaxRemoveOptions.KeepNoTrivia
+ syntax.ParameterList.Parameters.SelectMany(z => z.AttributeLists),
+ SyntaxRemoveOptions.KeepNoTrivia
)!
)
.WithAttributeLists(List())
@@ -62,21 +63,18 @@ IParameterSymbol parameter
);
}
- var claimsPrincipalProperty = parameterType
- .GetMembers()
- .FirstOrDefault(
- param => param switch
- {
- IPropertySymbol { Type: not null, IsImplicitlyDeclared: false } ps => SymbolEqualityComparer.Default.Equals(
- claimsPrincipal, ps.Type
- ),
- IFieldSymbol { Type: not null, IsImplicitlyDeclared: false } fs => SymbolEqualityComparer.Default.Equals(
- claimsPrincipal, fs.Type
- ),
- _ => false
- }
- );
- var hasClaimsPrincipal = claimsPrincipalProperty is not null;
+ var claimsPrincipalProperty =
+ parameterType
+ .GetMembers()
+ .FirstOrDefault(
+ param => param switch
+ {
+ IPropertySymbol { IsImplicitlyDeclared: false, } ps => SymbolEqualityComparer.Default.Equals(claimsPrincipal, ps.Type),
+ IFieldSymbol { IsImplicitlyDeclared: false, } fs => SymbolEqualityComparer.Default.Equals(claimsPrincipal, fs.Type),
+ _ => false,
+ }
+ );
+ var hasClaimsPrincipal = claimsPrincipalProperty is { };
if (hasClaimsPrincipal)
{
if (claimsPrincipalParameter is null)
@@ -98,12 +96,24 @@ IParameterSymbol parameter
return null;
}
+ if (mediatorParameter.GetAttribute("HotChocolate.ServiceAttribute") is null)
+ {
+ var node = newSyntax.ParameterList.Parameters.FirstOrDefault(z => z.Identifier.Text == mediatorParameter.Name)!;
+ newSyntax = newSyntax.WithParameterList(
+ newSyntax.ParameterList
+ .ReplaceNode(
+ node,
+ node.WithAttributeLists(
+ SingletonList(AttributeList(SingletonSeparatedList(Attribute(IdentifierName("HotChocolate.ServiceAttribute")))))
+ )
+ )
+ );
+ }
var sendRequestExpression = isStream
? streamMediatorRequest(IdentifierName(parameter.Name), cancellationTokenParameter)
: sendMediatorRequest(IdentifierName(parameter.Name), cancellationTokenParameter);
-
if (parameterType.IsRecord)
{
var expressions = new List();
@@ -120,19 +130,6 @@ IParameterSymbol parameter
// ReSharper enable NullableWarningSuppressionIsUsed
}
- if (cancellationTokenParameter is { })
- {
- // ReSharper disable NullableWarningSuppressionIsUsed
- expressions.Add(
- AssignmentExpression(
- SyntaxKind.SimpleAssignmentExpression,
- IdentifierName(claimsPrincipalProperty!.Name),
- IdentifierName(claimsPrincipalParameter!.Name)
- )
- );
- // ReSharper enable NullableWarningSuppressionIsUsed
- }
-
if (expressions.Any())
{
var withExpression = WithExpression(
@@ -190,7 +187,7 @@ IParameterSymbol parameter
static ExpressionSyntax sendMediatorRequest(ExpressionSyntax nameSyntax, IParameterSymbol? cancellationTokenParameter)
{
- var arguments = new List { Argument(nameSyntax) };
+ var arguments = new List { Argument(nameSyntax), };
if (cancellationTokenParameter is { })
{
arguments.Add(Argument(IdentifierName(cancellationTokenParameter.Name)));
@@ -227,7 +224,7 @@ static ExpressionSyntax sendMediatorRequest(ExpressionSyntax nameSyntax, IParame
static ExpressionSyntax streamMediatorRequest(ExpressionSyntax nameSyntax, IParameterSymbol? cancellationTokenParameter)
{
- var arguments = new List { Argument(nameSyntax) };
+ var arguments = new List { Argument(nameSyntax), };
if (cancellationTokenParameter is { })
{
arguments.Add(Argument(IdentifierName(cancellationTokenParameter.Name)));
@@ -246,59 +243,71 @@ static ExpressionSyntax streamMediatorRequest(ExpressionSyntax nameSyntax, IPara
private void GenerateMethods(
SourceProductionContext context,
- (ClassDeclarationSyntax syntax, INamedTypeSymbol symbol, SemanticModel semanticModel) valueTuple
+ (ClassDeclarationSyntax syntax, INamedTypeSymbol symbol, SemanticModel semanticModel) valueTuple
)
{
- var (syntax, symbol, semanticModel) = valueTuple;
+ ( var syntax, var symbol, var semanticModel ) = valueTuple;
var claimsPrincipal = semanticModel.Compilation.GetTypeByMetadataName("System.Security.Claims.ClaimsPrincipal")!;
var mediator = semanticModel.Compilation.GetTypeByMetadataName("MediatR.IMediator")!;
var cancellationToken = semanticModel.Compilation.GetTypeByMetadataName("System.Threading.CancellationToken")!;
- var members = syntax.Members
- .OfType()
- .Where(z => z.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword)))
- .Select(
- method =>
- {
- var methodSymbol = semanticModel.GetDeclaredSymbol(method);
- // ReSharper disable once UseNullPropagationWhenPossible
- if (methodSymbol is null)
- {
- context.ReportDiagnostic(Diagnostic.Create(GeneratorDiagnostics.TypeMustLiveInSameProject, method.GetLocation()));
- return default;
- }
-
- var request = methodSymbol.Parameters.FirstOrDefault(p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IRequest`1"))
- ?? methodSymbol.Parameters.FirstOrDefault(p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IRequest"));
- var streamRequest = methodSymbol.Parameters.FirstOrDefault(
- p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IStreamRequest`1")
- );
- return ( method, symbol: methodSymbol, request: request ?? streamRequest );
- }
- )
- .Where(z => z is { symbol: { }, method: { } })
- .ToImmutableArray();
-
- var newClass = syntax.WithMembers(List())
- .WithConstraintClauses(List())
- .WithAttributeLists(List())
- .WithBaseList(null)
+ var members = syntax
+ .Members
+ .OfType()
+ .Where(z => z.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword)))
+ .Select(
+ method =>
+ {
+ var methodSymbol = semanticModel.GetDeclaredSymbol(method);
+ // ReSharper disable once UseNullPropagationWhenPossible
+ if (methodSymbol is null)
+ {
+ context.ReportDiagnostic(Diagnostic.Create(GeneratorDiagnostics.TypeMustLiveInSameProject, method.GetLocation()));
+ return default;
+ }
+
+ var request = methodSymbol.Parameters.FirstOrDefault(p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IRequest`1"))
+ ?? methodSymbol.Parameters.FirstOrDefault(p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IRequest"));
+ var streamRequest = methodSymbol.Parameters.FirstOrDefault(
+ p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IStreamRequest`1")
+ );
+ return ( method, symbol: methodSymbol, request: request ?? streamRequest );
+ }
+ )
+ .Where(z => z is { symbol: { }, method: { }, })
+ .ToImmutableArray();
+
+ var newClass = syntax
+ .WithMembers(List())
+ .WithConstraintClauses(List())
+ .WithAttributeLists(List())
+ .WithBaseList(null)
;
- foreach (var (method, methodSymbol, request) in members)
+ foreach (( var method, var methodSymbol, var request ) in members)
{
if (request != null)
{
- var methodBody = GenerateMethod(context, mediator, claimsPrincipal, cancellationToken, method, methodSymbol, request);
+ var methodBody = GenerateMethod(
+ context,
+ mediator,
+ claimsPrincipal,
+ cancellationToken,
+ method,
+ methodSymbol,
+ request
+ );
if (methodBody is null) continue;
newClass = newClass.AddMembers(methodBody);
}
}
- var additionalUsings = new[] { "MediatR" };
+ var additionalUsings = new[] { "MediatR", };
- var usings = syntax.SyntaxTree.GetCompilationUnitRoot().Usings
- .AddDistinctUsingStatements(additionalUsings.Where(z => !string.IsNullOrWhiteSpace(z)));
+ var usings = syntax
+ .SyntaxTree.GetCompilationUnitRoot()
+ .Usings
+ .AddDistinctUsingStatements(additionalUsings.Where(z => !string.IsNullOrWhiteSpace(z)));
var cu = CompilationUnit(
List(),
@@ -326,11 +335,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
.SyntaxProvider
.CreateSyntaxProvider(
(node, _) => node is ClassDeclarationSyntax cds
- && cds.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword))
- && cds.AttributeLists.ContainsAttribute("ExtendObjectType")
- && cds.Members.Any(
- z => z is MethodDeclarationSyntax && z.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword))
- ),
+ && cds.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword))
+ && cds.AttributeLists.ContainsAttribute("ExtendObjectType")
+ && cds.Members.Any(
+ z => z is MethodDeclarationSyntax && z.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword))
+ ),
(syntaxContext, cancellationToken) =>
(
syntax: (ClassDeclarationSyntax)syntaxContext.Node,
@@ -343,4 +352,4 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
context.RegisterSourceOutput(syntaxProvider, GenerateMethods);
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs
index 26f541108..4823dfa00 100644
--- a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs
+++ b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs
@@ -1,3 +1,4 @@
+using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -33,34 +34,39 @@ INamedTypeSymbol targetSymbol
{
context.ReportDiagnostic(
Diagnostic.Create(
- GeneratorDiagnostics.ParameterMustBeSameTypeOfObject, declaration.Keyword.GetLocation(), declaration.GetFullMetadataName(),
+ GeneratorDiagnostics.ParameterMustBeSameTypeOfObject,
+ declaration.Keyword.GetLocation(),
+ declaration.GetFullMetadataName(),
declaration.Keyword.IsKind(SyntaxKind.ClassKeyword) ? "record" : "class"
)
);
return;
}
- var classToInherit = declaration
- .WithMembers(List())
- .WithAttributeLists(List())
- .WithConstraintClauses(List())
- .WithBaseList(null)
- .WithAttributeLists(
- SingletonList(
- AttributeList(
- SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated")))
- )
- )
- );
+ var classToInherit =
+ ( isRecord
+ ? (TypeDeclarationSyntax)RecordDeclaration(Token(SyntaxKind.RecordKeyword), declaration.Identifier)
+ : ClassDeclaration(declaration.Identifier) )
+ .WithModifiers(declaration.Modifiers)
+ .WithOpenBraceToken(Token(SyntaxKind.OpenBraceToken))
+ .WithCloseBraceToken(Token(SyntaxKind.CloseBraceToken))
+ .WithAttributeLists(
+ SingletonList(
+ AttributeList(
+ SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated")))
+ )
+ )
+ );
var writeableProperties =
- targetSymbol.GetMembers()
- .OfType()
- .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false });
+ targetSymbol
+ .GetMembers()
+ .OfType()
+ .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false, });
if (!targetSymbol.IsRecord)
{
// not able to use with operator, so ignore any init only properties.
- writeableProperties = writeableProperties.Where(z => z is { SetMethod.IsInitOnly: false, GetMethod.IsReadOnly: false });
+ writeableProperties = writeableProperties.Where(z => z is { SetMethod.IsInitOnly: false, GetMethod.IsReadOnly: false, });
}
@@ -68,26 +74,55 @@ INamedTypeSymbol targetSymbol
// only works for `set`able properties not init only
.Where(z => !symbol.GetMembers(z.Name).Any())
.ToArray();
- var existingMembers = targetSymbol.GetMembers()
- .OfType()
- .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false })
- .Where(z => symbol.GetMembers(z.Name).Any())
- .Except(writeableProperties);
+ var existingMembers = targetSymbol
+ .GetMembers()
+ .OfType()
+ .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false, })
+ .Where(z => symbol.GetMembers(z.Name).Any())
+ .Except(writeableProperties)
+ .ToArray();
+
+ var memberNamesSet = targetSymbol.MemberNames.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
+
+ var constructor = targetSymbol
+ .Constructors
+ .Where(z => !z.Parameters.Any(x => SymbolEqualityComparer.Default.Equals(x.Type, targetSymbol)))
+ .Where(z => !z.IsImplicitlyDeclared)
+ .OrderByDescending(z => z.Parameters.Length)
+ .FirstOrDefault();
+
+ existingMembers = existingMembers
+ .Except(
+ existingMembers
+ .Join(
+ constructor?.Parameters ?? ImmutableArray.Empty,
+ z => z.Name,
+ z => z.Name,
+ (a, _) => a,
+ StringComparer.OrdinalIgnoreCase
+ )
+ )
+ .ToArray();
+ var createArgumentList = constructor is null
+ ? ArgumentList()
+ : ArgumentList(
+ SeparatedList(constructor.Parameters.Select(z => Argument(IdentifierName(memberNamesSet.TryGetValue(z.Name, out var name) ? name : z.Name))))
+ );
var createBody = Block()
.AddStatements(
LocalDeclarationStatement(
VariableDeclaration(
- IdentifierName(Identifier(TriviaList(), SyntaxKind.VarKeyword, "var", "var", TriviaList()))
- ).WithVariables(
- SingletonSeparatedList(
- VariableDeclarator(Identifier("value"))
- .WithInitializer(
- EqualsValueClause(
- ObjectCreationExpression(
- IdentifierName(Identifier(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)))
- )
- .WithInitializer(
+ IdentifierName(Identifier(TriviaList(), SyntaxKind.VarKeyword, "var", "var", TriviaList()))
+ )
+ .WithVariables(
+ SingletonSeparatedList(
+ VariableDeclarator(Identifier("value"))
+ .WithInitializer(
+ EqualsValueClause(
+ ObjectCreationExpression(
+ IdentifierName(Identifier(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))),
+ createArgumentList,
InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SeparatedList(
@@ -103,10 +138,10 @@ INamedTypeSymbol targetSymbol
)
)
)
+ )
)
- )
+ )
)
- )
)
);
@@ -133,12 +168,12 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
ITypeSymbol propertyType;
propertyType = propertySymbol.Type is INamedTypeSymbol
{
- Name: "Assigned", ContainingAssembly.Name: "Rocket.Surgery.LaunchPad.Foundation"
+ Name: "Assigned", ContainingAssembly.Name: "Rocket.Surgery.LaunchPad.Foundation",
} namedTypeSymbol
? namedTypeSymbol.TypeArguments[0]
: propertySymbol.Type;
type = ParseTypeName(propertyType.ToDisplayString(NullableFlowState.MaybeNull, SymbolDisplayFormat.MinimallyQualifiedFormat));
- if (propertyType is { TypeKind: TypeKind.Struct or TypeKind.Enum } && type is not NullableTypeSyntax)
+ if (propertyType is { TypeKind: TypeKind.Struct or TypeKind.Enum, } && type is not NullableTypeSyntax)
{
type = NullableType(type);
}
@@ -152,8 +187,12 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
);
}
+ // declaration.Members.OfType();
+ // or primary consturctor list
+
var createMethod = MethodDeclaration(
- ParseTypeName(targetSymbol.ToDisplayString(NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat)), "Create"
+ ParseTypeName(targetSymbol.ToDisplayString(NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat)),
+ "Create"
)
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)))
.WithBody(
@@ -163,8 +202,10 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
);
classToInherit = classToInherit.AddMembers(createMethod);
- var usings = declaration.SyntaxTree.GetCompilationUnitRoot().Usings
- .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z)));
+ var usings = declaration
+ .SyntaxTree.GetCompilationUnitRoot()
+ .Usings
+ .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z)));
var cu = CompilationUnit(
List(),
@@ -189,7 +230,9 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
}
private static StatementSyntax GenerateApplyChangesBodyPart(
- IPropertySymbol propertySymbol, IdentifierNameSyntax valueIdentifier, bool isRecord
+ IPropertySymbol propertySymbol,
+ IdentifierNameSyntax valueIdentifier,
+ bool isRecord
)
{
return IfStatement(
@@ -202,7 +245,9 @@ private static StatementSyntax GenerateApplyChangesBodyPart(
SingletonList(
ExpressionStatement(
GenerateAssignmentExpression(
- propertySymbol, valueIdentifier, isRecord,
+ propertySymbol,
+ valueIdentifier,
+ isRecord,
propertySymbol.NullableAnnotation == NullableAnnotation.NotAnnotated && propertySymbol.Type.TypeKind == TypeKind.Struct
? BinaryExpression(
SyntaxKind.CoalesceExpression,
@@ -229,7 +274,10 @@ private static StatementSyntax GenerateApplyChangesBodyPart(
}
private static AssignmentExpressionSyntax GenerateAssignmentExpression(
- IPropertySymbol propertySymbol, IdentifierNameSyntax valueIdentifier, bool isRecord, ExpressionSyntax valueExpression
+ IPropertySymbol propertySymbol,
+ IdentifierNameSyntax valueIdentifier,
+ bool isRecord,
+ ExpressionSyntax valueExpression
)
{
return isRecord
@@ -279,48 +327,51 @@ private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySym
}
)
)
- )
+ ),
};
}
///
public void Initialize(IncrementalGeneratorInitializationContext context)
{
- var values = context.SyntaxProvider
- .CreateSyntaxProvider(
- static (node, _) =>
- node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationSyntax
+ var values = context
+ .SyntaxProvider
+ .CreateSyntaxProvider(
+ static (node, _) =>
+ node is (ClassDeclarationSyntax or RecordDeclarationSyntax)
+ and TypeDeclarationSyntax
{
- BaseList: { } baseList
- } && baseList.Types.Any(
- z => z.Type is GenericNameSyntax qns && qns.Identifier.Text.EndsWith("IOptionalTracking", StringComparison.Ordinal)
- ),
- static (syntaxContext, token) => (
- syntax: (TypeDeclarationSyntax)syntaxContext.Node, semanticModel: syntaxContext.SemanticModel,
- // ReSharper disable once NullableWarningSuppressionIsUsed
- symbol: syntaxContext.SemanticModel.GetDeclaredSymbol((TypeDeclarationSyntax)syntaxContext.Node, token)!
- )
- )
- .Select(
- (tuple, _) =>
- {
- var interfaceSymbol = tuple.symbol
- .Interfaces.FirstOrDefault(
- z => z.Name.StartsWith("IOptionalTracking", StringComparison.Ordinal)
- );
- var targetSymbol = interfaceSymbol?.ContainingAssembly.Name == "Rocket.Surgery.LaunchPad.HotChocolate"
- ? (INamedTypeSymbol?)interfaceSymbol.TypeArguments[0]
- : null;
- return (
- tuple.symbol,
- tuple.syntax,
- tuple.semanticModel,
- interfaceSymbol,
- targetSymbol
- );
- }
- )
- .Where(x => x.symbol is not null && x.targetSymbol is not null);
+ BaseList: { } baseList,
+ }
+ && baseList.Types.Any(
+ z => z.Type is GenericNameSyntax qns && qns.Identifier.Text.EndsWith("IOptionalTracking", StringComparison.Ordinal)
+ ),
+ static (syntaxContext, token) => (
+ syntax: (TypeDeclarationSyntax)syntaxContext.Node, semanticModel: syntaxContext.SemanticModel,
+ // ReSharper disable once NullableWarningSuppressionIsUsed
+ symbol: syntaxContext.SemanticModel.GetDeclaredSymbol((TypeDeclarationSyntax)syntaxContext.Node, token)!
+ )
+ )
+ .Select(
+ (tuple, _) =>
+ {
+ var interfaceSymbol = tuple.symbol
+ .Interfaces.FirstOrDefault(
+ z => z.Name.StartsWith("IOptionalTracking", StringComparison.Ordinal)
+ );
+ var targetSymbol = interfaceSymbol?.ContainingAssembly.Name == "Rocket.Surgery.LaunchPad.HotChocolate"
+ ? (INamedTypeSymbol?)interfaceSymbol.TypeArguments[0]
+ : null;
+ return (
+ tuple.symbol,
+ tuple.syntax,
+ tuple.semanticModel,
+ interfaceSymbol,
+ targetSymbol
+ );
+ }
+ )
+ .Where(x => x.symbol is { } && x.targetSymbol is { });
context.RegisterSourceOutput(
values,
@@ -328,4 +379,4 @@ node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationS
static (productionContext, tuple) => GeneratePropertyTracking(productionContext, tuple.syntax, tuple.symbol, tuple.targetSymbol!)
);
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers/PropertyTrackingGenerator.cs b/src/Analyzers/PropertyTrackingGenerator.cs
index 82debc9e7..3653140e4 100644
--- a/src/Analyzers/PropertyTrackingGenerator.cs
+++ b/src/Analyzers/PropertyTrackingGenerator.cs
@@ -1,3 +1,4 @@
+using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -34,36 +35,42 @@ INamedTypeSymbol targetSymbol
{
context.ReportDiagnostic(
Diagnostic.Create(
- GeneratorDiagnostics.ParameterMustBeSameTypeOfObject, declaration.Keyword.GetLocation(), declaration.GetFullMetadataName(),
+ GeneratorDiagnostics.ParameterMustBeSameTypeOfObject,
+ declaration.Keyword.GetLocation(),
+ declaration.GetFullMetadataName(),
declaration.Keyword.IsKind(SyntaxKind.ClassKeyword) ? "record" : "class"
)
);
return;
}
- var classToInherit = declaration
- .WithMembers(List())
- .WithAttributeLists(List())
- .WithConstraintClauses(List())
- .WithBaseList(null)
- .WithAttributeLists(
- SingletonList(
- AttributeList(
- SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated")))
- )
- )
- );
+ var classToInherit =
+ ( isRecord
+ ? (TypeDeclarationSyntax)RecordDeclaration(Token(SyntaxKind.RecordKeyword), declaration.Identifier)
+ : ClassDeclaration(declaration.Identifier) )
+ .WithModifiers(declaration.Modifiers)
+ .WithOpenBraceToken(Token(SyntaxKind.OpenBraceToken))
+ .WithCloseBraceToken(Token(SyntaxKind.CloseBraceToken))
+ .WithAttributeLists(
+ SingletonList(
+ AttributeList(
+ SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated")))
+ )
+ )
+ );
var writeableProperties =
- targetSymbol.GetMembers()
- .OfType()
- // only works for `set`able properties not init only
- .Where(z => !symbol.GetMembers(z.Name).Any())
- .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false });
+ targetSymbol
+ .GetMembers()
+ .OfType()
+ // only works for `set`able properties not init only
+ .Where(z => !symbol.GetMembers(z.Name).Any())
+ .Where(z => z is { IsStatic: false, IsIndexer: false, IsReadOnly: false, })
+ .ToArray();
if (!targetSymbol.IsRecord)
{
// not able to use with operator, so ignore any init only properties.
- writeableProperties = writeableProperties.Where(z => z is { SetMethod.IsInitOnly: false, GetMethod.IsReadOnly: false });
+ writeableProperties = writeableProperties.Where(z => z is { SetMethod.IsInitOnly: false, GetMethod.IsReadOnly: false, }).ToArray();
}
var changesRecord = RecordDeclaration(Token(SyntaxKind.RecordKeyword), "Changes")
@@ -80,6 +87,7 @@ INamedTypeSymbol targetSymbol
var getChangedStateMethodInitializer = InitializerExpression(SyntaxKind.ObjectInitializerExpression);
var applyChangesBody = Block();
var resetChangesBody = Block();
+ var createMethodInitializer = InitializerExpression(SyntaxKind.ObjectInitializerExpression);
var namespaces = new HashSet();
static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbol symbol)
@@ -102,7 +110,10 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
var type = ParseTypeName(propertySymbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
AddNamespacesFromPropertyType(namespaces, propertySymbol.Type);
- classToInherit = classToInherit.AddMembers(GenerateTrackingProperties(propertySymbol, type));
+ var assignedType = GenericName(Identifier("Rocket.Surgery.LaunchPad.Foundation.Assigned"))
+ .WithTypeArgumentList(TypeArgumentList(SingletonSeparatedList(type)));
+
+ classToInherit = classToInherit.AddMembers(GenerateTrackingProperties(propertySymbol, assignedType));
changesRecord = changesRecord.AddMembers(
PropertyDeclaration(PredefinedType(Token(SyntaxKind.BoolKeyword)), Identifier(propertySymbol.Name))
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)))
@@ -112,7 +123,7 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
new[]
{
AccessorDeclaration(SyntaxKind.GetAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
- AccessorDeclaration(SyntaxKind.InitAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken))
+ AccessorDeclaration(SyntaxKind.InitAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
}
)
)
@@ -131,6 +142,32 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
)
)
);
+ createMethodInitializer = createMethodInitializer.AddExpressions(
+ AssignmentExpression(
+ SyntaxKind.SimpleAssignmentExpression,
+ IdentifierName(propertySymbol.Name),
+ InvocationExpression(
+ MemberAccessExpression(
+ SyntaxKind.SimpleMemberAccessExpression,
+ assignedType,
+ IdentifierName("Empty")
+ )
+ )
+ .WithArgumentList(
+ ArgumentList(
+ SingletonSeparatedList(
+ Argument(
+ MemberAccessExpression(
+ SyntaxKind.SimpleMemberAccessExpression,
+ IdentifierName("value"),
+ IdentifierName(propertySymbol.Name)
+ )
+ )
+ )
+ )
+ )
+ )
+ );
applyChangesBody = applyChangesBody.AddStatements(
GenerateApplyChangesBodyPart(propertySymbol, IdentifierName("state"), isRecord)
);
@@ -163,7 +200,8 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
var getChangedStateMethod =
MethodDeclaration(
- ParseTypeName("Changes"), Identifier("GetChangedState")
+ ParseTypeName("Changes"),
+ Identifier("GetChangedState")
)
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)))
.WithBody(
@@ -183,9 +221,10 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
.WithParameterList(
ParameterList(
SingletonSeparatedList(
- Parameter(Identifier("state")).WithType(
- IdentifierName(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))
- )
+ Parameter(Identifier("state"))
+ .WithType(
+ IdentifierName(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))
+ )
)
)
)
@@ -213,17 +252,72 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
)
.WithBody(Block().AddStatements(ExpressionStatement(InvocationExpression(IdentifierName("ResetChanges")))));
+
+ var memberNamesSet = symbol.MemberNames.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
+ var constructor = symbol
+ .Constructors
+ .Where(z => !z.Parameters.Any(x => SymbolEqualityComparer.Default.Equals(x.Type, targetSymbol)))
+ .Where(z => !z.IsImplicitlyDeclared)
+ .OrderByDescending(z => z.Parameters.Length)
+ .FirstOrDefault();
+
+ var createArgumentList = constructor is null
+ ? ArgumentList()
+ : ArgumentList(
+ SeparatedList(
+ constructor.Parameters
+ .Select(
+ z => Argument(
+ MemberAccessExpression(
+ SyntaxKind.SimpleMemberAccessExpression,
+ IdentifierName("value"),
+ IdentifierName(memberNamesSet.TryGetValue(z.Name, out var name) ? name : z.Name)
+ )
+ )
+ )
+ )
+ );
+
+ var createMethod = MethodDeclaration(
+ ParseTypeName(symbol.ToDisplayString(NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat)),
+ "Create"
+ )
+ .WithParameterList(
+ ParameterList(
+ SingletonSeparatedList(
+ Parameter(Identifier("value"))
+ .WithType(
+ ParseTypeName(targetSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))
+ )
+ )
+ )
+ )
+ .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)))
+ .WithExpressionBody(
+ ArrowExpressionClause(
+ ObjectCreationExpression(
+ IdentifierName(Identifier(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))),
+ createArgumentList,
+ createMethodInitializer
+ )
+ )
+ )
+ .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
+
classToInherit = classToInherit
.AddMembers(
changesRecord,
getChangedStateMethod,
applyChangesMethod,
resetChangesMethod,
- resetChangesImplementation
+ resetChangesImplementation,
+ createMethod
);
- var usings = declaration.SyntaxTree.GetCompilationUnitRoot().Usings
- .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z)));
+ var usings = declaration
+ .SyntaxTree.GetCompilationUnitRoot()
+ .Usings
+ .AddDistinctUsingStatements(namespaces.Where(z => !string.IsNullOrWhiteSpace(z)));
var cu = CompilationUnit(
List(),
@@ -248,7 +342,9 @@ static void AddNamespacesFromPropertyType(HashSet namespaces, ITypeSymbo
}
private static StatementSyntax GenerateApplyChangesBodyPart(
- IPropertySymbol propertySymbol, IdentifierNameSyntax valueIdentifier, bool isRecord
+ IPropertySymbol propertySymbol,
+ IdentifierNameSyntax valueIdentifier,
+ bool isRecord
)
{
return IfStatement(
@@ -291,13 +387,11 @@ private static StatementSyntax GenerateApplyChangesBodyPart(
);
}
- private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySymbol propertySymbol, TypeSyntax typeSyntax)
+ private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySymbol propertySymbol, GenericNameSyntax assignedType)
{
- var type = GenericName(Identifier("Rocket.Surgery.LaunchPad.Foundation.Assigned"))
- .WithTypeArgumentList(TypeArgumentList(SingletonSeparatedList(typeSyntax)));
return new MemberDeclarationSyntax[]
{
- PropertyDeclaration(type, Identifier(propertySymbol.Name))
+ PropertyDeclaration(assignedType, Identifier(propertySymbol.Name))
.WithModifiers(
TokenList(
Token(SyntaxKind.PublicKeyword)
@@ -309,16 +403,17 @@ private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySym
new[]
{
AccessorDeclaration(SyntaxKind.GetAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
- AccessorDeclaration(SyntaxKind.SetAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken))
+ AccessorDeclaration(SyntaxKind.SetAccessorDeclaration).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
}
)
)
- ).WithInitializer(
+ )
+ .WithInitializer(
EqualsValueClause(
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
- type,
+ assignedType,
IdentifierName("Empty")
)
)
@@ -335,48 +430,52 @@ private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySym
)
)
)
- ).WithSemicolonToken(Token(SyntaxKind.SemicolonToken))
+ )
+ .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
};
}
///
public void Initialize(IncrementalGeneratorInitializationContext context)
{
- var values = context.SyntaxProvider
- .CreateSyntaxProvider(
- static (node, _) =>
- node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationSyntax
+ var values = context
+ .SyntaxProvider
+ .CreateSyntaxProvider(
+ static (node, _) =>
+ node is (ClassDeclarationSyntax or RecordDeclarationSyntax)
+ and TypeDeclarationSyntax
{
- BaseList: { } baseList
- } && baseList.Types.Any(
- z => z.Type is GenericNameSyntax qns && qns.Identifier.Text.EndsWith("IPropertyTracking", StringComparison.Ordinal)
- ),
- static (syntaxContext, token) => (
- syntax: (TypeDeclarationSyntax)syntaxContext.Node, semanticModel: syntaxContext.SemanticModel,
- // ReSharper disable once NullableWarningSuppressionIsUsed
- symbol: syntaxContext.SemanticModel.GetDeclaredSymbol((TypeDeclarationSyntax)syntaxContext.Node, token)!
- )
- )
- .Select(
- (tuple, _) =>
- {
- var interfaceSymbol = tuple.symbol
- .Interfaces.FirstOrDefault(
- z => z.Name.StartsWith("IPropertyTracking", StringComparison.Ordinal)
- );
- var targetSymbol = interfaceSymbol?.ContainingAssembly.Name == "Rocket.Surgery.LaunchPad.Foundation"
- ? (INamedTypeSymbol?)interfaceSymbol.TypeArguments[0]
- : null;
- return (
- tuple.symbol,
- tuple.syntax,
- tuple.semanticModel,
- interfaceSymbol,
- targetSymbol
- );
- }
- )
- .Where(x => x.symbol is not null && x.targetSymbol is not null);
+ BaseList: { } baseList,
+ }
+ && baseList.Types.Any(
+ z => z.Type is GenericNameSyntax qns && qns.Identifier.Text.EndsWith("IPropertyTracking", StringComparison.Ordinal)
+ ),
+ static (syntaxContext, token) => (
+ syntax: (TypeDeclarationSyntax)syntaxContext.Node, semanticModel: syntaxContext.SemanticModel,
+ // ReSharper disable once NullableWarningSuppressionIsUsed
+ symbol: syntaxContext.SemanticModel.GetDeclaredSymbol((TypeDeclarationSyntax)syntaxContext.Node, token)!
+ )
+ )
+ .Select(
+ (tuple, _) =>
+ {
+ var interfaceSymbol = tuple.symbol
+ .Interfaces.FirstOrDefault(
+ z => z.Name.StartsWith("IPropertyTracking", StringComparison.Ordinal)
+ );
+ var targetSymbol = interfaceSymbol?.ContainingAssembly.Name == "Rocket.Surgery.LaunchPad.Foundation"
+ ? (INamedTypeSymbol?)interfaceSymbol.TypeArguments[0]
+ : null;
+ return (
+ tuple.symbol,
+ tuple.syntax,
+ tuple.semanticModel,
+ interfaceSymbol,
+ targetSymbol
+ );
+ }
+ )
+ .Where(x => x.symbol is { } && x.targetSymbol is { });
context.RegisterSourceOutput(
values,
@@ -384,4 +483,4 @@ node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationS
static (productionContext, tuple) => GeneratePropertyTracking(productionContext, tuple.syntax, tuple.symbol, tuple.targetSymbol!)
);
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers/Rocket.Surgery.LaunchPad.Analyzers.csproj b/src/Analyzers/Rocket.Surgery.LaunchPad.Analyzers.csproj
index cf08cf9df..8e41f242f 100644
--- a/src/Analyzers/Rocket.Surgery.LaunchPad.Analyzers.csproj
+++ b/src/Analyzers/Rocket.Surgery.LaunchPad.Analyzers.csproj
@@ -2,7 +2,7 @@
netstandard2.0
true
- $(DefineConstants);ROSLYN4_0;ROSLYN4_4
+ $(DefineConstants);ROSLYN4_0;ROSLYN4_4;ROSLYN4_6;ROSLYN4_8
true
@@ -19,6 +19,11 @@
PrivateAssets="all"
ReferenceOutputAssembly="false"
/>
+
+
+
diff --git a/src/Analyzers/SymbolExtensions.cs b/src/Analyzers/SymbolExtensions.cs
index 394d0fc56..8d8e880eb 100644
--- a/src/Analyzers/SymbolExtensions.cs
+++ b/src/Analyzers/SymbolExtensions.cs
@@ -8,10 +8,15 @@ internal static class SymbolExtensions
{
public static AttributeData? GetAttribute(this ISymbol symbol, string attributeClassName)
{
- return symbol.GetAttributes().FirstOrDefault(z => z.AttributeClass?.Name == attributeClassName);
+ return symbol
+ .GetAttributes()
+ .FirstOrDefault(z => z.AttributeClass?.Name == attributeClassName || z.AttributeClass.GetFullMetadataName() == attributeClassName);
}
- public static SyntaxList AddDistinctUsingStatements(this SyntaxList usingDirectiveSyntax, IEnumerable namespaces)
+ public static SyntaxList AddDistinctUsingStatements(
+ this SyntaxList usingDirectiveSyntax,
+ IEnumerable namespaces
+ )
{
foreach (var additionalUsing in namespaces.Where(z => !string.IsNullOrWhiteSpace(z)))
{
@@ -21,4 +26,4 @@ public static SyntaxList AddDistinctUsingStatements(this S
return usingDirectiveSyntax;
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers/SyntaxExtensions.cs b/src/Analyzers/SyntaxExtensions.cs
index 7c1b3adea..46fab0035 100644
--- a/src/Analyzers/SyntaxExtensions.cs
+++ b/src/Analyzers/SyntaxExtensions.cs
@@ -28,11 +28,12 @@ TypeDeclarationSyntax source
var parent = source.Parent;
while (parent is TypeDeclarationSyntax parentSyntax)
{
- classToNest = parentSyntax
- .WithMembers(SyntaxFactory.List())
- .WithAttributeLists(SyntaxFactory.List())
- .WithConstraintClauses(SyntaxFactory.List())
- .WithBaseList(null)
+ classToNest = ( parentSyntax is RecordDeclarationSyntax
+ ? (TypeDeclarationSyntax)SyntaxFactory.RecordDeclaration(SyntaxFactory.Token(SyntaxKind.RecordKeyword), parentSyntax.Identifier)
+ : SyntaxFactory.ClassDeclaration(parentSyntax.Identifier) )
+ .WithModifiers(parentSyntax.Modifiers)
+ .WithOpenBraceToken(SyntaxFactory.Token(SyntaxKind.OpenBraceToken))
+ .WithCloseBraceToken(SyntaxFactory.Token(SyntaxKind.CloseBraceToken))
.AddMembers(classToNest);
if (!parentSyntax.Modifiers.Any(z => z.IsKind(SyntaxKind.PartialKeyword)))
@@ -114,15 +115,15 @@ static bool IsRootNamespace(ISymbol symbol)
public static string? GetSyntaxName(this TypeSyntax typeSyntax)
{
return typeSyntax switch
- {
- SimpleNameSyntax sns => sns.Identifier.Text,
- QualifiedNameSyntax qns => qns.Right.Identifier.Text,
- NullableTypeSyntax nts => nts.ElementType.GetSyntaxName() + "?",
- PredefinedTypeSyntax pts => pts.Keyword.Text,
- ArrayTypeSyntax ats => ats.ElementType.GetSyntaxName() + "[]",
- TupleTypeSyntax tts => "(" + tts.Elements.Select(z => $"{z.Type.GetSyntaxName()}{z.Identifier.Text}") + ")",
- _ => null // there might be more but for now... throw new NotSupportedException(typeSyntax.GetType().FullName)
- };
+ {
+ SimpleNameSyntax sns => sns.Identifier.Text,
+ QualifiedNameSyntax qns => qns.Right.Identifier.Text,
+ NullableTypeSyntax nts => nts.ElementType.GetSyntaxName() + "?",
+ PredefinedTypeSyntax pts => pts.Keyword.Text,
+ ArrayTypeSyntax ats => ats.ElementType.GetSyntaxName() + "[]",
+ TupleTypeSyntax tts => "(" + tts.Elements.Select(z => $"{z.Type.GetSyntaxName()}{z.Identifier.Text}") + ")",
+ _ => null, // there might be more but for now... throw new NotSupportedException(typeSyntax.GetType().FullName)
+ };
}
public static bool ContainsAttribute(this TypeDeclarationSyntax syntax, string attributePrefixes) // string is comma separated
@@ -132,7 +133,7 @@ public static bool ContainsAttribute(this TypeDeclarationSyntax syntax, string a
public static bool ContainsAttribute(this AttributeListSyntax list, string attributePrefixes) // string is comma separated
{
- if (list is { Attributes: { Count: 0 } })
+ if (list is { Attributes: { Count: 0, }, })
return false;
var names = GetNames(attributePrefixes);
@@ -147,7 +148,7 @@ public static bool ContainsAttribute(this AttributeListSyntax list, string attri
public static bool ContainsAttribute(this in SyntaxList list, string attributePrefixes) // string is comma separated
{
- if (list is { Count: 0 })
+ if (list is { Count: 0, })
return false;
var names = GetNames(attributePrefixes);
@@ -170,7 +171,7 @@ public static bool ContainsAttribute(this in SyntaxList lis
public static AttributeSyntax? GetAttribute(this AttributeListSyntax list, string attributePrefixes) // string is comma separated
{
- if (list is { Attributes: { Count: 0 } })
+ if (list is { Attributes: { Count: 0, }, })
return null;
var names = GetNames(attributePrefixes);
@@ -185,7 +186,7 @@ public static bool ContainsAttribute(this in SyntaxList lis
public static AttributeSyntax? GetAttribute(this in SyntaxList list, string attributePrefixes) // string is comma separated
{
- if (list is { Count: 0 })
+ if (list is { Count: 0, })
return null;
var names = GetNames(attributePrefixes);
@@ -213,10 +214,10 @@ private static HashSet GetNames(string attributePrefixes)
{
if (!AttributeNames.TryGetValue(attributePrefixes, out var names))
{
- names = new HashSet(attributePrefixes.Split(',').SelectMany(z => new[] { z, z + "Attribute" }));
+ names = new(attributePrefixes.Split(',').SelectMany(z => new[] { z, z + "Attribute", }));
AttributeNames.TryAdd(attributePrefixes, names);
}
return names;
}
-}
+}
\ No newline at end of file
diff --git a/src/HotChocolate/IPropertyTracking.cs b/src/HotChocolate/IPropertyTracking.cs
index 7a818d459..2057ddb2c 100644
--- a/src/HotChocolate/IPropertyTracking.cs
+++ b/src/HotChocolate/IPropertyTracking.cs
@@ -11,14 +11,4 @@ namespace Rocket.Surgery.LaunchPad.HotChocolate;
///
///
[PublicAPI]
-public interface IOptionalTracking where T : new()
-{
- ///
- /// Method used to create the request from this given object
- ///
- ///
- /// For records this will return a new record instance for classes it will mutate the existing instance.
- ///
- ///
- T Create();
-}
+public interface IOptionalTracking;
\ No newline at end of file
diff --git a/test/Analyzers.Tests.roslyn4.0/Analyzers.Tests.roslyn4.0.csproj b/test/Analyzers.Tests.roslyn4.0/Analyzers.Tests.roslyn4.0.csproj
index 791ba6fb0..623ca4948 100644
--- a/test/Analyzers.Tests.roslyn4.0/Analyzers.Tests.roslyn4.0.csproj
+++ b/test/Analyzers.Tests.roslyn4.0/Analyzers.Tests.roslyn4.0.csproj
@@ -2,7 +2,7 @@
net6.0;net7.0;net8.0
<_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Analyzers.Tests.", ""))
- $(DefineConstants);$(_Analyzer_Roslyn_Version_.ToUpper().Replace(".", "_"))
+ $(DefineConstants);ROSLYN_CURRENT;ROSLYN4_0
Analyzers.Tests
Analyzers.Tests
diff --git a/test/Analyzers.Tests.roslyn4.4/Analyzers.Tests.roslyn4.4.csproj b/test/Analyzers.Tests.roslyn4.4/Analyzers.Tests.roslyn4.4.csproj
index 791ba6fb0..c30892b36 100644
--- a/test/Analyzers.Tests.roslyn4.4/Analyzers.Tests.roslyn4.4.csproj
+++ b/test/Analyzers.Tests.roslyn4.4/Analyzers.Tests.roslyn4.4.csproj
@@ -2,7 +2,7 @@
net6.0;net7.0;net8.0
<_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Analyzers.Tests.", ""))
- $(DefineConstants);$(_Analyzer_Roslyn_Version_.ToUpper().Replace(".", "_"))
+ $(DefineConstants);ROSLYN_CURRENT;ROSLYN4_0;ROSLYN4_4
Analyzers.Tests
Analyzers.Tests
diff --git a/test/Analyzers.Tests.roslyn4.6/Analyzers.Tests.roslyn4.6.csproj b/test/Analyzers.Tests.roslyn4.6/Analyzers.Tests.roslyn4.6.csproj
new file mode 100644
index 000000000..77910315b
--- /dev/null
+++ b/test/Analyzers.Tests.roslyn4.6/Analyzers.Tests.roslyn4.6.csproj
@@ -0,0 +1,20 @@
+
+
+ net6.0;net7.0;net8.0
+ <_Analyzer_Roslyn_Version_>$(MSBuildProjectName.Replace("Analyzers.Tests.", ""))
+ $(DefineConstants);ROSLYN_CURRENT;ROSLYN4_0;ROSLYN4_4;ROSLYN4_6
+ Analyzers.Tests
+ Analyzers.Tests
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/Analyzers.Tests/Analyzers.Tests.csproj b/test/Analyzers.Tests/Analyzers.Tests.csproj
index a019da62f..6bd62b745 100644
--- a/test/Analyzers.Tests/Analyzers.Tests.csproj
+++ b/test/Analyzers.Tests/Analyzers.Tests.csproj
@@ -1,7 +1,7 @@
net6.0;net8.0
- $(DefineConstants);ROSLYN_CURRENT;ROSLYN4_0;ROSLYN4_4
+ $(DefineConstants);ROSLYN_CURRENT;ROSLYN4_0;ROSLYN4_4;ROSLYN4_6;ROSLYN4_8
diff --git a/test/Analyzers.Tests/GraphqlMutationActionBodyGeneratorTests.cs b/test/Analyzers.Tests/GraphqlMutationActionBodyGeneratorTests.cs
index 485205cc1..8757f95e8 100644
--- a/test/Analyzers.Tests/GraphqlMutationActionBodyGeneratorTests.cs
+++ b/test/Analyzers.Tests/GraphqlMutationActionBodyGeneratorTests.cs
@@ -75,6 +75,7 @@ public GraphqlMutationActionBodyGeneratorTests(ITestOutputHelper testOutputHelpe
global using System.Threading.Tasks;
global using HotChocolate;
global using HotChocolate.Types;
+global using System.Security.Claims;
"
);
}
@@ -167,7 +168,7 @@ public partial class RocketMutation
/// Get the launch records for a given rocket
///
///
- public partial IAsyncEnumerable GetRocketLaunchRecords([Service] IMediator mediator, GetRocketLaunchRecords.Request request);
+ public partial IAsyncEnumerable GetRocketLaunchRecords(IMediator mediator, GetRocketLaunchRecords.Request request);
///
/// Get a specific launch record for a given rocket
@@ -307,7 +308,7 @@ public partial class RocketMutation
namespace TestNamespace;
public static class Save2Rocket
{
- public class Request : IRequest
+ public record Request : IRequest
{
public Guid Id { get; set; }
public string? Sn { get; init; } = null!;
@@ -324,7 +325,7 @@ namespace MyNamespace.Controllers;
[ExtendObjectType(OperationTypeNames.Mutation)]
public partial class RocketMutation
{
- public partial Task Save2Rocket([Service] IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal claimsPrincipal);
+ public partial Task Save2Rocket([Service] IMediator mediator, ClaimsPrincipal claimsPrincipal, Save2Rocket.Request request);
}",
}
);
@@ -365,7 +366,6 @@ public partial class RocketMutation
{
defaultString,
@"
-using System.Security.Claims;
namespace TestNamespace;
public static class Save2Rocket
{
@@ -417,6 +417,37 @@ namespace MyNamespace.Controllers;
public partial class RocketMutation
{
public partial Task Save2Rocket([Service] IMediator mediator, Save2Rocket.Request request, CancellationToken cancellationToken);
+}",
+ }
+ );
+ Add(
+ "GenerateBodyWithCancellationTokenAndClaimsPrincipal",
+ new[]
+ {
+ defaultString,
+ @"
+using System.Threading;
+namespace TestNamespace;
+public static class Save2Rocket
+{
+ public record Request : IRequest
+ {
+ public Guid Id { get; set; }
+ public string? Sn { get; init; } = null!;
+ public ClaimsPrincipal ClaimsPrincipal { get; init; }
+ public string Other { get; init; }
+ }
+}",
+ @"
+using TestNamespace;
+using System.Threading;
+
+namespace MyNamespace.Controllers;
+
+[ExtendObjectType(OperationTypeNames.Mutation)]
+public partial class RocketMutation
+{
+ public partial Task Save2Rocket([Service] IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal cp, CancellationToken cancellationToken);
}",
}
);
diff --git a/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs b/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs
index 0dafe2a73..1c95624fc 100644
--- a/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs
+++ b/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs
@@ -183,16 +183,14 @@ public async Task Should_Support_Nullable_Struct_Property()
var source = @"
namespace Sample.Core.Operations.Rockets
{
- public record Request : IRequest
+ public record Request(Guid Id) : IRequest
{
- public Guid Id { get; init; }
- public string SerialNumber { get; set; } = null!;
- public int Type { get; set; }
- public Instant? PlannedDate { get; set; }
+ public string SerialNumber { get; init; }
+ public int Type { get; init; }
+ public Instant? PlannedDate { get; init; }
}
- public partial record PatchRocket : IOptionalTracking, IRequest
+ public partial record PatchRocket(Guid Id) : IOptionalTracking, IRequest
{
- public Guid Id { get; init; }
}
}
";
diff --git a/test/Analyzers.Tests/ModuleInitializer.cs b/test/Analyzers.Tests/ModuleInitializer.cs
index 7a8097714..6e5d34b58 100644
--- a/test/Analyzers.Tests/ModuleInitializer.cs
+++ b/test/Analyzers.Tests/ModuleInitializer.cs
@@ -69,7 +69,8 @@ private static Target Selector(SyntaxTree source)
.FilePath
.Replace("\\", "/", StringComparison.OrdinalIgnoreCase)
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
- .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
+ .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Replace(".roslyn4.6", string.Empty, StringComparison.OrdinalIgnoreCase);
var data = $@"//HintName: {hintPath}
{source.GetText()}";
return new("cs", data.Replace("\r", string.Empty, StringComparison.OrdinalIgnoreCase));
@@ -112,9 +113,9 @@ private static ConversionResult Convert(GeneratorDriverRunResult target, IReadOn
if (target.Diagnostics.Any())
{
var info = new
- {
- target.Diagnostics,
- };
+ {
+ target.Diagnostics,
+ };
return new(info, targets);
}
@@ -126,7 +127,8 @@ private static Target SourceToTarget(GeneratedSourceResult source)
var hintName = source
.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
- .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase);
+ .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Replace(".roslyn4.6", string.Empty, StringComparison.OrdinalIgnoreCase);
var data = $@"//HintName: {hintName}
{source.SourceText}";
return new("cs", data, Path.GetFileNameWithoutExtension(hintName));
@@ -188,7 +190,8 @@ public override void Write(VerifyJsonWriter writer, GeneratedSourceResult value)
value
.HintName
.Replace(".roslyn4.0", string.Empty, StringComparison.OrdinalIgnoreCase)
- .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase),
+ .Replace(".roslyn4.4", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Replace(".roslyn4.6", string.Empty, StringComparison.OrdinalIgnoreCase),
"HintName"
);
writer.WriteMember(value, value.SourceText, "Source");
diff --git a/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs b/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs
index bfb8da71e..378dd1ba3 100644
--- a/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs
+++ b/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs
@@ -175,10 +175,7 @@ public record Request : IRequest
public string SerialNumber { get; set; } = null!;
public int Type { get; set; }
}
- public partial class PatchRocket : IPropertyTracking, IRequest
- {
- public Guid Id { get; init; }
- }
+ public partial class PatchRocket(Guid Id) : IPropertyTracking, IRequest;
}
";
var result = await GenerateAsync(source);
@@ -229,10 +226,7 @@ public record Request : IRequest
public string? SerialNumber { get; set; } = null!;
public int Type { get; set; }
}
- public partial record PatchRocket : IPropertyTracking, IRequest
- {
- public Guid Id { get; init; }
- }
+ public partial record PatchRocket(Guid Id) : IPropertyTracking, IRequest;
}
";
var result = await GenerateAsync(source);
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=#01.verified.cs
index 84462e8b0..686ee76a9 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=#01.verified.cs
@@ -18,9 +18,11 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task> GetRocket(Guid id, [Bind()] GetRocket.Request request)
{
- var result = await Mediator.Send(request with {Id = id}, HttpContext.RequestAborted).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { Id = id }, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
[ProducesDefaultResponseType]
@@ -30,12 +32,7 @@ public partial async Task> GetRocket(Guid id, [Bind()]
public partial async Task> CreateRocket([BindRequired][FromBody] CreateRocket.Request request)
{
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
- return new AcceptedAtActionResult("GetRocket", null, new
- {
- id = result.Id
- }
-
- , result);
+ return new AcceptedAtActionResult("GetRocket", null, new { id = result.Id }, result);
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=#01.verified.cs
index 2c3269cb6..2e823f4fe 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=#01.verified.cs
@@ -21,7 +21,9 @@ public partial async Task> GetRocket(Guid id, [Bind()]
request.Id = id;
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
[ProducesDefaultResponseType]
@@ -32,12 +34,7 @@ public partial async Task> GetRocket(Guid id, [Bind()]
public partial async Task> CreateRocket([BindRequired][FromBody] CreateRocket.Request request)
{
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
- return new CreatedAtActionResult("GetRocket", null, new
- {
- id = result.Id
- }
-
- , result);
+ return new CreatedAtActionResult("GetRocket", null, new { id = result.Id }, result);
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=#01.verified.cs
index 0108e620f..a1129f48a 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=#01.verified.cs
@@ -18,9 +18,11 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task> GetRocketLaunchRecord(Guid id, Guid launchId, [Bind()][BindRequired][FromRoute] GetRocketLaunchRecord.Request request)
{
- var result = await Mediator.Send(request with {Id = id, LaunchId = launchId}, HttpContext.RequestAborted).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { Id = id, LaunchId = launchId }, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=#01.verified.cs
index 3f483ee07..684a4a36f 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=#01.verified.cs
@@ -18,9 +18,11 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task> GetRocketLaunchRecord(Guid id, Guid launchRecordId, [Bind()][BindRequired][FromRoute] GetRocketLaunchRecord.Request request)
{
- var result = await Mediator.Send(request with {Id = id, LaunchRecordId = launchRecordId}, HttpContext.RequestAborted).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { Id = id, LaunchRecordId = launchRecordId }, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=#01.verified.cs
index 775f2c94c..f51ebda52 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=#01.verified.cs
@@ -18,9 +18,11 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task> GetRocketLaunchRecord(Guid id, string launchRecordId, [Bind()][BindRequired][FromRoute] GetRocketLaunchRecord.Request request)
{
- var result = await Mediator.Send(request with {Id = id, LaunchRecordId = launchRecordId}, HttpContext.RequestAborted).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { Id = id, LaunchRecordId = launchRecordId }, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=#01.verified.cs
index af7ec112c..0f4314245 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=#01.verified.cs
@@ -18,7 +18,7 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial IAsyncEnumerable GetRocketLaunchRecords(Guid id, [Bind()][BindRequired][FromRoute] GetRocketLaunchRecords.Request request)
{
- var result = Mediator.CreateStream(request with {Id = id}, HttpContext.RequestAborted);
+ var result = Mediator.CreateStream(request with { Id = id }, HttpContext.RequestAborted);
return result;
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnTypeOther_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnTypeOther_sources=#01.verified.cs
index 6ee09d868..e99e47290 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnTypeOther_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnTypeOther_sources=#01.verified.cs
@@ -18,7 +18,7 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task DeleteLaunchRecord(Guid id, [Bind()][BindRequired][FromRoute] DeleteLaunchRecord.Request request)
{
- await Mediator.Send(request with {Id = id}, HttpContext.RequestAborted).ConfigureAwait(false);
+ await Mediator.Send(request with { Id = id }, HttpContext.RequestAborted).ConfigureAwait(false);
return new StatusCodeResult(204);
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnType_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnType_sources=#01.verified.cs
index 07dd534d0..022c86062 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnType_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithVoidReturnType_sources=#01.verified.cs
@@ -18,7 +18,7 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task DeleteRocket(Guid id, [Bind()] DeleteRocket.Request request)
{
- await Mediator.Send(request with {Id = id}, HttpContext.RequestAborted).ConfigureAwait(false);
+ await Mediator.Send(request with { Id = id }, HttpContext.RequestAborted).ConfigureAwait(false);
return new StatusCodeResult(204);
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=#01.verified.cs
index 1f48c0e7b..eae982b9e 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=#01.verified.cs
@@ -20,7 +20,9 @@ public partial async Task> GetRocket(GetRocket.Request
{
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=#01.verified.cs
index 96beebcb1..7885c81f6 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=#01.verified.cs
@@ -23,7 +23,9 @@ public partial async Task> Save2Rocket(Guid id, string
request.ClaimsPrincipal = this.User;
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithHttpRequest_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithHttpRequest_sources=#01.verified.cs
index f8e65fa8a..50fd1a5ec 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithHttpRequest_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithHttpRequest_sources=#01.verified.cs
@@ -18,9 +18,11 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task> Save2Rocket(Guid id, string? sn, [Bind("Other")] Save2Rocket.Request request)
{
- var result = await Mediator.Send(request with {Id = id, Sn = sn, R = this.Request}, HttpContext.RequestAborted).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { Id = id, Sn = sn, R = this.Request }, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=#01.verified.cs
index a49d1e04c..9a75cdb81 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=#01.verified.cs
@@ -18,7 +18,7 @@ public partial class RocketController
[ProducesResponseType(typeof(FluentValidationProblemDetails), 422)]
public partial async Task SaveRocket(Guid id, [Bind()][BindRequired][FromBody] SaveRocket.Request request)
{
- await Mediator.Send(request with {Id = id}, HttpContext.RequestAborted).ConfigureAwait(false);
+ await Mediator.Send(request with { Id = id }, HttpContext.RequestAborted).ConfigureAwait(false);
return new StatusCodeResult(204);
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterMultiple_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterMultiple_sources=#01.verified.cs
index f47a5aadb..847ebfbb9 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterMultiple_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterMultiple_sources=#01.verified.cs
@@ -22,7 +22,9 @@ public partial async Task> Save2Rocket(Guid id, string
request.Sn = sn;
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=#01.verified.cs b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=#01.verified.cs
index 775f33602..d80d8b471 100644
--- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=#01.verified.cs
+++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=#01.verified.cs
@@ -21,7 +21,9 @@ public partial async Task> Save2Rocket(Guid id, [Bind(
request.Id = id;
var result = await Mediator.Send(request, HttpContext.RequestAborted).ConfigureAwait(false);
return new ObjectResult(result)
- {StatusCode = 200};
+ {
+ StatusCode = 200
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.verified.cs
index 40774574b..684dbc87c 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.verified.cs
@@ -11,7 +11,7 @@ public partial class RocketMutation
/// Get the launch records for a given rocket
///
///
- public partial IAsyncEnumerable GetRocketLaunchRecords(IMediator mediator, GetRocketLaunchRecords.Request request)
+ public partial IAsyncEnumerable GetRocketLaunchRecords([HotChocolate.ServiceAttribute] IMediator mediator, GetRocketLaunchRecords.Request request)
{
var result = Mediator.CreateStream(request);
return result;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.cs
new file mode 100644
index 000000000..f094db695
--- /dev/null
+++ b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.cs
@@ -0,0 +1,18 @@
+//HintName: Rocket.Surgery.LaunchPad.Analyzers/Rocket.Surgery.LaunchPad.Analyzers.GraphqlMutationActionBodyGenerator/RocketMutation_Methods.cs
+#nullable enable
+using TestNamespace;
+using System.Threading;
+using MediatR;
+
+namespace MyNamespace.Controllers
+{
+ public partial class RocketMutation
+ {
+ public partial async Task Save2Rocket(IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal cp, CancellationToken cancellationToken)
+ {
+ var result = await Mediator.Send(request with { ClaimsPrincipal = cp }, cancellationToken).ConfigureAwait(false);
+ return result;
+ }
+ }
+}
+#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.txt b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.txt
new file mode 100644
index 000000000..e2ed71440
--- /dev/null
+++ b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithCancellationTokenAndClaimsPrincipal_sources=.verified.txt
@@ -0,0 +1,4 @@
+{
+ ResultDiagnostics: null,
+ Results: {}
+}
\ No newline at end of file
diff --git a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=.verified.cs
index 5b7995f49..ca0ec9e76 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlMutationActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithClaimsPrincipal_sources=.verified.cs
@@ -8,10 +8,9 @@ namespace MyNamespace.Controllers
{
public partial class RocketMutation
{
- public partial async Task Save2Rocket(IMediator mediator, Save2Rocket.Request request, ClaimsPrincipal claimsPrincipal)
+ public partial async Task Save2Rocket(IMediator mediator, ClaimsPrincipal claimsPrincipal, Save2Rocket.Request request)
{
- request.ClaimsPrincipal = claimsPrincipal;
- var result = await Mediator.Send(request).ConfigureAwait(false);
+ var result = await Mediator.Send(request with { ClaimsPrincipal = claimsPrincipal }).ConfigureAwait(false);
return result;
}
}
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
index 90fba1ffe..624d95897 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
@@ -7,14 +7,15 @@
public partial class PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.PatchRocket Create()
{
- var value = new global::Sample.Core.Operations.Rockets.PatchRocket{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.PatchRocket()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
value.SerialNumber = SerialNumber.Value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
index 90fba1ffe..624d95897 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
@@ -7,14 +7,15 @@
public partial class PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.PatchRocket Create()
{
- var value = new global::Sample.Core.Operations.Rockets.PatchRocket{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.PatchRocket()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
value.SerialNumber = SerialNumber.Value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
index d429026d5..175c319d3 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
@@ -7,14 +7,15 @@
public partial class PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Request Create()
{
- var value = new global::Request{Id = Id};
+ var value = new global::Request()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
value.SerialNumber = SerialNumber.Value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
index d429026d5..175c319d3 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
@@ -7,14 +7,15 @@
public partial class PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Request Create()
{
- var value = new global::Request{Id = Id};
+ var value = new global::Request()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
value.SerialNumber = SerialNumber.Value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
index 4ffdd7128..0433d6646 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
@@ -7,27 +7,37 @@
public partial record PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.PatchRocket Create()
{
- var value = new global::Sample.Core.Operations.Rockets.PatchRocket{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.PatchRocket()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value};
+ value = value with
+ {
+ Type = Type.Value
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
index 4ffdd7128..0433d6646 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.verified.cs
@@ -7,27 +7,37 @@
public partial record PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.PatchRocket Create()
{
- var value = new global::Sample.Core.Operations.Rockets.PatchRocket{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.PatchRocket()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value};
+ value = value with
+ {
+ Type = Type.Value
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
index 569669d1d..277bf6b49 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.verified.cs
@@ -7,34 +7,45 @@
public partial record PatchGraphRocket
{
public HotChocolate.Optional Id { get; set; }
-
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Request Create()
{
- var value = new global::Request{};
+ var value = new global::Request()
+ {
+ };
if (Id.HasValue)
{
- value = value with {Id = Id.Value ?? default};
+ value = value with
+ {
+ Id = Id.Value ?? default
+ };
}
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value ?? default};
+ value = value with
+ {
+ Type = Type.Value ?? default
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value ?? default};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value ?? default
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
index 569669d1d..277bf6b49 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.verified.cs
@@ -7,34 +7,45 @@
public partial record PatchGraphRocket
{
public HotChocolate.Optional Id { get; set; }
-
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Request Create()
{
- var value = new global::Request{};
+ var value = new global::Request()
+ {
+ };
if (Id.HasValue)
{
- value = value with {Id = Id.Value ?? default};
+ value = value with
+ {
+ Id = Id.Value ?? default
+ };
}
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value ?? default};
+ value = value with
+ {
+ Type = Type.Value ?? default
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value ?? default};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value ?? default
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
index 72d5a5289..613d5d0a8 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
@@ -11,27 +11,37 @@ public static class PublicClass
public partial record PatchGraphRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.Request Create()
{
- var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.Request()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value ?? default};
+ value = value with
+ {
+ Type = Type.Value ?? default
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value ?? default};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value ?? default
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.verified.cs
index 5f5d378a0..d91a665b5 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.verified.cs
@@ -9,27 +9,37 @@ namespace Sample.Core.Operations.Rockets
public partial record PatchRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.Request Create()
{
- var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.Request()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value};
+ value = value with
+ {
+ Type = Type.Value
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value ?? default};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value ?? default
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
index 2ca95bf7e..37cc7ec01 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
@@ -9,27 +9,37 @@ namespace Sample.Core.Operations.Rockets
public partial record PatchRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.Request Create()
{
- var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.Request()
+ {
+ Id = Id
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value ?? default};
+ value = value with
+ {
+ Type = Type.Value ?? default
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value ?? default};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value ?? default
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.verified.cs
index 10d6d0b56..f4f6e683c 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.verified.cs
@@ -10,34 +10,45 @@ namespace Sample.Core.Operations.Rockets
public partial record PatchRocketUnderTest
{
public HotChocolate.Optional Id { get; set; }
-
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.Request Create()
{
- var value = new global::Sample.Core.Operations.Rockets.Request{};
+ var value = new global::Sample.Core.Operations.Rockets.Request()
+ {
+ };
if (Id.HasValue)
{
- value = value with {Id = Id.Value};
+ value = value with
+ {
+ Id = Id.Value
+ };
}
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value};
+ value = value with
+ {
+ Type = Type.Value
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
index d7b1c0a08..0aefd3408 100644
--- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
@@ -9,27 +9,36 @@ namespace Sample.Core.Operations.Rockets
public partial record PatchRocket
{
public HotChocolate.Optional SerialNumber { get; set; }
-
public HotChocolate.Optional Type { get; set; }
-
public HotChocolate.Optional PlannedDate { get; set; }
public global::Sample.Core.Operations.Rockets.Request Create()
{
- var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id};
+ var value = new global::Sample.Core.Operations.Rockets.Request(Id)
+ {
+ };
if (SerialNumber.HasValue)
{
- value = value with {SerialNumber = SerialNumber.Value};
+ value = value with
+ {
+ SerialNumber = SerialNumber.Value
+ };
}
if (Type.HasValue)
{
- value = value with {Type = Type.Value ?? default};
+ value = value with
+ {
+ Type = Type.Value ?? default
+ };
}
if (PlannedDate.HasValue)
{
- value = value with {PlannedDate = PlannedDate.Value};
+ value = value with
+ {
+ PlannedDate = PlannedDate.Value
+ };
}
return value;
diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.verified.cs b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.verified.cs
index e1a189096..3822f48a3 100644
--- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.verified.cs
+++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.verified.cs
@@ -13,7 +13,11 @@ public partial class Request
{
public string SerialNumber { get; set; }
- public Request With(Model value) => new Request{Id = this.Id, SerialNumber = value.SerialNumber};
+ public Request With(Model value) => new Request
+ {
+ Id = this.Id,
+ SerialNumber = value.SerialNumber
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.verified.cs b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.verified.cs
index bf133369b..04db24558 100644
--- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.verified.cs
+++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.verified.cs
@@ -13,7 +13,10 @@ public partial record Request
{
public string SerialNumber { get; set; }
- public Request With(Model value) => this with {SerialNumber = value.SerialNumber};
+ public Request With(Model value) => this with
+ {
+ SerialNumber = value.SerialNumber
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.verified.cs b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.verified.cs
index d2d8048f5..70ac57b0f 100644
--- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.verified.cs
+++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.verified.cs
@@ -11,7 +11,10 @@ public static partial class CreateRocket
[System.Runtime.CompilerServices.CompilerGenerated]
public partial record Request
{
- public Request With(Model value) => this with {SerialNumber = value.SerialNumber};
+ public Request With(Model value) => this with
+ {
+ SerialNumber = value.SerialNumber
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.verified.cs b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.verified.cs
index 02e19a155..0717b3810 100644
--- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.verified.cs
+++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.verified.cs
@@ -13,10 +13,16 @@ public partial record Request
{
public string SerialNumber { get; set; }
- public Request With(Model value) => this with {SerialNumber = value.SerialNumber};
+ public Request With(Model value) => this with
+ {
+ SerialNumber = value.SerialNumber
+ };
public string OtherNumber { get; set; }
- public Request With(Other value) => this with {OtherNumber = value.OtherNumber};
+ public Request With(Other value) => this with
+ {
+ OtherNumber = value.OtherNumber
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
index 39d16e61e..97c5e36b7 100644
--- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
+++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
@@ -13,7 +13,10 @@ public partial record Request
{
public string SerialNumber { get; set; }
- public Request With(Model value) => this with {SerialNumber = value.SerialNumber};
+ public Request With(Model value) => this with
+ {
+ SerialNumber = value.SerialNumber
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs
index 88b2c34c0..e0c86c833 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.verified.cs
@@ -7,18 +7,21 @@ 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
@@ -48,5 +51,11 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs
index 88b2c34c0..e0c86c833 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.verified.cs
@@ -7,18 +7,21 @@ 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
@@ -48,5 +51,11 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs
index 88b2c34c0..e0c86c833 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.verified.cs
@@ -7,18 +7,21 @@ 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
@@ -48,5 +51,11 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs
index 7d4eaa6e5..0a674714f 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber.verified.cs
@@ -8,37 +8,49 @@ 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; }
-
public bool SerialNumber { get; init; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ Id = Id.HasBeenSet(),
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
{
if (Id.HasBeenSet())
{
- state = state with {Id = Id!};
+ state = state with
+ {
+ Id = Id!
+ };
}
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -57,5 +69,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ Id = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Id),
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs
index 7d4eaa6e5..0a674714f 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type.verified.cs
@@ -8,37 +8,49 @@ 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; }
-
public bool SerialNumber { get; init; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ Id = Id.HasBeenSet(),
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
{
if (Id.HasBeenSet())
{
- state = state with {Id = Id!};
+ state = state with
+ {
+ Id = Id!
+ };
}
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -57,5 +69,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ Id = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Id),
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs
index 7d4eaa6e5..0a674714f 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.verified.cs
@@ -8,37 +8,49 @@ 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; }
-
public bool SerialNumber { get; init; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {Id = Id.HasBeenSet(), SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ Id = Id.HasBeenSet(),
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Request ApplyChanges(global::Request state)
{
if (Id.HasBeenSet())
{
- state = state with {Id = Id!};
+ state = state with
+ {
+ Id = Id!
+ };
}
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -57,5 +69,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::PatchRocket Create(global::Request value) => new global::PatchRocket()
+ {
+ Id = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Id),
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
index 6275400e4..73bd86c32 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.verified.cs
@@ -11,30 +11,39 @@ public partial record 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state)
{
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -52,6 +61,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::Sample.Core.Operations.Rockets.PublicClass.PatchRocket Create(global::Sample.Core.Operations.Rockets.Request value) => new global::Sample.Core.Operations.Rockets.PublicClass.PatchRocket()
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
}
}
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
index 0cca3f54c..9d7577c6b 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.verified.cs
@@ -9,30 +9,39 @@ public partial record 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state)
{
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -50,6 +59,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::Sample.Core.Operations.Rockets.PatchRocket Create(global::Sample.Core.Operations.Rockets.Request value) => new global::Sample.Core.Operations.Rockets.PatchRocket(value.Id)
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
}
#nullable restore
diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
index 9d7fe5cd6..9bf4b40b0 100644
--- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
+++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.verified.cs
@@ -9,30 +9,39 @@ public partial record 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; }
-
public bool Type { get; init; }
}
public Changes GetChangedState()
{
return new Changes()
- {SerialNumber = SerialNumber.HasBeenSet(), Type = Type.HasBeenSet()};
+ {
+ SerialNumber = SerialNumber.HasBeenSet(),
+ Type = Type.HasBeenSet()
+ };
}
public global::Sample.Core.Operations.Rockets.Request ApplyChanges(global::Sample.Core.Operations.Rockets.Request state)
{
if (SerialNumber.HasBeenSet())
{
- state = state with {SerialNumber = SerialNumber!};
+ state = state with
+ {
+ SerialNumber = SerialNumber!
+ };
}
if (Type.HasBeenSet())
{
- state = state with {Type = Type!};
+ state = state with
+ {
+ Type = Type!
+ };
}
ResetChanges();
@@ -50,6 +59,12 @@ public PatchRocket ResetChanges()
{
ResetChanges();
}
+
+ public static global::Sample.Core.Operations.Rockets.PatchRocket Create(global::Sample.Core.Operations.Rockets.Request value) => new global::Sample.Core.Operations.Rockets.PatchRocket()
+ {
+ SerialNumber = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.SerialNumber),
+ Type = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(value.Type)
+ };
}
}
#nullable restore
diff --git a/test/Extensions.Tests/ChangeTrackingTests.cs b/test/Extensions.Tests/ChangeTrackingTests.cs
new file mode 100644
index 000000000..06c1e54e7
--- /dev/null
+++ b/test/Extensions.Tests/ChangeTrackingTests.cs
@@ -0,0 +1,130 @@
+using Rocket.Surgery.Extensions.Testing;
+using Rocket.Surgery.LaunchPad.Foundation;
+
+namespace Extensions.Tests;
+
+public partial class ChangeTrackingTests(ITestOutputHelper testOutputHelper) : LoggerTest(testOutputHelper)
+{
+ [Fact]
+ public void ShouldTrackChanges_For_Classes()
+ {
+ var tracking = new ClassWithTracking(1);
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ tracking.Name = "Test";
+ tracking.Name.HasBeenSet().Should().BeTrue();
+ }
+
+ [Fact]
+ public void ShouldResetChanges_For_Classes()
+ {
+ var tracking = new ClassWithTracking(1)
+ {
+ Name = "Test",
+ };
+ tracking.ResetChanges();
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ }
+
+ [Fact]
+ public void ShouldApplyChanges_For_Classes()
+ {
+ var instance = new Class(1)
+ {
+ Name = "MyName",
+ };
+ var tracking = new ClassWithTracking(1)
+ {
+ Name = "Test",
+ };
+ tracking.ApplyChanges(instance);
+
+ instance.Name.Should().Be("Test");
+ }
+
+ [Fact]
+ public void ShouldCreate_For_Classes()
+ {
+ var instance = new Class(1)
+ {
+ Name = "MyName",
+ Description = "MyDescription",
+ };
+ var tracking = ClassWithTracking.Create(instance);
+ tracking.Description = "My New description";
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ tracking.Description.HasBeenSet().Should().BeTrue();
+ tracking.ApplyChanges(instance);
+
+ instance.Name.Should().Be("MyName");
+ instance.Description.Should().Be("My New description");
+ }
+
+ [Fact]
+ public void ShouldTrackChanges_For_Records()
+ {
+ var tracking = new RecordWithTracking(1);
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ tracking.Name = "Test";
+ tracking.Name.HasBeenSet().Should().BeTrue();
+ }
+
+ [Fact]
+ public void ShouldResetChanges_For_Records()
+ {
+ var tracking = new RecordWithTracking(1)
+ {
+ Name = "Test",
+ };
+ tracking.ResetChanges();
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ }
+
+ [Fact]
+ public void ShouldApplyChanges_For_Records()
+ {
+ var instance = new Record(1, "MyName");
+ var tracking = new RecordWithTracking(1)
+ {
+ Name = "Test",
+ };
+ instance = tracking.ApplyChanges(instance);
+
+ instance.Name.Should().Be("Test");
+ }
+
+ [Fact]
+ public void ShouldCreate_For_Records()
+ {
+ var instance = new Record(1, "MyName")
+ {
+ Description = "MyDescription",
+ };
+ var tracking = RecordWithTracking.Create(instance);
+ tracking.Description = "My New description";
+ tracking.Name.HasBeenSet().Should().BeFalse();
+ tracking.Description.HasBeenSet().Should().BeTrue();
+ instance = tracking.ApplyChanges(instance);
+
+ instance.Name.Should().Be("MyName");
+ instance.Description.Should().Be("My New description");
+ }
+
+ public partial class Class(int Id)
+ {
+ public int Id { get; } = Id;
+ public string? Name { get; set; }
+ public string? Description { get; set; }
+ }
+
+ public partial class ClassWithTracking(int Id) : IPropertyTracking
+ {
+ public int Id { get; } = Id;
+ }
+
+ public partial record Record(int Id, string? Name)
+ {
+ public string? Description { get; set; }
+ }
+
+ public partial record RecordWithTracking(int Id) : IPropertyTracking;
+}
\ No newline at end of file
diff --git a/test/Extensions.Tests/Extensions.Tests.csproj b/test/Extensions.Tests/Extensions.Tests.csproj
index 35adf1558..7de91eb39 100644
--- a/test/Extensions.Tests/Extensions.Tests.csproj
+++ b/test/Extensions.Tests/Extensions.Tests.csproj
@@ -17,5 +17,13 @@
+
+
+
diff --git a/test/Sample.Graphql.Tests/snapshots/FoundationTests.GraphqlSchema.verified.graphql b/test/Sample.Graphql.Tests/snapshots/FoundationTests.GraphqlSchema.verified.graphql
index 6df5b1a95..cfa3bfef1 100644
--- a/test/Sample.Graphql.Tests/snapshots/FoundationTests.GraphqlSchema.verified.graphql
+++ b/test/Sample.Graphql.Tests/snapshots/FoundationTests.GraphqlSchema.verified.graphql
@@ -1,39 +1,39 @@
schema {
- query: Query
- mutation: Mutation
+ query: Query
+ mutation: Mutation
}
interface GeoJSONInterface {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float]
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float]
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"The launch record creation response"
type CreateLaunchRecordResponse {
- "The id of the new launch record"
- id: UUID!
+ "The id of the new launch record"
+ id: UUID!
}
"The identifier of the rocket that was created"
type CreateRocketResponse {
- "The rocket id"
- id: UUID!
+ "The rocket id"
+ id: UUID!
}
"Models an OGC-style LineString"
type GeoJSONLineStringType implements GeoJSONInterface {
- "The \"coordinates\" field is an array of two or more positions."
- coordinates: [Position]
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field is an array of two or more positions."
+ coordinates: [Position]
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
"""
@@ -42,38 +42,38 @@ Models a collection of LineStrings.
Any collection of LineStrings is a valid MultiLineString.
"""
type GeoJSONMultiLineStringType implements GeoJSONInterface {
- "The \"coordinates\" field is an array of LineString coordinate arrays."
- coordinates: [Position]
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field is an array of LineString coordinate arrays."
+ coordinates: [Position]
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
"Models a collection of Points."
type GeoJSONMultiPointType implements GeoJSONInterface {
- "The \"coordinates\" field is an array of positions."
- coordinates: [Position]
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field is an array of positions."
+ coordinates: [Position]
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
"Basic implementation of MultiPolygon."
type GeoJSONMultiPolygonType implements GeoJSONInterface {
- "The \"coordinates\" field is an array of Polygon coordinate arrays."
- coordinates: Coordinates
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field is an array of Polygon coordinate arrays."
+ coordinates: Coordinates
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
"""
@@ -85,14 +85,14 @@ The coordinate which defines it if any) is a valid coordinate
(i.e. does not have an NaN X- or Y-ordinate
"""
type GeoJSONPointType implements GeoJSONInterface {
- "The \"coordinates\" field is a single position."
- coordinates: Position
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field is a single position."
+ coordinates: Position
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
"""
@@ -119,257 +119,257 @@ makes the interior of the polygon disconnected
(i.e. effectively split the polygon into two pieces).
"""
type GeoJSONPolygonType implements GeoJSONInterface {
- "The \"coordinates\" field MUST be an array of linear ring coordinate arrays. For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface."
- coordinates: [[Position]]
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType!
- "The minimum bounding box around the geometry object"
- bbox: [Float!]!
- "The coordinate reference system integer identifier"
- crs: Int!
+ "The \"coordinates\" field MUST be an array of linear ring coordinate arrays. For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface."
+ coordinates: [[Position]]
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType!
+ "The minimum bounding box around the geometry object"
+ bbox: [Float!]!
+ "The coordinate reference system integer identifier"
+ crs: Int!
}
type GeometryOutputs {
- geometry: Geometry
- point: GeoJSONPointType
- lineString: GeoJSONLineStringType
- polygon: GeoJSONPolygonType
- multiPoint: GeoJSONMultiPointType
- multiLineString: GeoJSONMultiLineStringType
- multiPolygon: GeoJSONMultiPolygonType
+ geometry: Geometry
+ point: GeoJSONPointType
+ lineString: GeoJSONLineStringType
+ polygon: GeoJSONPolygonType
+ multiPoint: GeoJSONMultiPointType
+ multiLineString: GeoJSONMultiLineStringType
+ multiPolygon: GeoJSONMultiPolygonType
}
type LaunchRecord {
- rocket: ReadyRocket!
- id: UUID!
- partner: String
- payload: String
- payloadWeightKg: Long!
- actualLaunchDate: DateTime
- scheduledLaunchDate: DateTime!
+ rocket: ReadyRocket!
+ id: UUID!
+ partner: String
+ payload: String
+ payloadWeightKg: Long!
+ actualLaunchDate: DateTime
+ scheduledLaunchDate: DateTime!
}
"The launch record details"
type LaunchRecordModel {
- "The launch record id"
- id: UUID!
- "The launch partner"
- partner: String!
- "The payload details"
- payload: String!
- "The payload weight in Kg"
- payloadWeightKg: Long!
- "The actual launch date"
- actualLaunchDate: Instant
- "The intended date for the launch"
- scheduledLaunchDate: Instant!
- "The serial number of the reusable rocket"
- rocketSerialNumber: String!
- "The kind of rocket that will be launching"
- rocketType: RocketType!
+ "The launch record id"
+ id: UUID!
+ "The launch partner"
+ partner: String!
+ "The payload details"
+ payload: String!
+ "The payload weight in Kg"
+ payloadWeightKg: Long!
+ "The actual launch date"
+ actualLaunchDate: Instant
+ "The intended date for the launch"
+ scheduledLaunchDate: Instant!
+ "The serial number of the reusable rocket"
+ rocketSerialNumber: String!
+ "The kind of rocket that will be launching"
+ rocketType: RocketType!
}
"A connection to a list of items."
type LaunchRecordsConnection {
- "Information to aid in pagination."
- pageInfo: PageInfo!
- "A list of edges."
- edges: [LaunchRecordsEdge!]
- "A flattened list of the nodes."
- nodes: [LaunchRecord!]
+ "Information to aid in pagination."
+ pageInfo: PageInfo!
+ "A list of edges."
+ edges: [LaunchRecordsEdge!]
+ "A flattened list of the nodes."
+ nodes: [LaunchRecord!]
}
"An edge in a connection."
type LaunchRecordsEdge {
- "A cursor for use in pagination."
- cursor: String!
- "The item at the end of the edge."
- node: LaunchRecord!
+ "A cursor for use in pagination."
+ cursor: String!
+ "The item at the end of the edge."
+ node: LaunchRecord!
}
type Mutation {
- createRocket(request: CreateRocketRequest!): CreateRocketResponse!
- editRocket(request: EditRocketRequest!): RocketModel!
- patchRocket(request: EditRocketPatchRequestInput!): RocketModel!
- deleteRocket(request: DeleteRocketRequest!): Void!
- createLaunchRecord(request: CreateLaunchRecordRequest!): CreateLaunchRecordResponse!
- editLaunchRecord(request: EditLaunchRecordRequest!): LaunchRecordModel!
- patchLaunchRecord(request: EditLaunchRecordPatchRequestInput!): LaunchRecordModel!
- deleteLaunchRecord(request: DeleteLaunchRecordRequest!): Void!
+ createRocket(request: CreateRocketRequest!): CreateRocketResponse!
+ editRocket(request: EditRocketRequest!): RocketModel!
+ patchRocket(request: EditRocketPatchRequestInput!): RocketModel!
+ deleteRocket(request: DeleteRocketRequest!): Void!
+ createLaunchRecord(request: CreateLaunchRecordRequest!): CreateLaunchRecordResponse!
+ editLaunchRecord(request: EditLaunchRecordRequest!): LaunchRecordModel!
+ patchLaunchRecord(request: EditLaunchRecordPatchRequestInput!): LaunchRecordModel!
+ deleteLaunchRecord(request: DeleteLaunchRecordRequest!): Void!
}
type NodaTimeOutputs {
- instant: Instant
- localDate: LocalDate
- localTime: LocalTime
- localDateTime: LocalDateTime
- offsetDateTime: OffsetDateTime
- offsetTime: OffsetTime
- period: Period
- duration: Duration
- zonedDateTime: ZonedDateTime
- offset: Offset
- isoDayOfWeek: IsoDayOfWeek
+ instant: Instant
+ localDate: LocalDate
+ localTime: LocalTime
+ localDateTime: LocalDateTime
+ offsetDateTime: OffsetDateTime
+ offsetTime: OffsetTime
+ period: Period
+ duration: Duration
+ zonedDateTime: ZonedDateTime
+ offset: Offset
+ isoDayOfWeek: IsoDayOfWeek
}
"Information about pagination in a connection."
type PageInfo {
- "Indicates whether more edges exist following the set defined by the clients arguments."
- hasNextPage: Boolean!
- "Indicates whether more edges exist prior the set defined by the clients arguments."
- hasPreviousPage: Boolean!
- "When paginating backwards, the cursor to continue."
- startCursor: String
- "When paginating forwards, the cursor to continue."
- endCursor: String
+ "Indicates whether more edges exist following the set defined by the clients arguments."
+ hasNextPage: Boolean!
+ "Indicates whether more edges exist prior the set defined by the clients arguments."
+ hasPreviousPage: Boolean!
+ "When paginating backwards, the cursor to continue."
+ startCursor: String
+ "When paginating forwards, the cursor to continue."
+ endCursor: String
}
type Query {
- launchRecords("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String where: LaunchRecordFilterInput order: [LaunchRecordSortInput!]): LaunchRecordsConnection
- rockets("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String where: ReadyRocketFilterInput order: [ReadyRocketSortInput!]): RocketsConnection
- nodaTimeTest(inputs: NodaTimeInputsInput!): NodaTimeOutputs!
- geometryTest(inputs: GeometryInputsInput!): GeometryOutputs!
+ launchRecords("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String where: LaunchRecordFilterInput order: [LaunchRecordSortInput!]): LaunchRecordsConnection
+ rockets("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String where: ReadyRocketFilterInput order: [ReadyRocketSortInput!]): RocketsConnection
+ nodaTimeTest(inputs: NodaTimeInputsInput!): NodaTimeOutputs!
+ geometryTest(inputs: GeometryInputsInput!): GeometryOutputs!
}
"A rocket in inventory"
type ReadyRocket {
- launchRecords: [LaunchRecord!]!
- id: UUID!
- serialNumber: String!
- type: RocketType!
+ launchRecords: [LaunchRecord!]!
+ id: UUID!
+ serialNumber: String!
+ type: RocketType!
}
"The details of a given rocket"
type RocketModel {
- "The unique rocket identifier"
- id: UUID!
- "The serial number of the rocket"
- sn: String!
- "The type of the rocket"
- type: RocketType!
+ "The unique rocket identifier"
+ id: UUID!
+ "The serial number of the rocket"
+ sn: String!
+ "The type of the rocket"
+ type: RocketType!
}
"A connection to a list of items."
type RocketsConnection {
- "Information to aid in pagination."
- pageInfo: PageInfo!
- "A list of edges."
- edges: [RocketsEdge!]
- "A flattened list of the nodes."
- nodes: [ReadyRocket!]
+ "Information to aid in pagination."
+ pageInfo: PageInfo!
+ "A list of edges."
+ edges: [RocketsEdge!]
+ "A flattened list of the nodes."
+ nodes: [ReadyRocket!]
}
"An edge in a connection."
type RocketsEdge {
- "A cursor for use in pagination."
- cursor: String!
- "The item at the end of the edge."
- node: ReadyRocket!
+ "A cursor for use in pagination."
+ cursor: String!
+ "The item at the end of the edge."
+ node: ReadyRocket!
}
"Create a launch record"
input CreateLaunchRecordRequest {
- "The rocket to use"
- rocketId: UUID!
- "The launch partner"
- partner: String
- "The launch partners payload"
- payload: String
- "The payload weight"
- payloadWeightKg: Float!
- "The actual launch date"
- actualLaunchDate: Instant
- "The intended launch date"
- scheduledLaunchDate: Instant!
+ "The rocket to use"
+ rocketId: UUID!
+ "The launch partner"
+ partner: String
+ "The launch partners payload"
+ payload: String
+ "The payload weight"
+ payloadWeightKg: Float!
+ "The actual launch date"
+ actualLaunchDate: Instant
+ "The intended launch date"
+ scheduledLaunchDate: Instant!
}
"The operation to create a new rocket record"
input CreateRocketRequest {
- "The serial number of the rocket"
- serialNumber: String!
- "The type of rocket"
- type: RocketType!
+ "The serial number of the rocket"
+ serialNumber: String!
+ "The type of rocket"
+ type: RocketType!
}
input DateTimeOperationFilterInput {
- eq: DateTime
- neq: DateTime
- in: [DateTime]
- nin: [DateTime]
- gt: DateTime
- ngt: DateTime
- gte: DateTime
- ngte: DateTime
- lt: DateTime
- nlt: DateTime
- lte: DateTime
- nlte: DateTime
+ eq: DateTime
+ neq: DateTime
+ in: [DateTime]
+ nin: [DateTime]
+ gt: DateTime
+ ngt: DateTime
+ gte: DateTime
+ ngte: DateTime
+ lt: DateTime
+ nlt: DateTime
+ lte: DateTime
+ nlte: DateTime
}
"The request to delete a launch record"
input DeleteLaunchRecordRequest {
- "The launch record to delete"
- id: UUID!
+ "The launch record to delete"
+ id: UUID!
}
"The request to remove a rocket from the system"
input DeleteRocketRequest {
- "The rocket id"
- id: UUID!
+ "The rocket id"
+ id: UUID!
}
input EditLaunchRecordPatchRequestInput {
- id: UUID!
- partner: String
- payload: String
- payloadWeightKg: Float
- actualLaunchDate: Instant
- scheduledLaunchDate: Instant
- rocketId: UUID
+ id: UUID!
+ partner: String
+ payload: String
+ payloadWeightKg: Float
+ actualLaunchDate: Instant
+ scheduledLaunchDate: Instant
+ rocketId: UUID
}
"The launch record update request"
input EditLaunchRecordRequest {
- "The launch record to update"
- id: UUID!
- "The updated launch partner"
- partner: String!
- "The updated launch payload"
- payload: String!
- "The updated payload weight"
- payloadWeightKg: Float!
- "The updated actual launch date"
- actualLaunchDate: Instant
- "The scheduled launch date"
- scheduledLaunchDate: Instant!
- "The update rocket id"
- rocketId: UUID!
+ "The launch record to update"
+ id: UUID!
+ "The updated launch partner"
+ partner: String!
+ "The updated launch payload"
+ payload: String!
+ "The updated payload weight"
+ payloadWeightKg: Float!
+ "The updated actual launch date"
+ actualLaunchDate: Instant
+ "The scheduled launch date"
+ scheduledLaunchDate: Instant!
+ "The update rocket id"
+ rocketId: UUID!
}
input EditRocketPatchRequestInput {
- id: UUID!
- serialNumber: String
- type: RocketType
+ id: UUID!
+ serialNumber: String
+ type: RocketType
}
"The edit operation to update a rocket"
input EditRocketRequest {
- "The rocket id"
- id: UUID!
- "The serial number of the rocket"
- serialNumber: String!
- "The type of the rocket"
- type: RocketType!
+ "The rocket id"
+ id: UUID!
+ "The serial number of the rocket"
+ serialNumber: String!
+ "The type of the rocket"
+ type: RocketType!
}
"Models an OGC-style LineString"
input GeoJSONLineStringInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field is an array of two or more positions."
- coordinates: [Position]
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field is an array of two or more positions."
+ coordinates: [Position]
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"""
@@ -378,32 +378,32 @@ Models a collection of LineStrings.
Any collection of LineStrings is a valid MultiLineString.
"""
input GeoJSONMultiLineStringInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field is an array of LineString coordinate arrays."
- coordinates: [[Position]]
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field is an array of LineString coordinate arrays."
+ coordinates: [[Position]]
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"Models a collection of Points."
input GeoJSONMultiPointInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field is an array of positions."
- coordinates: [Position]
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field is an array of positions."
+ coordinates: [Position]
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"Basic implementation of MultiPolygon."
input GeoJSONMultiPolygonInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field is an array of Polygon coordinate arrays."
- coordinates: Coordinates
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field is an array of Polygon coordinate arrays."
+ coordinates: Coordinates
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"""
@@ -415,12 +415,12 @@ The coordinate which defines it if any) is a valid coordinate
(i.e. does not have an NaN X- or Y-ordinate
"""
input GeoJSONPointInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field is a single position."
- coordinates: Position
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field is a single position."
+ coordinates: Position
+ "The coordinate reference system integer identifier"
+ crs: Int
}
"""
@@ -447,150 +447,150 @@ makes the interior of the polygon disconnected
(i.e. effectively split the polygon into two pieces).
"""
input GeoJSONPolygonInput {
- "The geometry type of the GeoJson object"
- type: GeoJSONGeometryType
- "The \"coordinates\" field MUST be an array of linear ring coordinate arrays. For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface."
- coordinates: [[Position]]
- "The coordinate reference system integer identifier"
- crs: Int
+ "The geometry type of the GeoJson object"
+ type: GeoJSONGeometryType
+ "The \"coordinates\" field MUST be an array of linear ring coordinate arrays. For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface."
+ coordinates: [[Position]]
+ "The coordinate reference system integer identifier"
+ crs: Int
}
input GeometryInputsInput {
- geometry: Geometry
+ geometry: Geometry
}
input LaunchRecordFilterInput {
- and: [LaunchRecordFilterInput!]
- or: [LaunchRecordFilterInput!]
- id: StronglyTypedIdFilterOfUuidTypeFilterInput
- partner: StringOperationFilterInput
- payload: StringOperationFilterInput
- payloadWeightKg: LongOperationFilterInput
- actualLaunchDate: DateTimeOperationFilterInput
- scheduledLaunchDate: DateTimeOperationFilterInput
- rocketId: StronglyTypedIdFilterOfUuidTypeFilterInput
- rocket: ReadyRocketFilterInput
+ and: [LaunchRecordFilterInput!]
+ or: [LaunchRecordFilterInput!]
+ id: StronglyTypedIdFilterOfUuidTypeFilterInput
+ partner: StringOperationFilterInput
+ payload: StringOperationFilterInput
+ payloadWeightKg: LongOperationFilterInput
+ actualLaunchDate: DateTimeOperationFilterInput
+ scheduledLaunchDate: DateTimeOperationFilterInput
+ rocketId: StronglyTypedIdFilterOfUuidTypeFilterInput
+ rocket: ReadyRocketFilterInput
}
input LaunchRecordSortInput {
- partner: SortEnumType
- payload: SortEnumType
- payloadWeightKg: SortEnumType
- actualLaunchDate: SortEnumType
- scheduledLaunchDate: SortEnumType
+ partner: SortEnumType
+ payload: SortEnumType
+ payloadWeightKg: SortEnumType
+ actualLaunchDate: SortEnumType
+ scheduledLaunchDate: SortEnumType
}
input ListFilterInputTypeOfLaunchRecordFilterInput {
- all: LaunchRecordFilterInput
- none: LaunchRecordFilterInput
- some: LaunchRecordFilterInput
- any: Boolean
+ all: LaunchRecordFilterInput
+ none: LaunchRecordFilterInput
+ some: LaunchRecordFilterInput
+ any: Boolean
}
input LongOperationFilterInput {
- eq: Long
- neq: Long
- in: [Long]
- nin: [Long]
- gt: Long
- ngt: Long
- gte: Long
- ngte: Long
- lt: Long
- nlt: Long
- lte: Long
- nlte: Long
+ eq: Long
+ neq: Long
+ in: [Long]
+ nin: [Long]
+ gt: Long
+ ngt: Long
+ gte: Long
+ ngte: Long
+ lt: Long
+ nlt: Long
+ lte: Long
+ nlte: Long
}
input NodaTimeInputsInput {
- instant: Instant
- localDate: LocalDate
- localTime: LocalTime
- localDateTime: LocalDateTime
- offsetDateTime: OffsetDateTime
- offsetTime: OffsetTime
- period: Period
- duration: Duration
- zonedDateTime: ZonedDateTime
- offset: Offset
- isoDayOfWeek: IsoDayOfWeek
+ instant: Instant
+ localDate: LocalDate
+ localTime: LocalTime
+ localDateTime: LocalDateTime
+ offsetDateTime: OffsetDateTime
+ offsetTime: OffsetTime
+ period: Period
+ duration: Duration
+ zonedDateTime: ZonedDateTime
+ offset: Offset
+ isoDayOfWeek: IsoDayOfWeek
}
"A rocket in inventory"
input ReadyRocketFilterInput {
- and: [ReadyRocketFilterInput!]
- or: [ReadyRocketFilterInput!]
- id: StronglyTypedIdFilterOfUuidTypeFilterInput
- serialNumber: StringOperationFilterInput
- type: RocketTypeOperationFilterInput
- launchRecords: ListFilterInputTypeOfLaunchRecordFilterInput
+ and: [ReadyRocketFilterInput!]
+ or: [ReadyRocketFilterInput!]
+ id: StronglyTypedIdFilterOfUuidTypeFilterInput
+ serialNumber: StringOperationFilterInput
+ type: RocketTypeOperationFilterInput
+ launchRecords: ListFilterInputTypeOfLaunchRecordFilterInput
}
"A rocket in inventory"
input ReadyRocketSortInput {
- type: SortEnumType
- serialNumber: SortEnumType
+ type: SortEnumType
+ serialNumber: SortEnumType
}
input RocketTypeOperationFilterInput {
- eq: RocketType
- neq: RocketType
- in: [RocketType!]
- nin: [RocketType!]
+ eq: RocketType
+ neq: RocketType
+ in: [RocketType!]
+ nin: [RocketType!]
}
input StringOperationFilterInput {
- and: [StringOperationFilterInput!]
- or: [StringOperationFilterInput!]
- eq: String
- neq: String
- contains: String
- ncontains: String
- in: [String]
- nin: [String]
- startsWith: String
- nstartsWith: String
- endsWith: String
- nendsWith: String
+ and: [StringOperationFilterInput!]
+ or: [StringOperationFilterInput!]
+ eq: String
+ neq: String
+ contains: String
+ ncontains: String
+ in: [String]
+ nin: [String]
+ startsWith: String
+ nstartsWith: String
+ endsWith: String
+ nendsWith: String
}
input StronglyTypedIdFilterOfUuidTypeFilterInput {
- eq: UUID
- neq: UUID
- in: [UUID]
- nin: [UUID]
+ eq: UUID
+ neq: UUID
+ in: [UUID]
+ nin: [UUID]
}
input StronglyTypedIdOperationFilterInput {
- eq: UUID
- neq: UUID
- in: [UUID]
- nin: [UUID]
+ eq: UUID
+ neq: UUID
+ in: [UUID]
+ nin: [UUID]
}
enum GeoJSONGeometryType {
- Point
- MultiPoint
- LineString
- MultiLineString
- Polygon
- MultiPolygon
- GeometryCollection
+ Point
+ MultiPoint
+ LineString
+ MultiLineString
+ Polygon
+ MultiPolygon
+ GeometryCollection
}
"The available rocket types"
enum RocketType {
- "Your best bet"
- FALCON9
- "For those huge payloads"
- FALCON_HEAVY
- "We stole our competitors rocket platform!"
- ATLAS_V
+ "Your best bet"
+ FALCON9
+ "For those huge payloads"
+ FALCON_HEAVY
+ "We stole our competitors rocket platform!"
+ ATLAS_V
}
enum SortEnumType {
- ASC
- DESC
+ ASC
+ DESC
}
"A coordinate is an array of positions."
@@ -615,7 +615,7 @@ scalar Instant
"""
Equates the days of the week with their numerical value according to ISO-8601.
-Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7.
+ Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7.
"""
scalar IsoDayOfWeek
@@ -633,7 +633,7 @@ scalar Long
"""
An offset from UTC in seconds.
-A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America).
+ A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America).
"""
scalar Offset
@@ -660,4 +660,4 @@ scalar Void
A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants.
A ZonedDateTime is global, in that it maps to a single Instant.
"""
-scalar ZonedDateTime
+scalar ZonedDateTime
\ No newline at end of file