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

Fixed Warnings #6661

Merged
merged 6 commits into from
Nov 2, 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
17 changes: 10 additions & 7 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<Project>

<PropertyGroup>
<IsMacOsArm Condition="'$(NETCoreSdkPortableRuntimeIdentifier)' == 'osx-arm64'">true</IsMacOsArm>
</PropertyGroup>

<PropertyGroup>
<LangVersion>preview</LangVersion>
<Version Condition="$(Version) == ''">0.0.0</Version>
<NoWarn>$(NoWarn);CS0436;RS0026;RS0027;RS0041</NoWarn>
<NoWarn>$(NoWarn);CS0436;RS0026;RS0027;RS0041;AD0001;CS1591;NU5104;NU5128;NU5501</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'debug'">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<PropertyGroup Condition="'$(Configuration)' == 'release'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;NU5104</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/GreenDonut/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/HotChocolate/ApolloFederation/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
httpContext.Request.Headers,
httpContext.Request.Host.Value,
httpContext.Request.Method,
httpContext.Request.Path.Value,
httpContext.Request.Path.Value!,

Check warning on line 32 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Possible null reference argument for parameter 'path' in 'OriginalRequest.OriginalRequest(IHeaderDictionary headers, string host, string method, string path, IEnumerable<KeyValuePair<string, StringValues>>? query, string scheme)'.

Check warning on line 32 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View check run for this annotation

Codecov / codecov/patch

src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs#L32

Added line #L32 was not covered by tests
httpContext.Request.Query,
httpContext.Request.Scheme);

var source = new IPAndPort(
connection.RemoteIpAddress.ToString(),
connection.RemoteIpAddress!.ToString(),

Check warning on line 37 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Dereference of a possibly null reference.

Check warning on line 37 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View check run for this annotation

Codecov / codecov/patch

src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs#L37

Added line #L37 was not covered by tests
connection.RemotePort);

var destination = new IPAndPort(
connection.LocalIpAddress.ToString(),
connection.LocalIpAddress!.ToString(),

Check warning on line 41 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Dereference of a possibly null reference.

Check warning on line 41 in src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs

View check run for this annotation

Codecov / codecov/patch

src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/Request/DefaultQueryRequestFactory.cs#L41

Added line #L41 was not covered by tests
connection.LocalPort);

return new OpaQueryRequest(policy, originalRequest, source, destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace HotChocolate.AspNetCore;

[Serializable]
public class GraphQLRequestException : GraphQLException
{
public GraphQLRequestException(string message)
Expand All @@ -25,17 +24,4 @@ public GraphQLRequestException(IEnumerable<IError> errors)
: base(errors)
{
}

#if NET8_0_OR_GREATER
[Obsolete(
"This API supports obsolete formatter-based serialization. " +
"It should not be called or extended by application code.",
true)]
#endif
protected GraphQLRequestException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void StartOperationBatchRequest(
/// <param name="context">
/// The <see cref="HttpContext"/>.
/// </param>
/// <param name="errors">
/// <param name="exception">
/// The <see cref="Exception"/>.
/// </param>
void WebSocketSessionError(HttpContext context, Exception exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected async Task<WebSocket> ConnectToServerAsync(
protected static WebSocketClient CreateWebSocketClient(TestServer testServer)
{
var client = testServer.CreateWebSocketClient();
client.ConfigureRequest = r => r.Headers.Add("Sec-WebSocket-Protocol", "graphql-ws");
client.ConfigureRequest = r => r.Headers.SecWebSocketProtocol = "graphql-ws";
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ protected async Task<WebSocket> ConnectToServerAsync(
protected static WebSocketClient CreateWebSocketClient(TestServer testServer)
{
var client = testServer.CreateWebSocketClient();
client.ConfigureRequest = r => r.Headers.Add(
"Sec-WebSocket-Protocol",
WellKnownProtocols.GraphQL_Transport_WS);
client.ConfigureRequest = r => r.Headers.SecWebSocketProtocol = WellKnownProtocols.GraphQL_Transport_WS;
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Task Connect_With_Invalid_Protocol()
using var testServer = CreateStarWarsServer();
var client = testServer.CreateWebSocketClient();

client.ConfigureRequest = r => r.Headers.Add("Sec-WebSocket-Protocol", "foo");
client.ConfigureRequest = r => r.Headers.SecWebSocketProtocol = "foo";

// act
var socket = await client.ConnectAsync(SubscriptionUri, ct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public Task Connect_With_Invalid_Protocol()
var client = testServer.CreateWebSocketClient();

// act
client.ConfigureRequest = r => r.Headers.Add("Sec-WebSocket-Protocol", "foo");
client.ConfigureRequest = r => r.Headers.SecWebSocketProtocol = "foo";
using var socket = await client.ConnectAsync(SubscriptionUri, ct);

// assert
Expand Down
3 changes: 2 additions & 1 deletion src/HotChocolate/AspNetCore/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Warn>0</Warn>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AzureHeaderDictionary(HttpResponse response, HttpResponseData responseDat

public void Add(KeyValuePair<string, StringValues> item)
{
_response.Headers.Add(item.Key, item.Value);
_response.Headers.Append(item.Key, item.Value);
_responseData.Headers.Add(item.Key, (IEnumerable<string>)item.Value);
}

Expand Down Expand Up @@ -52,7 +52,7 @@ public bool Remove(KeyValuePair<string, StringValues> item)

public void Add(string key, StringValues value)
{
_response.Headers.Add(key, value);
_response.Headers.Append(key, value);
_responseData.Headers.Add(key, (IEnumerable<string>)value);
}

Expand Down
3 changes: 2 additions & 1 deletion src/HotChocolate/AzureFunctions/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<Warn>0</Warn>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/HotChocolate/Caching/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<Warn>0</Warn>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
16 changes: 0 additions & 16 deletions src/HotChocolate/Core/src/Abstractions/Execution/QueryException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace HotChocolate.Execution;

[Serializable]
public class QueryException
: GraphQLException
{
Expand All @@ -28,17 +25,4 @@ public QueryException(IEnumerable<IError> errors)
: base(errors)
{
}

#if NET8_0_OR_GREATER
[Obsolete(
"This API supports obsolete formatter-based serialization. " +
"It should not be called or extended by application code.",
true)]
#endif
protected QueryException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace HotChocolate.Execution;

[Serializable]
public class QueryRequestBuilderException : Exception
{
public QueryRequestBuilderException() { }
Expand All @@ -12,15 +11,4 @@ public QueryRequestBuilderException(string message)

public QueryRequestBuilderException(string message, Exception inner)
: base(message, inner) { }

#if NET8_0_OR_GREATER
[Obsolete(
"This API supports obsolete formatter-based serialization. " +
"It should not be called or extended by application code.",
true)]
#endif
protected QueryRequestBuilderException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
18 changes: 1 addition & 17 deletions src/HotChocolate/Core/src/Abstractions/GraphQLException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#pragma warning disable RCS1194
#pragma warning disable RCS1194

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace HotChocolate;

[Serializable]
public class GraphQLException : Exception
{
public GraphQLException(string message)
Expand Down Expand Up @@ -46,19 +44,5 @@ public GraphQLException(string message, Exception innerException)
};
}

#if NET8_0_OR_GREATER
[Obsolete(
"This API supports obsolete formatter-based serialization. " +
"It should not be called or extended by application code.",
true)]
#endif
protected GraphQLException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
Errors = Array.Empty<IError>();
}

public IReadOnlyList<IError> Errors { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ public Task<IExecutionResult> ExecuteAsync(
/// <param name="requestBatch">
/// The GraphQL request batch.
/// </param>
/// <param name="allowParallelExecution">
/// Defines if the executor is allowed to execute the batch in parallel.
/// </param>
/// <param name="cancellationToken">
/// The cancellation token.
/// </param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
return services;
}

public static T GetApplicationService<T>(this IServiceProvider services) =>
services.GetApplicationServices().GetRequiredService<T>();
public static T GetApplicationService<T>(this IServiceProvider services) where T : notnull
=> services.GetApplicationServices().GetRequiredService<T>();

Check warning on line 51 in src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

The type 'T' cannot be used as type parameter 'T' in the generic type or method 'ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider)'. Nullability of type argument 'T' doesn't match 'notnull' constraint.

Check warning on line 51 in src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs

View workflow job for this annotation

GitHub Actions / CodeQL

The type 'T' cannot be used as type parameter 'T' in the generic type or method 'ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider)'. Nullability of type argument 'T' doesn't match 'notnull' constraint.

Check warning on line 51 in src/HotChocolate/Core/src/Execution/DependencyInjection/InternalSchemaServiceCollectionExtensions.cs

View workflow job for this annotation

GitHub Actions / CodeQL

The type 'T' cannot be used as type parameter 'T' in the generic type or method 'ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider)'. Nullability of type argument 'T' doesn't match 'notnull' constraint.

public static IServiceProvider GetApplicationServices(this IServiceProvider services) =>
services.GetRequiredService<IApplicationServiceProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
else if (typeof(IDataLoaderDiagnosticEventListener).IsAssignableFrom(typeof(T)))
{
builder.Services.TryAddSingleton<T>();
builder.Services.AddSingleton(s => (IDataLoaderDiagnosticEventListener)s.GetService<T>());
builder.Services.AddSingleton(s => (IDataLoaderDiagnosticEventListener)s.GetRequiredService<T>());

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

The type 'GreenDonut.IDataLoaderDiagnosticEventListener?' cannot be used as type parameter 'TService' in the generic type or method 'ServiceCollectionServiceExtensions.AddSingleton<TService>(IServiceCollection, Func<IServiceProvider, TService>)'. Nullability of type argument 'GreenDonut.IDataLoaderDiagnosticEventListener?' doesn't match 'class' constraint.

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Converting null literal or possible null value to non-nullable type.

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Nullability of reference types in return type of 'lambda expression' doesn't match the target delegate 'Func<IServiceProvider, IDataLoaderDiagnosticEventListener?>' (possibly because of nullability attributes).

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

The type 'GreenDonut.IDataLoaderDiagnosticEventListener?' cannot be used as type parameter 'TService' in the generic type or method 'ServiceCollectionServiceExtensions.AddSingleton<TService>(IServiceCollection, Func<IServiceProvider, TService>)'. Nullability of type argument 'GreenDonut.IDataLoaderDiagnosticEventListener?' doesn't match 'class' constraint.

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

Converting null literal or possible null value to non-nullable type.

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

Nullability of reference types in return type of 'lambda expression' doesn't match the target delegate 'Func<IServiceProvider, IDataLoaderDiagnosticEventListener?>' (possibly because of nullability attributes).

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

The type 'GreenDonut.IDataLoaderDiagnosticEventListener?' cannot be used as type parameter 'TService' in the generic type or method 'ServiceCollectionServiceExtensions.AddSingleton<TService>(IServiceCollection, Func<IServiceProvider, TService>)'. Nullability of type argument 'GreenDonut.IDataLoaderDiagnosticEventListener?' doesn't match 'class' constraint.

Check warning on line 54 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

Converting null literal or possible null value to non-nullable type.
}
else if (typeof(T).IsDefined(typeof(DiagnosticEventSourceAttribute), true))
{
Expand All @@ -61,7 +61,7 @@
typeof(T).GetCustomAttributes(typeof(DiagnosticEventSourceAttribute), true))
{
var listener = ((DiagnosticEventSourceAttribute)attribute).Listener;
builder.Services.AddSingleton(listener, s => s.GetService<T>());
builder.Services.AddSingleton(listener, s => s.GetRequiredService<T>());

Check warning on line 64 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / Merge and Upload Coverage

Possible null reference return.

Check warning on line 64 in src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.Instrumentation.cs

View workflow job for this annotation

GitHub Actions / CodeQL

Possible null reference return.
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public static IRequestExecutorBuilder AddResolver(
/// Adds a custom parameter expression builder to the resolver compiler.
/// </summary>
/// <param name="builder">
/// The <see cref="IResolverCompilerBuilder"/>.
/// The <see cref="IResolverCompiler"/>.
/// </param>
/// <param name="expression">
/// A expression that resolves the data for the custom parameter.
Expand All @@ -569,7 +569,7 @@ public static IRequestExecutorBuilder AddResolver(
/// The parameter result type.
/// </typeparam>
/// <returns>
/// An <see cref="IResolverCompilerBuilder"/> that can be used to configure to
/// An <see cref="IResolverCompiler"/> that can be used to configure to
/// chain in more configuration.
/// </returns>
public static IRequestExecutorBuilder AddParameterExpressionBuilder<T>(
Expand Down
Loading
Loading