-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser to GqlModelGenerator and also GqlModel Namespace options
- Loading branch information
Showing
27 changed files
with
300 additions
and
705 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
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,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<CompilerVisibleProperty Include="GqlPlus_BaseNamespace" /> | ||
</ItemGroup> | ||
</Project> |
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,18 @@ | ||
| ||
namespace GqlPlus; | ||
|
||
public sealed class GqlModelOptions(string baseNamespace) | ||
: IEquatable<GqlModelOptions> | ||
{ | ||
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); | ||
} |
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
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
26 changes: 26 additions & 0 deletions
26
test/GqlPlus.GeneratorsTests/GqlModelConfigOptionsProvider.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,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<string> values | ||
) : AnalyzerConfigOptions | ||
{ | ||
public static GqlModelConfigOptions Empty { get; } = new([]); | ||
|
||
public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) | ||
=> values.TryGetValue(key, out value); | ||
} |
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
47 changes: 10 additions & 37 deletions
47
...Plus.GeneratorsTests/SchemaModelTests/Intro_Built-In#Model_Intro_Built-In.gen.verified.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 |
---|---|---|
@@ -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 {} | ||
namespace GqlTest.Model_Intro_Built-In {} |
19 changes: 4 additions & 15 deletions
19
...Plus.GeneratorsTests/SchemaModelTests/Intro_Category#Model_Intro_Category.gen.verified.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 |
---|---|---|
@@ -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 {} | ||
namespace GqlTest.Model_Intro_Category {} |
46 changes: 9 additions & 37 deletions
46
.../GqlPlus.GeneratorsTests/SchemaModelTests/Intro_Common#Model_Intro_Common.gen.verified.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 |
---|---|---|
@@ -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 {} | ||
namespace GqlTest.Model_Intro_Common {} |
Oops, something went wrong.