diff --git a/src/GraphQLParser.Tests/ParserTests.Throw.cs b/src/GraphQLParser.Tests/ParserTests.Throw.cs index 7f14addc..616da69e 100644 --- a/src/GraphQLParser.Tests/ParserTests.Throw.cs +++ b/src/GraphQLParser.Tests/ParserTests.Throw.cs @@ -294,20 +294,36 @@ public void Should_Throw_If_Descriptions_Not_Allowed(string query) [Fact] public void Should_Throw_On_Unknown_Cases_From_ExpectOneOf() { - var context = new ParserContext("abc", default); - Should.Throw(() => context.ParseNamedDefinition(new[] { "abc" })) + Should.Throw( + () => + { + var context = new ParserContext("abc", default); + context.ParseNamedDefinition(new[] { "abc" }); + }) .Message.ShouldBe("Unexpected keyword 'abc' in ParseNamedDefinition."); - context = new ParserContext("abc", default); - Should.Throw(() => context.ParseOperationType(new[] { "abc" })) + Should.Throw( + () => + { + var context = new ParserContext("abc", default); + context.ParseOperationType(new[] { "abc" }); + }) .Message.ShouldBe("Unexpected keyword 'abc' in ParseOperationType."); - context = new ParserContext("abc", default); - Should.Throw(() => context.ParseDirectiveLocation(new[] { "abc" })) + Should.Throw( + () => + { + var context = new ParserContext("abc", default); + context.ParseDirectiveLocation(new[] { "abc" }); + }) .Message.ShouldBe("Unexpected keyword 'abc' in ParseDirectiveLocation."); - context = new ParserContext("extend abc", default); - Should.Throw(() => context.ParseTypeExtension(new[] { "abc" })) + Should.Throw( + () => + { + var context = new ParserContext("extend abc", default); + context.ParseTypeExtension(new[] { "abc" }); + }) .Message.ShouldBe("Unexpected keyword 'abc' in ParseTypeExtension."); } } diff --git a/src/GraphQLParser/ParserContext.Parse.cs b/src/GraphQLParser/ParserContext.Parse.cs index 4a0cdad1..0cddc8f8 100644 --- a/src/GraphQLParser/ParserContext.Parse.cs +++ b/src/GraphQLParser/ParserContext.Parse.cs @@ -3,8 +3,8 @@ namespace GraphQLParser; -// WARNING: mutable struct, pass it by reference to those methods that will change it -internal partial struct ParserContext +// WARNING: mutable ref struct, pass it by reference to those methods that will change it +internal ref partial struct ParserContext { // http://spec.graphql.org/October2021/#Document public GraphQLDocument ParseDocument() diff --git a/src/GraphQLParser/ParserContext.cs b/src/GraphQLParser/ParserContext.cs index 3a45135c..e83c7a3c 100644 --- a/src/GraphQLParser/ParserContext.cs +++ b/src/GraphQLParser/ParserContext.cs @@ -5,8 +5,9 @@ namespace GraphQLParser; -// WARNING: mutable struct, pass it by reference to those methods that will change it -internal partial struct ParserContext +// WARNING: mutable ref struct, pass it by reference to those methods that will change it + +internal ref partial struct ParserContext { private static string[] TopLevelKeywordOneOf { get; set; } = new[] {