From cd236f842d3395de49f49fff8b06ef59af7c4e55 Mon Sep 17 00:00:00 2001 From: Struan Judd Date: Sun, 16 Feb 2025 08:39:27 +1300 Subject: [PATCH] Add parser to GqlModelGenerator and also GqlModel Namespace options --- src/GqlPlus.Generators/GqlModelGenerator.cs | 48 ++- .../GqlModelGenerator.props | 5 + src/GqlPlus.Generators/GqlModelOptions.cs | 18 + .../GqlPlus.Generators.csproj | 9 + src/GqlPlus.Parser/Token/Tokenizer.cs | 2 +- .../TestGeneratorsHelper.cs | 8 +- .../GqlModelConfigOptionsProvider.cs | 26 ++ .../GqlModelGeneratorTests.cs | 4 +- .../GqlPlus.GeneratorsTests.csproj | 2 +- ...lt-In#Model_Intro_Built-In.gen.verified.cs | 47 +- ...egory#Model_Intro_Category.gen.verified.cs | 19 +- ..._Common#Model_Intro_Common.gen.verified.cs | 46 +- ...plete#Model_Intro_Complete.gen.verified.cs | 401 ++++-------------- ...s#Model_Intro_Declarations.gen.verified.cs | 35 +- ...tive#Model_Intro_Directive.gen.verified.cs | 19 +- ..._Domain#Model_Intro_Domain.gen.verified.cs | 73 +--- ...ntro_Dual#Model_Intro_Dual.gen.verified.cs | 24 +- ...ntro_Enum#Model_Intro_Enum.gen.verified.cs | 17 +- ...ro_Input#Model_Intro_Input.gen.verified.cs | 32 +- ...ro_Names#Model_Intro_Names.gen.verified.cs | 17 +- ..._Object#Model_Intro_Object.gen.verified.cs | 52 +-- ..._Option#Model_Intro_Option.gen.verified.cs | 8 +- ..._Output#Model_Intro_Output.gen.verified.cs | 39 +- ...ro_Union#Model_Intro_Union.gen.verified.cs | 12 +- .../all#Model_all.gen.verified.cs | 15 +- .../default#Model_default.gen.verified.cs | 17 +- .../errors#Model_errors.gen.verified.cs | 10 +- 27 files changed, 300 insertions(+), 705 deletions(-) create mode 100644 src/GqlPlus.Generators/GqlModelGenerator.props create mode 100644 src/GqlPlus.Generators/GqlModelOptions.cs create mode 100644 test/GqlPlus.GeneratorsTests/GqlModelConfigOptionsProvider.cs diff --git a/src/GqlPlus.Generators/GqlModelGenerator.cs b/src/GqlPlus.Generators/GqlModelGenerator.cs index 8b5d0c94..279b9012 100644 --- a/src/GqlPlus.Generators/GqlModelGenerator.cs +++ b/src/GqlPlus.Generators/GqlModelGenerator.cs @@ -1,7 +1,14 @@ using System.Collections.Immutable; using System.Text; +using System.Threading; +using GqlPlus.Abstractions.Schema; +using GqlPlus.Parsing; +using GqlPlus.Parsing.Schema; +using GqlPlus.Result; +using GqlPlus.Token; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.Extensions.DependencyInjection; namespace GqlPlus; @@ -10,36 +17,57 @@ public class GqlModelGenerator : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { + IncrementalValueProvider gqlModelOptions = context.AnalyzerConfigOptionsProvider.Select(MakeGqlModelOptions); + IncrementalValueProvider> samples = context.AdditionalTextsProvider .Where(text => Path.GetExtension(text.Path).Equals(".graphql+", StringComparison.OrdinalIgnoreCase)) .Collect(); - context.RegisterSourceOutput(samples, GenerateCode); + context.RegisterSourceOutput(samples.Combine(gqlModelOptions), GenerateCode); + } + + private static GqlModelOptions MakeGqlModelOptions(AnalyzerConfigOptionsProvider provider, CancellationToken _) + { + if (!provider.GlobalOptions.TryGetValue("build_property.GqlPlus_BaseNamespace", out string? baseNamespace)) { + baseNamespace = "GqlPlus"; + } + + return new GqlModelOptions(baseNamespace); } - private void GenerateCode(SourceProductionContext context, ImmutableArray array) + private void GenerateCode(SourceProductionContext context, (ImmutableArray Left, GqlModelOptions Right) tuple) { - if (array.IsDefaultOrEmpty) { + (ImmutableArray array, GqlModelOptions? options) = tuple; + + if (array.IsDefaultOrEmpty || options is null) { return; } + IServiceProvider services = new ServiceCollection() + .AddCommonParsers() + .AddSchemaParsers() + .BuildServiceProvider(); + + Parser.L schemaParser = services.GetRequiredService.D>(); + foreach (AdditionalText text in array) { string file = Path.GetFileNameWithoutExtension(text.Path); StringBuilder builder = new("// Generated from "); builder.AppendLine(text.Path); builder.AppendLine("\n/*"); - TextLineCollection? lines = text.GetText()?.Lines; + string? lines = text.GetText()?.ToString(); if (lines is not null) { - foreach (TextLine line in lines) { - builder.AppendLine(line.ToString()); + Tokenizer tokens = new(lines); + + IGqlpSchema ast = schemaParser.Parse(tokens, "Schema").Required(); + foreach (IGqlpDeclaration item in ast.Declarations) { + builder.AppendLine(item.Label + " - " + item.Name); } } builder.AppendLine("*/\n"); - builder.AppendLine("namespace GqlPlus;"); - builder.AppendLine(); - builder.AppendLine("public class Model_" + file + " {}"); + builder.AppendLine($"namespace {options.BaseNamespace}.Model_" + file + " {}"); context.AddSource("Model_" + file + ".gen.cs", builder.ToString()); } diff --git a/src/GqlPlus.Generators/GqlModelGenerator.props b/src/GqlPlus.Generators/GqlModelGenerator.props new file mode 100644 index 00000000..329d8cf6 --- /dev/null +++ b/src/GqlPlus.Generators/GqlModelGenerator.props @@ -0,0 +1,5 @@ + + + + + diff --git a/src/GqlPlus.Generators/GqlModelOptions.cs b/src/GqlPlus.Generators/GqlModelOptions.cs new file mode 100644 index 00000000..543cab54 --- /dev/null +++ b/src/GqlPlus.Generators/GqlModelOptions.cs @@ -0,0 +1,18 @@ + +namespace GqlPlus; + +public sealed class GqlModelOptions(string baseNamespace) + : IEquatable +{ + public string BaseNamespace { get; } = baseNamespace; + + public bool Equals(GqlModelOptions other) + => BaseNamespace.Equals(other?.BaseNamespace, StringComparison.Ordinal); + + public override bool Equals(object obj) + => obj is GqlModelOptions options + ? Equals(options) + : base.Equals(obj); + public override int GetHashCode() + => HashCode.Combine(BaseNamespace); +} diff --git a/src/GqlPlus.Generators/GqlPlus.Generators.csproj b/src/GqlPlus.Generators/GqlPlus.Generators.csproj index 9df93b9f..97c08d42 100644 --- a/src/GqlPlus.Generators/GqlPlus.Generators.csproj +++ b/src/GqlPlus.Generators/GqlPlus.Generators.csproj @@ -13,6 +13,15 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/src/GqlPlus.Parser/Token/Tokenizer.cs b/src/GqlPlus.Parser/Token/Tokenizer.cs index 06ab0fe6..0740fe94 100644 --- a/src/GqlPlus.Parser/Token/Tokenizer.cs +++ b/src/GqlPlus.Parser/Token/Tokenizer.cs @@ -61,7 +61,7 @@ static Tokenizer() internal bool IgnoreSeparators { get; set; } - internal Tokenizer(string operation) + public Tokenizer(string operation) { _operation = operation.AsMemory(); _len = _operation.Length; diff --git a/test/GqlPlus.GeneratorsTestBase/TestGeneratorsHelper.cs b/test/GqlPlus.GeneratorsTestBase/TestGeneratorsHelper.cs index aed5aed3..95a8ef49 100644 --- a/test/GqlPlus.GeneratorsTestBase/TestGeneratorsHelper.cs +++ b/test/GqlPlus.GeneratorsTestBase/TestGeneratorsHelper.cs @@ -2,6 +2,7 @@ using DiffEngine; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; namespace GqlPlus; @@ -11,7 +12,7 @@ public static class TestGeneratorsHelper static TestGeneratorsHelper() => DiffRunner.MaxInstancesToLaunch(20); - public static GeneratorDriver Generate(this IIncrementalGenerator generator, ImmutableArray additionalPaths) + public static GeneratorDriver Generate(this IIncrementalGenerator generator, ImmutableArray additionalPaths, AnalyzerConfigOptionsProvider? configOptions = null) { SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(""); @@ -26,6 +27,11 @@ public static GeneratorDriver Generate(this IIncrementalGenerator generator, Imm GeneratorDriver driver = CSharpGeneratorDriver.Create(generator) .AddAdditionalTexts(additionalPaths); + if (configOptions is not null) { + driver = driver.WithUpdatedAnalyzerConfigOptions(configOptions); + } + + return driver.RunGenerators(compilation); } diff --git a/test/GqlPlus.GeneratorsTests/GqlModelConfigOptionsProvider.cs b/test/GqlPlus.GeneratorsTests/GqlModelConfigOptionsProvider.cs new file mode 100644 index 00000000..801f5c7e --- /dev/null +++ b/test/GqlPlus.GeneratorsTests/GqlModelConfigOptionsProvider.cs @@ -0,0 +1,26 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace GqlPlus; + +internal sealed class GqlModelConfigOptionsProvider : AnalyzerConfigOptionsProvider +{ + public override GqlModelConfigOptions GlobalOptions { get; } + = new(new() { ["build_property.GqlPlus_BaseNamespace"] = "GqlTest" }); + + public override GqlModelConfigOptions GetOptions(SyntaxTree tree) + => GqlModelConfigOptions.Empty; + public override GqlModelConfigOptions GetOptions(AdditionalText textFile) + => GqlModelConfigOptions.Empty; +} + +internal sealed class GqlModelConfigOptions( + Map values +) : AnalyzerConfigOptions +{ + public static GqlModelConfigOptions Empty { get; } = new([]); + + public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) + => values.TryGetValue(key, out value); +} diff --git a/test/GqlPlus.GeneratorsTests/GqlModelGeneratorTests.cs b/test/GqlPlus.GeneratorsTests/GqlModelGeneratorTests.cs index f5b1c8d9..4d05b127 100644 --- a/test/GqlPlus.GeneratorsTests/GqlModelGeneratorTests.cs +++ b/test/GqlPlus.GeneratorsTests/GqlModelGeneratorTests.cs @@ -20,8 +20,10 @@ public async Task ModelSchema(string sample) { string schema = await ReadSchema(sample); + GqlModelConfigOptionsProvider options = new(); + GeneratorDriver driver = new GqlModelGenerator() - .Generate((sample + ".graphql+").AdditionalString(schema)); + .Generate((sample + ".graphql+").AdditionalString(schema), options); await Verifier.Verify(driver, CustomSettings("Schema", "Model", sample)); } diff --git a/test/GqlPlus.GeneratorsTests/GqlPlus.GeneratorsTests.csproj b/test/GqlPlus.GeneratorsTests/GqlPlus.GeneratorsTests.csproj index 026a2768..6bf9e4aa 100644 --- a/test/GqlPlus.GeneratorsTests/GqlPlus.GeneratorsTests.csproj +++ b/test/GqlPlus.GeneratorsTests/GqlPlus.GeneratorsTests.csproj @@ -5,7 +5,7 @@ - + diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Built-In#Model_Intro_Built-In.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Built-In#Model_Intro_Built-In.gen.verified.cs index 74ab8c5f..003c0883 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Built-In#Model_Intro_Built-In.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Built-In#Model_Intro_Built-In.gen.verified.cs @@ -1,41 +1,14 @@ //HintName: Model_Intro_Built-In.gen.cs // Generated from Intro_Built-In.graphql+ /* -output _Constant { - | _Simple - | _ConstantList - | _ConstantMap - } -output _Simple { - | Boolean - | _DomainValue<_DomainKind.Number Number> - | _DomainValue<_DomainKind.String String> - | _EnumValue -} -output _ConstantList { - | _Constant[] - } -output _ConstantMap { - | _Constant[Simple] - } -output _Collections { - | _Modifier<_ModifierKind.List> - | _ModifierKeyed<_ModifierKind.Dictionary> - | _ModifierKeyed<_ModifierKind.TypeParam> - } -output _ModifierKeyed<$kind> { - : _Modifier<$kind> - by: _TypeSimple - optional: Boolean - } -output _Modifiers { - | _Modifier<_ModifierKind.Optional> - | _Collections - } -enum _ModifierKind { Opt[Optional] List Dict[Dictionary] Param[TypeParam] } -output _Modifier<$kind> { - modifierKind: $kind - } +Output - _Constant +Output - _Simple +Output - _ConstantList +Output - _ConstantMap +Output - _Collections +Output - _ModifierKeyed +Output - _Modifiers +Enum - _ModifierKind +Output - _Modifier */ -namespace GqlPlus; -public class Model_Intro_Built-In {} \ No newline at end of file +namespace GqlTest.Model_Intro_Built-In {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Category#Model_Intro_Category.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Category#Model_Intro_Category.gen.verified.cs index c62c89b6..d780caa7 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Category#Model_Intro_Category.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Category#Model_Intro_Category.gen.verified.cs @@ -1,19 +1,8 @@ //HintName: Model_Intro_Category.gen.cs // Generated from Intro_Category.graphql+ /* -output _Categories { - category: _Category - type: _Type - | _Category - | _Type -} -output _Category { - : _Aliased - resolution: _Resolution - output: _TypeRef<_TypeKind.Output> - modifiers: _Modifiers[] - } -enum _Resolution { Parallel Sequential Single } +Output - _Categories +Output - _Category +Enum - _Resolution */ -namespace GqlPlus; -public class Model_Intro_Category {} \ No newline at end of file +namespace GqlTest.Model_Intro_Category {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Common#Model_Intro_Common.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Common#Model_Intro_Common.gen.verified.cs index 2a44b3c5..cb91c77e 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Common#Model_Intro_Common.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Common#Model_Intro_Common.gen.verified.cs @@ -1,41 +1,13 @@ //HintName: Model_Intro_Common.gen.cs // Generated from Intro_Common.graphql+ /* -output _Type { - | _BaseType<_TypeKind.Basic> - | _BaseType<_TypeKind.Internal> - | _TypeDual - | _TypeEnum - | _TypeInput - | _TypeOutput - | _TypeDomain - | _TypeUnion - } -output _BaseType<$kind> { - : _Aliased - typeKind: $kind - } -output _ChildType<$kind $parent> { - : _BaseType<$kind> - parent: $parent - } -output _ParentType<$kind $item $allItem> { - : _ChildType<$kind _Identifier> - items: $item[] - allItems: $allItem[] - } -enum _SimpleKind { Basic Enum Internal Domain Union } -enum _TypeKind { :_SimpleKind Dual Input Output } -output _TypeRef<$kind> { - typeKind: $kind - name: _Identifier -} -output _TypeSimple { - | _TypeRef<_TypeKind.Basic> - | _TypeRef<_TypeKind.Enum> - | _TypeRef<_TypeKind.Domain> - | _TypeRef<_TypeKind.Union> - } +Output - _Type +Output - _BaseType +Output - _ChildType +Output - _ParentType +Enum - _SimpleKind +Enum - _TypeKind +Output - _TypeRef +Output - _TypeSimple */ -namespace GqlPlus; -public class Model_Intro_Common {} \ No newline at end of file +namespace GqlTest.Model_Intro_Common {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Complete#Model_Intro_Complete.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Complete#Model_Intro_Complete.gen.verified.cs index 4d4b9657..ecfa8c35 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Complete#Model_Intro_Complete.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Complete#Model_Intro_Complete.gen.verified.cs @@ -1,324 +1,85 @@ //HintName: Model_Intro_Complete.gen.cs // Generated from Intro_Complete.graphql+ /* -output _Schema { - : _Named - categories(_CategoryFilter?): _Categories[_Identifier] - directives(_Filter?): _Directives[_Identifier] - types(_TypeFilter?): _Type[_Identifier] - settings(_Filter?): _Setting[_Identifier] - } -domain _Identifier { String /[A-Za-z_]+/ } -input _Filter { - names: _NameFilter[] - matchAliases: Boolean? = true - aliases: _NameFilter[] - returnByAlias: Boolean? = false - returnReferencedTypes: Boolean? = false - | _NameFilter[] - } -"_NameFilter is a simple match expression against _Identifier where '.' matches any single character and '*' matches zero or more of any character." -domain _NameFilter { String /[A-Za-z_.*]+/ } -input _CategoryFilter { - : _Filter - resolutions: _Resolution[] - } -input _TypeFilter { - : _Filter - kinds: _TypeKind[] - } -dual _Aliased { - : _Described - aliases: _Identifier[] - } -dual _Described { - : _Named - description: String - } -dual _Named { - name: _Identifier - } -output _Categories { - category: _Category - type: _Type - | _Category - | _Type -} -output _Category { - : _Aliased - resolution: _Resolution - output: _TypeRef<_TypeKind.Output> - modifiers: _Modifiers[] - } -enum _Resolution { Parallel Sequential Single } -output _Directives { - directive: _Directive - type: _Type - | _Directive - | _Type -} -output _Directive { - : _Aliased - parameters: _InputParam[] - repeatable: Boolean - locations: _[_Location] - } -enum _Location { Operation Variable Field Inline Spread Fragment } -output _Setting { - : _Described - value: _Constant -} -output _Type { - | _BaseType<_TypeKind.Basic> - | _BaseType<_TypeKind.Internal> - | _TypeDual - | _TypeEnum - | _TypeInput - | _TypeOutput - | _TypeDomain - | _TypeUnion - } -output _BaseType<$kind> { - : _Aliased - typeKind: $kind - } -output _ChildType<$kind $parent> { - : _BaseType<$kind> - parent: $parent - } -output _ParentType<$kind $item $allItem> { - : _ChildType<$kind _Identifier> - items: $item[] - allItems: $allItem[] - } -enum _SimpleKind { Basic Enum Internal Domain Union } -enum _TypeKind { :_SimpleKind Dual Input Output } -output _TypeRef<$kind> { - typeKind: $kind - name: _Identifier -} -output _TypeSimple { - | _TypeRef<_TypeKind.Basic> - | _TypeRef<_TypeKind.Enum> - | _TypeRef<_TypeKind.Domain> - | _TypeRef<_TypeKind.Union> - } -output _Constant { - | _Simple - | _ConstantList - | _ConstantMap - } -output _Simple { - | Boolean - | _DomainValue<_DomainKind.Number Number> - | _DomainValue<_DomainKind.String String> - | _EnumValue -} -output _ConstantList { - | _Constant[] - } -output _ConstantMap { - | _Constant[Simple] - } -output _Collections { - | _Modifier<_ModifierKind.List> - | _ModifierKeyed<_ModifierKind.Dictionary> - | _ModifierKeyed<_ModifierKind.TypeParam> - } -output _ModifierKeyed<$kind> { - : _Modifier<$kind> - by: _TypeSimple - optional: Boolean - } -output _Modifiers { - | _Modifier<_ModifierKind.Optional> - | _Collections - } -enum _ModifierKind { Opt[Optional] List Dict[Dictionary] Param[TypeParam] } -output _Modifier<$kind> { - modifierKind: $kind - } -enum _DomainKind { Boolean Enum Number String } -output _TypeDomain { - | _BaseDomain<_DomainKind.Boolean _DomainTrueFalse _DomainItemTrueFalse> - | _BaseDomain<_DomainKind.Enum _DomainMember _DomainItemMember> - | _BaseDomain<_DomainKind.Number _DomainRange _DomainItemRange> - | _BaseDomain<_DomainKind.String _DomainRegex _DomainItemRegex> - } -output _DomainRef<$kind> { - : _TypeRef<_TypeKind.Domain> - domainKind: $kind - } -output _BaseDomain<$domain $item $domainItem> { - : _ParentType<_TypeKind.Domain $item $domainItem> - domain: $domain - } -dual _BaseDomainItem { - exclude: Boolean - } -output _DomainItem<$item> { - : $item - domain: _Identifier - } -output _DomainValue<$kind $value> { - : _DomainRef<$kind> - value: $value - } -dual _DomainTrueFalse { - : _BaseDomainItem - value: Boolean - } -output _DomainItemTrueFalse { - : _DomainItem<_DomainTrueFalse> - } -output _DomainMember { - : _BaseDomainItem - value: _EnumValue - } -output _DomainItemMember { - : _DomainItem<_DomainMember> - } -dual _DomainRange { - : _BaseDomainItem - lower: Number? - upper: Number? - } -output _DomainItemRange { - : _DomainItem<_DomainRange> - } -dual _DomainRegex { - : _BaseDomainItem - pattern: String - } -output _DomainItemRegex { - : _DomainItem<_DomainRegex> - } -output _TypeEnum { - : _ParentType<_TypeKind.Enum _Aliased _EnumMember> - } -dual _EnumMember { - : _Aliased - enum: _Identifier - } -output _EnumValue { - : _TypeRef<_TypeKind.Enum> - member: _Identifier - } -output _TypeUnion { - : _ParentType<_TypeKind.Union _Named _UnionMember> - } -dual _UnionMember { - : _Named - union: _Identifier - } -output _TypeObject<$kind $parent $field $alternate> { - : _ChildType<$kind $parent> - typeParams: _Described[] - fields: $field[] - alternates: $alternate[] - allFields: _ObjectFor<$field>[] - allAlternates: _ObjectFor<$alternate>[] - } -dual _ObjDescribed<$base> { - base: $base - description: String - | $base - } -output _ObjType<$base> { - | _BaseType<_TypeKind.Internal> - | _TypeSimple - | $base - } -output _ObjBase { - typeArgs: _ObjDescribed<_ObjArg>[] - | _TypeParam - } -output _ObjArg { - : _TypeRef<_TypeKind> - | _TypeParam -} -domain _TypeParam { :_Identifier String } -output _Alternate<$base> { - type: _ObjDescribed<$base> - collections: _Collections[] - } -output _ObjectFor<$for> { - : $for - object: _Identifier - } -output _Field<$base> { - : _Aliased - type: _ObjDescribed<$base> - modifiers: _Modifiers[] - } -output _TypeDual { - : _TypeObject<_TypeKind.Dual _DualParent _DualField _DualAlternate> - } -output _DualBase { - : _ObjBase - dual: _Identifier - } -output _DualParent { - : _ObjDescribed<_DualBase> - } -output _DualField { - : _Field<_DualBase> - } -output _DualAlternate { - : _Alternate<_DualBase> - } -output _TypeInput { - : _TypeObject<_TypeKind.Input _InputParent _InputField _InputAlternate> - } -output _InputBase { - : _ObjBase - input: _Identifier - | _DualBase - } -output _InputParent { - : _ObjDescribed<_InputBase> - } -output _InputField { - : _Field<_InputBase> - default: _Constant? - } -output _InputAlternate { - : _Alternate<_InputBase> - } -output _InputParam { - : _ObjDescribed<_InputBase> - modifiers: _Modifiers[] - default: _Constant? - } -output _TypeOutput { - : _TypeObject<_TypeKind.Output _OutputParent _OutputField _OutputAlternate> - } -output _OutputBase { - : _ObjBase - output: _Identifier - | _DualBase - } -output _OutputParent { - : _ObjDescribed<_OutputBase> - } -output _OutputField { - : _Field<_OutputBase> - parameter: _InputParam[] - | _OutputEnum - } -output _OutputAlternate { - : _Alternate<_OutputBase> - } -output _OutputArg { - : _TypeRef<_TypeKind> - member: _Identifier? - | _TypeParam - } -output _OutputEnum { - : _TypeRef<_TypeKind.Enum> - field: _Identifier - member: _Identifier - } +Output - _Schema +Domain - _Identifier +Input - _Filter +Domain - _NameFilter +Input - _CategoryFilter +Input - _TypeFilter +Dual - _Aliased +Dual - _Described +Dual - _Named +Output - _Categories +Output - _Category +Enum - _Resolution +Output - _Directives +Output - _Directive +Enum - _Location +Output - _Setting +Output - _Type +Output - _BaseType +Output - _ChildType +Output - _ParentType +Enum - _SimpleKind +Enum - _TypeKind +Output - _TypeRef +Output - _TypeSimple +Output - _Constant +Output - _Simple +Output - _ConstantList +Output - _ConstantMap +Output - _Collections +Output - _ModifierKeyed +Output - _Modifiers +Enum - _ModifierKind +Output - _Modifier +Enum - _DomainKind +Output - _TypeDomain +Output - _DomainRef +Output - _BaseDomain +Dual - _BaseDomainItem +Output - _DomainItem +Output - _DomainValue +Dual - _DomainTrueFalse +Output - _DomainItemTrueFalse +Output - _DomainMember +Output - _DomainItemMember +Dual - _DomainRange +Output - _DomainItemRange +Dual - _DomainRegex +Output - _DomainItemRegex +Output - _TypeEnum +Dual - _EnumMember +Output - _EnumValue +Output - _TypeUnion +Dual - _UnionMember +Output - _TypeObject +Dual - _ObjDescribed +Output - _ObjType +Output - _ObjBase +Output - _ObjArg +Domain - _TypeParam +Output - _Alternate +Output - _ObjectFor +Output - _Field +Output - _TypeDual +Output - _DualBase +Output - _DualParent +Output - _DualField +Output - _DualAlternate +Output - _TypeInput +Output - _InputBase +Output - _InputParent +Output - _InputField +Output - _InputAlternate +Output - _InputParam +Output - _TypeOutput +Output - _OutputBase +Output - _OutputParent +Output - _OutputField +Output - _OutputAlternate +Output - _OutputArg +Output - _OutputEnum */ -namespace GqlPlus; -public class Model_Intro_Complete {} \ No newline at end of file +namespace GqlTest.Model_Intro_Complete {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Declarations#Model_Intro_Declarations.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Declarations#Model_Intro_Declarations.gen.verified.cs index 55d035bf..7606f29a 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Declarations#Model_Intro_Declarations.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Declarations#Model_Intro_Declarations.gen.verified.cs @@ -1,32 +1,11 @@ //HintName: Model_Intro_Declarations.gen.cs // Generated from Intro_Declarations.graphql+ /* -output _Schema { - : _Named - categories(_CategoryFilter?): _Categories[_Identifier] - directives(_Filter?): _Directives[_Identifier] - types(_TypeFilter?): _Type[_Identifier] - settings(_Filter?): _Setting[_Identifier] - } -domain _Identifier { String /[A-Za-z_]+/ } -input _Filter { - names: _NameFilter[] - matchAliases: Boolean? = true - aliases: _NameFilter[] - returnByAlias: Boolean? = false - returnReferencedTypes: Boolean? = false - | _NameFilter[] - } -"_NameFilter is a simple match expression against _Identifier where '.' matches any single character and '*' matches zero or more of any character." -domain _NameFilter { String /[A-Za-z_.*]+/ } -input _CategoryFilter { - : _Filter - resolutions: _Resolution[] - } -input _TypeFilter { - : _Filter - kinds: _TypeKind[] - } +Output - _Schema +Domain - _Identifier +Input - _Filter +Domain - _NameFilter +Input - _CategoryFilter +Input - _TypeFilter */ -namespace GqlPlus; -public class Model_Intro_Declarations {} \ No newline at end of file +namespace GqlTest.Model_Intro_Declarations {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Directive#Model_Intro_Directive.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Directive#Model_Intro_Directive.gen.verified.cs index 6531a785..14233af1 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Directive#Model_Intro_Directive.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Directive#Model_Intro_Directive.gen.verified.cs @@ -1,19 +1,8 @@ //HintName: Model_Intro_Directive.gen.cs // Generated from Intro_Directive.graphql+ /* -output _Directives { - directive: _Directive - type: _Type - | _Directive - | _Type -} -output _Directive { - : _Aliased - parameters: _InputParam[] - repeatable: Boolean - locations: _[_Location] - } -enum _Location { Operation Variable Field Inline Spread Fragment } +Output - _Directives +Output - _Directive +Enum - _Location */ -namespace GqlPlus; -public class Model_Intro_Directive {} \ No newline at end of file +namespace GqlTest.Model_Intro_Directive {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Domain#Model_Intro_Domain.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Domain#Model_Intro_Domain.gen.verified.cs index f532a762..e817682a 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Domain#Model_Intro_Domain.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Domain#Model_Intro_Domain.gen.verified.cs @@ -1,61 +1,20 @@ //HintName: Model_Intro_Domain.gen.cs // Generated from Intro_Domain.graphql+ /* -enum _DomainKind { Boolean Enum Number String } -output _TypeDomain { - | _BaseDomain<_DomainKind.Boolean _DomainTrueFalse _DomainItemTrueFalse> - | _BaseDomain<_DomainKind.Enum _DomainMember _DomainItemMember> - | _BaseDomain<_DomainKind.Number _DomainRange _DomainItemRange> - | _BaseDomain<_DomainKind.String _DomainRegex _DomainItemRegex> - } -output _DomainRef<$kind> { - : _TypeRef<_TypeKind.Domain> - domainKind: $kind - } -output _BaseDomain<$domain $item $domainItem> { - : _ParentType<_TypeKind.Domain $item $domainItem> - domain: $domain - } -dual _BaseDomainItem { - exclude: Boolean - } -output _DomainItem<$item> { - : $item - domain: _Identifier - } -output _DomainValue<$kind $value> { - : _DomainRef<$kind> - value: $value - } -dual _DomainTrueFalse { - : _BaseDomainItem - value: Boolean - } -output _DomainItemTrueFalse { - : _DomainItem<_DomainTrueFalse> - } -output _DomainMember { - : _BaseDomainItem - value: _EnumValue - } -output _DomainItemMember { - : _DomainItem<_DomainMember> - } -dual _DomainRange { - : _BaseDomainItem - lower: Number? - upper: Number? - } -output _DomainItemRange { - : _DomainItem<_DomainRange> - } -dual _DomainRegex { - : _BaseDomainItem - pattern: String - } -output _DomainItemRegex { - : _DomainItem<_DomainRegex> - } +Enum - _DomainKind +Output - _TypeDomain +Output - _DomainRef +Output - _BaseDomain +Dual - _BaseDomainItem +Output - _DomainItem +Output - _DomainValue +Dual - _DomainTrueFalse +Output - _DomainItemTrueFalse +Output - _DomainMember +Output - _DomainItemMember +Dual - _DomainRange +Output - _DomainItemRange +Dual - _DomainRegex +Output - _DomainItemRegex */ -namespace GqlPlus; -public class Model_Intro_Domain {} \ No newline at end of file +namespace GqlTest.Model_Intro_Domain {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Dual#Model_Intro_Dual.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Dual#Model_Intro_Dual.gen.verified.cs index 92a1a906..eee481d7 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Dual#Model_Intro_Dual.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Dual#Model_Intro_Dual.gen.verified.cs @@ -1,22 +1,10 @@ //HintName: Model_Intro_Dual.gen.cs // Generated from Intro_Dual.graphql+ /* -output _TypeDual { - : _TypeObject<_TypeKind.Dual _DualParent _DualField _DualAlternate> - } -output _DualBase { - : _ObjBase - dual: _Identifier - } -output _DualParent { - : _ObjDescribed<_DualBase> - } -output _DualField { - : _Field<_DualBase> - } -output _DualAlternate { - : _Alternate<_DualBase> - } +Output - _TypeDual +Output - _DualBase +Output - _DualParent +Output - _DualField +Output - _DualAlternate */ -namespace GqlPlus; -public class Model_Intro_Dual {} \ No newline at end of file +namespace GqlTest.Model_Intro_Dual {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Enum#Model_Intro_Enum.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Enum#Model_Intro_Enum.gen.verified.cs index 3276c794..76661c38 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Enum#Model_Intro_Enum.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Enum#Model_Intro_Enum.gen.verified.cs @@ -1,17 +1,8 @@ //HintName: Model_Intro_Enum.gen.cs // Generated from Intro_Enum.graphql+ /* -output _TypeEnum { - : _ParentType<_TypeKind.Enum _Aliased _EnumMember> - } -dual _EnumMember { - : _Aliased - enum: _Identifier - } -output _EnumValue { - : _TypeRef<_TypeKind.Enum> - member: _Identifier - } +Output - _TypeEnum +Dual - _EnumMember +Output - _EnumValue */ -namespace GqlPlus; -public class Model_Intro_Enum {} \ No newline at end of file +namespace GqlTest.Model_Intro_Enum {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Input#Model_Intro_Input.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Input#Model_Intro_Input.gen.verified.cs index a78ab168..dfb28a28 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Input#Model_Intro_Input.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Input#Model_Intro_Input.gen.verified.cs @@ -1,29 +1,11 @@ //HintName: Model_Intro_Input.gen.cs // Generated from Intro_Input.graphql+ /* -output _TypeInput { - : _TypeObject<_TypeKind.Input _InputParent _InputField _InputAlternate> - } -output _InputBase { - : _ObjBase - input: _Identifier - | _DualBase - } -output _InputParent { - : _ObjDescribed<_InputBase> - } -output _InputField { - : _Field<_InputBase> - default: _Constant? - } -output _InputAlternate { - : _Alternate<_InputBase> - } -output _InputParam { - : _ObjDescribed<_InputBase> - modifiers: _Modifiers[] - default: _Constant? - } +Output - _TypeInput +Output - _InputBase +Output - _InputParent +Output - _InputField +Output - _InputAlternate +Output - _InputParam */ -namespace GqlPlus; -public class Model_Intro_Input {} \ No newline at end of file +namespace GqlTest.Model_Intro_Input {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Names#Model_Intro_Names.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Names#Model_Intro_Names.gen.verified.cs index db160db3..3ff40669 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Names#Model_Intro_Names.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Names#Model_Intro_Names.gen.verified.cs @@ -1,17 +1,8 @@ //HintName: Model_Intro_Names.gen.cs // Generated from Intro_Names.graphql+ /* -dual _Aliased { - : _Described - aliases: _Identifier[] - } -dual _Described { - : _Named - description: String - } -dual _Named { - name: _Identifier - } +Dual - _Aliased +Dual - _Described +Dual - _Named */ -namespace GqlPlus; -public class Model_Intro_Names {} \ No newline at end of file +namespace GqlTest.Model_Intro_Names {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Object#Model_Intro_Object.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Object#Model_Intro_Object.gen.verified.cs index e60c9820..14457a07 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Object#Model_Intro_Object.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Object#Model_Intro_Object.gen.verified.cs @@ -1,46 +1,14 @@ //HintName: Model_Intro_Object.gen.cs // Generated from Intro_Object.graphql+ /* -output _TypeObject<$kind $parent $field $alternate> { - : _ChildType<$kind $parent> - typeParams: _Described[] - fields: $field[] - alternates: $alternate[] - allFields: _ObjectFor<$field>[] - allAlternates: _ObjectFor<$alternate>[] - } -dual _ObjDescribed<$base> { - base: $base - description: String - | $base - } -output _ObjType<$base> { - | _BaseType<_TypeKind.Internal> - | _TypeSimple - | $base - } -output _ObjBase { - typeArgs: _ObjDescribed<_ObjArg>[] - | _TypeParam - } -output _ObjArg { - : _TypeRef<_TypeKind> - | _TypeParam -} -domain _TypeParam { :_Identifier String } -output _Alternate<$base> { - type: _ObjDescribed<$base> - collections: _Collections[] - } -output _ObjectFor<$for> { - : $for - object: _Identifier - } -output _Field<$base> { - : _Aliased - type: _ObjDescribed<$base> - modifiers: _Modifiers[] - } +Output - _TypeObject +Dual - _ObjDescribed +Output - _ObjType +Output - _ObjBase +Output - _ObjArg +Domain - _TypeParam +Output - _Alternate +Output - _ObjectFor +Output - _Field */ -namespace GqlPlus; -public class Model_Intro_Object {} \ No newline at end of file +namespace GqlTest.Model_Intro_Object {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Option#Model_Intro_Option.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Option#Model_Intro_Option.gen.verified.cs index e3f6c860..3b5fe165 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Option#Model_Intro_Option.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Option#Model_Intro_Option.gen.verified.cs @@ -1,10 +1,6 @@ //HintName: Model_Intro_Option.gen.cs // Generated from Intro_Option.graphql+ /* -output _Setting { - : _Described - value: _Constant -} +Output - _Setting */ -namespace GqlPlus; -public class Model_Intro_Option {} \ No newline at end of file +namespace GqlTest.Model_Intro_Option {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Output#Model_Intro_Output.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Output#Model_Intro_Output.gen.verified.cs index f7b6bc85..0a904981 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Output#Model_Intro_Output.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Output#Model_Intro_Output.gen.verified.cs @@ -1,35 +1,12 @@ //HintName: Model_Intro_Output.gen.cs // Generated from Intro_Output.graphql+ /* -output _TypeOutput { - : _TypeObject<_TypeKind.Output _OutputParent _OutputField _OutputAlternate> - } -output _OutputBase { - : _ObjBase - output: _Identifier - | _DualBase - } -output _OutputParent { - : _ObjDescribed<_OutputBase> - } -output _OutputField { - : _Field<_OutputBase> - parameter: _InputParam[] - | _OutputEnum - } -output _OutputAlternate { - : _Alternate<_OutputBase> - } -output _OutputArg { - : _TypeRef<_TypeKind> - member: _Identifier? - | _TypeParam - } -output _OutputEnum { - : _TypeRef<_TypeKind.Enum> - field: _Identifier - member: _Identifier - } +Output - _TypeOutput +Output - _OutputBase +Output - _OutputParent +Output - _OutputField +Output - _OutputAlternate +Output - _OutputArg +Output - _OutputEnum */ -namespace GqlPlus; -public class Model_Intro_Output {} \ No newline at end of file +namespace GqlTest.Model_Intro_Output {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Union#Model_Intro_Union.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Union#Model_Intro_Union.gen.verified.cs index 45b5aa93..279da573 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Union#Model_Intro_Union.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Union#Model_Intro_Union.gen.verified.cs @@ -1,13 +1,7 @@ //HintName: Model_Intro_Union.gen.cs // Generated from Intro_Union.graphql+ /* -output _TypeUnion { - : _ParentType<_TypeKind.Union _Named _UnionMember> - } -dual _UnionMember { - : _Named - union: _Identifier - } +Output - _TypeUnion +Dual - _UnionMember */ -namespace GqlPlus; -public class Model_Intro_Union {} \ No newline at end of file +namespace GqlTest.Model_Intro_Union {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/all#Model_all.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/all#Model_all.gen.verified.cs index 5c8a92ae..00a00b4d 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/all#Model_all.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/all#Model_all.gen.verified.cs @@ -1,12 +1,11 @@ //HintName: Model_all.gen.cs // Generated from all.graphql+ /* -category { All } -directive @all { All } -enum One { Two Three } -input Param { afterId: Guid? beforeId: Guid | String } -output All { items(Param?): String[] | String } -domain Guid { String /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/ } +Category - all +Directive - all +Enum - One +Input - Param +Output - All +Domain - Guid */ -namespace GqlPlus; -public class Model_all {} \ No newline at end of file +namespace GqlTest.Model_all {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/default#Model_default.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/default#Model_default.gen.verified.cs index 401b2c58..aff9602c 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/default#Model_default.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/default#Model_default.gen.verified.cs @@ -1,13 +1,12 @@ //HintName: Model_default.gen.cs // Generated from default.graphql+ /* -category { Query } -output Query { } -category { (sequential) Mutation } -output Mutation { } -category { (single) Subscription } -output Subscription { } -output _Schema { } +Category - query +Output - Query +Category - mutation +Output - Mutation +Category - subscription +Output - Subscription +Output - _Schema */ -namespace GqlPlus; -public class Model_default {} \ No newline at end of file +namespace GqlTest.Model_default {} \ No newline at end of file diff --git a/test/GqlPlus.GeneratorsTests/SchemaModelTests/errors#Model_errors.gen.verified.cs b/test/GqlPlus.GeneratorsTests/SchemaModelTests/errors#Model_errors.gen.verified.cs index 69eab2b5..2d84f98c 100644 --- a/test/GqlPlus.GeneratorsTests/SchemaModelTests/errors#Model_errors.gen.verified.cs +++ b/test/GqlPlus.GeneratorsTests/SchemaModelTests/errors#Model_errors.gen.verified.cs @@ -1,12 +1,6 @@ //HintName: Model_errors.gen.cs // Generated from errors.graphql+ /* -category query {} -directive @ {} -enum None [] {} -input Empty {} -output NoParams<> {} -domain Other { Enum } +Category - query */ -namespace GqlPlus; -public class Model_errors {} \ No newline at end of file +namespace GqlTest.Model_errors {} \ No newline at end of file