Skip to content

Commit

Permalink
Fixed Warnings (#6661)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Nov 2, 2023
1 parent 4680c84 commit 2453428
Show file tree
Hide file tree
Showing 93 changed files with 2,101 additions and 724 deletions.
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 @@ public OpaQueryRequest CreateRequest(AuthorizationContext context, AuthorizeDire
httpContext.Request.Headers,
httpContext.Request.Host.Value,
httpContext.Request.Method,
httpContext.Request.Path.Value,
httpContext.Request.Path.Value!,
httpContext.Request.Query,
httpContext.Request.Scheme);

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

var destination = new IPAndPort(
connection.LocalIpAddress.ToString(),
connection.LocalIpAddress!.ToString(),
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 @@ internal static IServiceCollection TryAddTimespanProvider(
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>();

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 @@ public static IRequestExecutorBuilder AddDiagnosticEventListener<T>(
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>());
}
else if (typeof(T).IsDefined(typeof(DiagnosticEventSourceAttribute), true))
{
Expand All @@ -61,7 +61,7 @@ public static IRequestExecutorBuilder AddDiagnosticEventListener<T>(
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>());
}
}
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

0 comments on commit 2453428

Please sign in to comment.