Skip to content
Merged

NET6 #184

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
10 changes: 6 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: 2
updates:
- package-ecosystem: nuget
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: daily
time: '02:00'
open-pull-requests-limit: 10
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core 5.0 SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
dotnet-version: "6.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/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
dotnet-version: "6.0.x"
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
version="${github_ref:10}"
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Setup .NET Core 5.0 SDK
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
dotnet-version: "6.0.x"
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
Expand All @@ -53,7 +53,7 @@ jobs:
working-directory: src
run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}}
- name: Upload Nuget packages as release artifacts
uses: actions/github-script@v2
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
Expand All @@ -64,7 +64,7 @@ jobs:
for (let file of await fs.readdir('src/out')) {
console.log('uploading', file);

await github.repos.uploadReleaseAsset({
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: ${{ github.event.release.id }},
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup .NET Core 3.1 SDK
- name: Setup .NET Core SDKs
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Setup .NET Core 5.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
dotnet-version: |
3.1.x
5.0.x
6.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -59,8 +55,9 @@ jobs:
working-directory: src
run: |
dotnet tool install -g dotnet-format --version 6.0.243104 --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
dotnet format --check --fix-whitespace || (echo "Run 'dotnet format' to fix formatting issues" && exit 1)
dotnet format --check -v diag --fix-style warn --fix-analyzers warn || (echo "Run 'dotnet format' to fix formatting issues" && exit 1)
dotnet format --no-restore --verify-no-changes -v diag --severity warn whitespace || (echo "Run 'dotnet format' to fix whitespace issues" && exit 1)
dotnet format --no-restore --verify-no-changes -v diag --severity warn analyzers || (echo "Run 'dotnet format' to fix analyzers issues" && exit 1)
dotnet format --no-restore --verify-no-changes -v diag --severity warn style || (echo "Run 'dotnet format' to fix style issues" && exit 1)
- name: Build solution [Release]
working-directory: src
run: dotnet build --no-restore -c Release -p:GraphQLTestVersion=${{ matrix.graphqlversion }}
Expand Down
2 changes: 1 addition & 1 deletion src/BasicSample/BasicSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5</TargetFramework>
<TargetFramework>net6</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/BasicSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public class Query
/// Resolver for 'Query.viewer' field.
/// </summary>
[GraphQLAuthorize("AdminPolicy")]
public User Viewer() => new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" };
public User Viewer() => new() { Id = Guid.NewGuid().ToString(), Name = "Quinn" };

/// <summary>
/// Resolver for 'Query.users' field.
/// </summary>
public List<User> Users() => new List<User> { new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" } };
public List<User> Users() => new() { new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" } };
}

/// <summary>
Expand Down
13 changes: 6 additions & 7 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<VersionPrefix>5.0.0-preview</VersionPrefix>
<LangVersion>8.0</LangVersion>
<LangVersion>latest</LangVersion>
<Authors>Joe McBride</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo.64x64.png</PackageIcon>
Expand All @@ -17,14 +17,13 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Nullable>enable</Nullable>
<PackageReadmeFile Condition="'$(IsPackable)' == 'true'">README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\assets\logo.64x64.png" Pack="true" PackagePath="\" Condition="'$(IsPackable)' == 'true'" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" Condition="'$(IsPackable)' == 'true'"/>
<ItemGroup Condition="'$(IsPackable)' == 'true'">
<None Include="..\..\assets\logo.64x64.png" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="../Tests.props" />

<PropertyGroup>
<TargetFramework>net5</TargetFramework>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void issue5_with_fragment_should_fail()
{
config.Query = "query a { article { ...frag } } query b { article { ...frag } } fragment frag on Article { content }";
config.Schema = TypedSchema();
config.ValidateResult = result => result.Errors.Single(x => x.Message == $"You are not authorized to run this query.\nRequired claim 'admin' is not present.");
config.ValidateResult = result => _ = result.Errors.Single(x => x.Message == $"You are not authorized to run this query.\nRequired claim 'admin' is not present.");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="../Tests.props" />

<PropertyGroup>
<TargetFrameworks>net5;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6;net5;netcoreapp3.1</TargetFrameworks>
<GraphQLTestVersion>5.0.0-preview-362</GraphQLTestVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL.Authorization/AuthorizationPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GraphQL.Authorization
/// </summary>
public class AuthorizationPolicy : IAuthorizationPolicy
{
private readonly List<IAuthorizationRequirement> _requirements = new List<IAuthorizationRequirement>();
private readonly List<IAuthorizationRequirement> _requirements = new();

/// <summary>
/// Creates a policy with a set of specified requirements.
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.Authorization/AuthorizationPolicyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace GraphQL.Authorization
/// </summary>
public class AuthorizationPolicyBuilder
{
private readonly List<IAuthorizationRequirement> _requirements = new List<IAuthorizationRequirement>();
private readonly List<IAuthorizationRequirement> _requirements = new();

/// <summary>
/// Build authorization policy.
/// </summary>
/// <returns>Created policy.</returns>
public AuthorizationPolicy Build() => new AuthorizationPolicy(_requirements);
public AuthorizationPolicy Build() => new(_requirements);

/// <summary>
/// Adds <see cref="ClaimAuthorizationRequirement"/> with the specified claim type.
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.Authorization/AuthorizationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GraphQL.Authorization
public class AuthorizationResult
{
// allocation optimization for green path
private static readonly AuthorizationResult _success = new AuthorizationResult { Succeeded = true };
private static readonly AuthorizationResult _success = new() { Succeeded = true };

/// <summary>
/// Is the authorization result successful?
Expand All @@ -31,6 +31,6 @@ public class AuthorizationResult
/// </summary>
/// <param name="errors">A set of authorization errors.</param>
/// <returns>Instance of <see cref="AuthorizationResult"/>.</returns>
public static AuthorizationResult Fail(IEnumerable<string> errors) => new AuthorizationResult { Errors = errors };
public static AuthorizationResult Fail(IEnumerable<string> errors) => new() { Errors = errors };
}
}
2 changes: 1 addition & 1 deletion src/GraphQL.Authorization/AuthorizationValidationRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Visit(INode node, int _)

new MatchingNodeVisitor<VariableReference>((variableRef, context) =>
{
if (!(context.TypeInfo.GetArgument()?.ResolvedType?.GetNamedType() is IComplexGraphType variableType))
if (context.TypeInfo.GetArgument()?.ResolvedType?.GetNamedType() is not IComplexGraphType variableType || ShouldBeSkipped(actualOperation, context))
return;

CheckAuth(variableRef, variableType, userContext, context, operationType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GraphQL.Authorization
/// </summary>
public class AuthenticatedUserRequirement : IAuthorizationRequirement
{
internal static readonly AuthenticatedUserRequirement Instance = new AuthenticatedUserRequirement();
internal static readonly AuthenticatedUserRequirement Instance = new();

/// <inheritdoc />
public Task Authorize(AuthorizationContext context)
Expand Down
4 changes: 2 additions & 2 deletions src/Harness/GraphQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class Query
/// Resolver for 'Query.viewer' field.
/// </summary>
[GraphQLAuthorize("AdminPolicy")]
public User Viewer() => new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" };
public User Viewer() => new() { Id = Guid.NewGuid().ToString(), Name = "Quinn" };

/// <summary>
/// Resolver for 'Query.users' field.
/// </summary>
public List<User> Users() => new List<User> { new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" } };
public List<User> Users() => new() { new User { Id = Guid.NewGuid().ToString(), Name = "Quinn" } };
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Harness/Harness.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net5;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6;net5;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down