Skip to content

Commit

Permalink
Migrate to NET8 (#382)
Browse files Browse the repository at this point in the history
* Migrate to NET8

* format

* Update

---------

Co-authored-by: Shane Krueger <Shane@acdmail.com>
  • Loading branch information
sungam3r and Shane32 authored Dec 11, 2023
1 parent 8de2491 commit aa5475e
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 58 deletions.
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
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

0 comments on commit aa5475e

Please sign in to comment.