Skip to content

Commit a390e46

Browse files
glen-84michaelstaib
authored andcommitted
Fixed issue with non-deterministic order of automatic type registrations (#7708)
1 parent ae1557d commit a390e46

17 files changed

+468
-4
lines changed

src/HotChocolate/Core/src/Types.Analyzers/Generators/TypeModuleSyntaxGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static void WriteConfiguration(
6363
var hasInterfaceTypes = false;
6464
var hasConfigurations = false;
6565

66-
foreach (var syntaxInfo in syntaxInfos)
66+
foreach (var syntaxInfo in syntaxInfos.OrderBy(s => s.OrderByKey))
6767
{
6868
if(syntaxInfo.Diagnostics.Length > 0)
6969
{

src/HotChocolate/Core/src/Types.Analyzers/Models/DataLoaderDefaultsInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public sealed class DataLoaderDefaultsInfo(
1818

1919
public bool GenerateInterfaces { get; } = generateInterfaces;
2020

21+
public override string OrderByKey => string.Empty;
22+
2123
public override bool Equals(object? obj)
2224
=> obj is DataLoaderDefaultsInfo other && Equals(other);
2325

src/HotChocolate/Core/src/Types.Analyzers/Models/DataLoaderInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public DataLoaderInfo(
7878

7979
public ImmutableArray<DataLoaderParameterInfo> Parameters { get; }
8080

81+
public override string OrderByKey => FullName;
82+
8183
public ImmutableArray<CacheLookup> GetLookups(ITypeSymbol keyType, ITypeSymbol valueType)
8284
{
8385
if (_lookups.Length > 0)

src/HotChocolate/Core/src/Types.Analyzers/Models/DataLoaderModuleInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ public sealed class DataLoaderModuleInfo(string moduleName) : SyntaxInfo
44
{
55
public string ModuleName { get; } = moduleName;
66

7+
public override string OrderByKey => ModuleName;
8+
79
public override bool Equals(object? obj)
810
=> obj is DataLoaderModuleInfo other && Equals(other);
911

src/HotChocolate/Core/src/Types.Analyzers/Models/InterfaceTypeExtensionInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public sealed class InterfaceTypeExtensionInfo(
2323

2424
public ImmutableArray<Resolver> Resolvers { get; } = resolvers;
2525

26+
public override string OrderByKey => Name;
27+
2628
public override bool Equals(object? obj)
2729
=> obj is ObjectTypeExtensionInfo other && Equals(other);
2830

src/HotChocolate/Core/src/Types.Analyzers/Models/ModuleInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public sealed class ModuleInfo(string moduleName, ModuleOptions options) : Synta
66

77
public ModuleOptions Options { get; } = options;
88

9+
public override string OrderByKey => ModuleName;
10+
911
public override bool Equals(object? obj)
1012
=> obj is ModuleInfo other && Equals(other);
1113

src/HotChocolate/Core/src/Types.Analyzers/Models/ObjectTypeExtensionInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public sealed class ObjectTypeExtensionInfo(
2626

2727
public ImmutableArray<Resolver> Resolvers { get; } = resolvers;
2828

29+
public override string OrderByKey => Name;
30+
2931
public override bool Equals(object? obj)
3032
=> obj is ObjectTypeExtensionInfo other && Equals(other);
3133

src/HotChocolate/Core/src/Types.Analyzers/Models/OperationInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public sealed class OperationInfo(OperationType type, string typeName, string me
88

99
public string MethodName { get; } = methodName;
1010

11+
public override string OrderByKey => TypeName;
12+
1113
public override bool Equals(object? obj)
1214
=> obj is OperationInfo other && Equals(other);
1315

src/HotChocolate/Core/src/Types.Analyzers/Models/OperationRegistrationInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public sealed class OperationRegistrationInfo(OperationType type, string typeNam
66

77
public string TypeName { get; } = typeName;
88

9+
public override string OrderByKey => TypeName;
10+
911
public override bool Equals(object? obj)
1012
=> obj is OperationRegistrationInfo other && Equals(other);
1113

src/HotChocolate/Core/src/Types.Analyzers/Models/RegisterDataLoaderInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ public sealed class RegisterDataLoaderInfo(string name) : SyntaxInfo
44
{
55
public string Name { get; } = name;
66

7+
public override string OrderByKey => Name;
8+
79
public override bool Equals(object? obj)
810
=> obj is RegisterDataLoaderInfo other && Equals(other);
911

0 commit comments

Comments
 (0)