Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to NET8 #382

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ jobs:
dotnet-version: |
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Disable MSVS Nuget Source # see https://github.com/graphql-dotnet/graphql-dotnet/issues/2422
if: ${{ startsWith(matrix.os, 'windows') }}
run: dotnet nuget disable source 'Microsoft Visual Studio Offline Packages'
- name: Install dependencies
working-directory: src
run: dotnet restore
Expand All @@ -72,7 +70,7 @@ jobs:
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: codecov/codecov-action@v3
with:
files: .coverage/GraphQLParser.Tests/coverage.net5.opencover.xml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a bug.

files: .coverage/GraphQLParser.Tests/coverage.net8.opencover.xml

buildcheck:
needs:
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQLParser.ApiTests/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Public_Api_Should_Not_Change_Inadvertently(Type type)
{
IncludeAssemblyAttributes = false,
//WhitelistedNamespacePrefixes = new[] { "Microsoft.Extensions.DependencyInjection" },
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute", "System.Diagnostics.CodeAnalysis.AllowNullAttribute" }
ExcludeAttributes = ["System.Diagnostics.DebuggerDisplayAttribute", "System.Diagnostics.CodeAnalysis.AllowNullAttribute"]
}))).ToArray();

if (publicApi.DistinctBy(item => item.content).Count() == 1)
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQLParser.ApiTests/GraphQLParser.ApiTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8</TargetFramework>
<NoWarn>$(NoWarn);1591</NoWarn>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQLParser.Tests/GraphQLParser.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(SingleTestPlatform)' != 'true'">
<TargetFrameworks>net6;net7</TargetFrameworks>
<TargetFrameworks>net6;net7;net8</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
</PropertyGroup>

Expand Down
16 changes: 8 additions & 8 deletions src/GraphQLParser.Tests/NodeHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public void NodeHelper_Should_Return_Proper_Nodes_1()
foreach (var method in typeof(NodeHelper).GetMethods().Where(m => m.IsStatic))
{
var node = method.GetParameters().Length == 1
? (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.None })
: (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.None, Activator.CreateInstance(method.GetParameters()[1].ParameterType) });
? (ASTNode)method.Invoke(null, [IgnoreOptions.None])
: (ASTNode)method.Invoke(null, [IgnoreOptions.None, Activator.CreateInstance(method.GetParameters()[1].ParameterType)]);

node.Comments = new List<GraphQLComment> { new GraphQLComment("abcdef") };
if (node is not GraphQLComment &&
Expand All @@ -29,8 +29,8 @@ public void NodeHelper_Should_Return_Proper_Nodes_2()
foreach (var method in typeof(NodeHelper).GetMethods().Where(m => m.IsStatic))
{
var node = method.GetParameters().Length == 1
? (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.Comments })
: (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.Comments, Activator.CreateInstance(method.GetParameters()[1].ParameterType) });
? (ASTNode)method.Invoke(null, [IgnoreOptions.Comments])
: (ASTNode)method.Invoke(null, [IgnoreOptions.Comments, Activator.CreateInstance(method.GetParameters()[1].ParameterType)]);

node.Comments = new List<GraphQLComment> { new GraphQLComment("abcdef") };
node.Comment.ShouldBeNull();
Expand All @@ -46,8 +46,8 @@ public void NodeHelper_Should_Return_Proper_Nodes_3()
foreach (var method in typeof(NodeHelper).GetMethods().Where(m => m.IsStatic))
{
var node = method.GetParameters().Length == 1
? (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.Locations })
: (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.Locations, Activator.CreateInstance(method.GetParameters()[1].ParameterType) });
? (ASTNode)method.Invoke(null, [IgnoreOptions.Locations])
: (ASTNode)method.Invoke(null, [IgnoreOptions.Locations, Activator.CreateInstance(method.GetParameters()[1].ParameterType)]);

node.Comments = new List<GraphQLComment> { new GraphQLComment("abcdef") };
if (node is not GraphQLComment &&
Expand All @@ -67,8 +67,8 @@ public void NodeHelper_Should_Return_Proper_Nodes_4()
foreach (var method in typeof(NodeHelper).GetMethods().Where(m => m.IsStatic))
{
var node = method.GetParameters().Length == 1
? (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.All })
: (ASTNode)method.Invoke(null, new object[] { IgnoreOptions.All, Activator.CreateInstance(method.GetParameters()[1].ParameterType) });
? (ASTNode)method.Invoke(null, [IgnoreOptions.All])
: (ASTNode)method.Invoke(null, [IgnoreOptions.All, Activator.CreateInstance(method.GetParameters()[1].ParameterType)]);

node.Comments = new List<GraphQLComment> { new GraphQLComment("abcdef") };
node.Comment.ShouldBeNull();
Expand Down
68 changes: 34 additions & 34 deletions src/GraphQLParser/ParserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace GraphQLParser;

internal ref partial struct ParserContext
{
private static string[] TopLevelKeywordOneOf { get; set; } = new[]
{
private static string[] TopLevelKeywordOneOf { get; set; } =
[
"query",
"mutation",
"subscription",
Expand All @@ -24,50 +24,50 @@ internal ref partial struct ParserContext
"input",
"extend",
"directive",
};
];

private static string[] TypeExtensionOneOf { get; set; } = new[]
{
private static string[] TypeExtensionOneOf { get; set; } =
[
"schema",
"scalar",
"type",
"interface",
"union",
"enum",
"input",
};
];

private static string[] OperationTypeOneOf { get; set; } = new[]
{
private static string[] OperationTypeOneOf { get; set; } =
[
"query",
"mutation",
"subscription",
};

private static string[] DirectiveLocationOneOf { get; set; } = new[]
{
// http://spec.graphql.org/June2018/#ExecutableDirectiveLocation
"QUERY",
"MUTATION",
"SUBSCRIPTION",
"FIELD",
"FRAGMENT_DEFINITION",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT",
"VARIABLE_DEFINITION",
// http://spec.graphql.org/June2018/#TypeSystemDirectiveLocation
"SCHEMA",
"SCALAR",
"OBJECT",
"FIELD_DEFINITION",
"ARGUMENT_DEFINITION",
"INTERFACE",
"UNION",
"ENUM",
"ENUM_VALUE",
"INPUT_OBJECT",
"INPUT_FIELD_DEFINITION",
};
];

private static string[] DirectiveLocationOneOf { get; set; } =
[
// http://spec.graphql.org/June2018/#ExecutableDirectiveLocation
"QUERY",
"MUTATION",
"SUBSCRIPTION",
"FIELD",
"FRAGMENT_DEFINITION",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT",
"VARIABLE_DEFINITION",
// http://spec.graphql.org/June2018/#TypeSystemDirectiveLocation
"SCHEMA",
"SCALAR",
"OBJECT",
"FIELD_DEFINITION",
"ARGUMENT_DEFINITION",
"INTERFACE",
"UNION",
"ENUM",
"ENUM_VALUE",
"INPUT_OBJECT",
"INPUT_FIELD_DEFINITION",
];

private delegate TResult ParseCallback<out TResult>(ref ParserContext context);

Expand Down
40 changes: 35 additions & 5 deletions src/GraphQLParser/Visitors/SDLPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,11 +1135,41 @@ private static bool TryPeekParent(TContext context, [NotNullWhen(true)] out ASTN
return true;
}

private static readonly string[] _hex32 = new[]
{
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", "\\u0008", "\\u0009", "\\u000A", "\\u000B", "\\u000C", "\\u000D", "\\u000E", "\\u000F",
"\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001A", "\\u001B", "\\u001C", "\\u001D", "\\u001E", "\\u001F"
};
private static readonly string[] _hex32 =
[
"\\u0000",
"\\u0001",
"\\u0002",
"\\u0003",
"\\u0004",
"\\u0005",
"\\u0006",
"\\u0007",
"\\u0008",
"\\u0009",
"\\u000A",
"\\u000B",
"\\u000C",
"\\u000D",
"\\u000E",
"\\u000F",
"\\u0010",
"\\u0011",
"\\u0012",
"\\u0013",
"\\u0014",
"\\u0015",
"\\u0016",
"\\u0017",
"\\u0018",
"\\u0019",
"\\u001A",
"\\u001B",
"\\u001C",
"\\u001D",
"\\u001E",
"\\u001F"
];

// http://spec.graphql.org/October2021/#StringCharacter
private static async ValueTask WriteEncodedStringAsync(TContext context, ROM value)
Expand Down