-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed initialization race-condition in generated code. (#7834)
* Fixed initialization race-condition in generated code. * Updated Snapshots
- Loading branch information
1 parent
4d6e37d
commit 63ab9f3
Showing
10 changed files
with
318 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/HotChocolate/Core/test/Types.Analyzers.Tests/TestMe.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// <auto-generated/> | ||
|
||
#nullable enable | ||
#pragma warning disable | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using HotChocolate; | ||
using HotChocolate.Types; | ||
using HotChocolate.Execution.Configuration; | ||
using HotChocolate.Internal; | ||
|
||
namespace HotChocolate.Types | ||
{ | ||
internal static class EntityInterfaceResolvers2 | ||
{ | ||
private static readonly object _sync = new object(); | ||
private static bool _bindingsInitialized; | ||
private readonly static global::HotChocolate.Internal.IParameterBinding[] _args_EntityInterface_IdString = new global::HotChocolate.Internal.IParameterBinding[1]; | ||
|
||
public static void InitializeBindings(global::HotChocolate.Internal.IParameterBindingResolver bindingResolver) | ||
{ | ||
if (!_bindingsInitialized) | ||
{ | ||
lock (_sync) | ||
{ | ||
if (!_bindingsInitialized) | ||
{ | ||
const global::System.Reflection.BindingFlags bindingFlags = | ||
global::System.Reflection.BindingFlags.Public | ||
| global::System.Reflection.BindingFlags.NonPublic | ||
| global::System.Reflection.BindingFlags.Static; | ||
|
||
var type = typeof(global::HotChocolate.Types.EntityInterface); | ||
global::System.Reflection.MethodInfo resolver = default!; | ||
global::System.Reflection.ParameterInfo[] parameters = default!; | ||
|
||
resolver = type.GetMethod( | ||
"IdString", | ||
bindingFlags, | ||
new global::System.Type[] { typeof(global::HotChocolate.Types.IEntity) })!; | ||
parameters = resolver.GetParameters(); | ||
_args_EntityInterface_IdString[0] = bindingResolver.GetBinding(parameters[0]); | ||
|
||
_bindingsInitialized = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static HotChocolate.Resolvers.FieldResolverDelegates EntityInterface_IdString() | ||
{ | ||
if(!_bindingsInitialized) | ||
{ | ||
throw new global::System.InvalidOperationException("The bindings must be initialized before the resolvers can be created."); | ||
} | ||
return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: EntityInterface_IdString_Resolver); | ||
} | ||
|
||
private static global::System.Object? EntityInterface_IdString_Resolver(global::HotChocolate.Resolvers.IResolverContext context) | ||
{ | ||
var args0 = context.Parent<global::HotChocolate.Types.IEntity>(); | ||
var result = global::HotChocolate.Types.EntityInterface.IdString(args0); | ||
return result; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.