From e0152e8cb6fbd9f0e533a889fd561c937b142537 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Fri, 31 May 2024 17:11:57 +0200 Subject: [PATCH 1/3] Cleanup Build --- .editorconfig | 1 + .vscode/settings.json | 3 - .vscode/tasks.json | 41 ++++++- src/Directory.Build.props | 6 + .../Directives/ComposeDirectiveTests.cs | 2 + .../ServiceCollectionExtensionTests.cs | 2 +- .../src/Caching/CacheControlAttribute.cs | 3 + .../DiagnosticEventSourceAttribute.cs | 1 + .../Execution/IExecutionResult.cs | 2 +- .../Core/src/Execution/IRequestExecutor.cs | 1 - .../Extensions/GetDataLoaderAttribute.cs | 3 +- .../Subscriptions.Postgres/PostgresChannel.cs | 2 +- .../ResilientNpgsqlConnection.cs | 4 +- .../Extensions/UsePagingAttribute.cs | 1 + .../InputObjectTypeValidationRule.cs | 6 +- .../Types/Types/Scalars/Iso8601Duration.cs | 14 +-- .../HotChocolate.Types.Analyzers.Tests.csproj | 68 +++++------ .../Types.Analyzers.Tests/___DemoCode.txt | 109 ++++++++++++++++++ .../PagingObjectFieldDescriptorExtensions.cs | 4 +- ...ingObjectFieldDescriptorExtensionsTests.cs | 61 +++++----- .../Validation/TypeValidationTestBase.cs | 2 +- .../Resolvers/ResolverTaskNullTests.cs | 4 +- .../Conventions/DefaultTypeInspectorTests.cs | 16 +-- .../Types.Tests/Types/InterfaceTypeTests.cs | 10 +- .../Types/ObjectTypeExtensionTests.cs | 4 + .../test/Types.Tests/Types/ObjectTypeTests.cs | 4 +- .../Types/Relay/NodeResolverTests.cs | 3 + ...erface_Issue_3577_Inheritance_Control.snap | 4 +- .../SortTypeAttributeTests.cs | 4 +- .../IFusionDiagnosticEventListener.cs | 6 +- .../Language/src/Language.Utf8/TokenHelper.cs | 6 +- .../src/Language.Utf8/TokenPrinter.cs | 2 +- .../Utf8GraphQLParser.Operations.cs | 2 +- .../Utf8GraphQLParser.TypeDefinition.cs | 4 +- .../Utf8GraphQLParser.Utilities.cs | 2 +- .../Language.Utf8/Utf8GraphQLParser.Values.cs | 10 +- .../src/Language.Utf8/Utf8GraphQLParser.cs | 2 +- .../Utf8GraphQLRequestParser.Response.cs | 4 +- .../Utf8GraphQLRequestParser.Syntax.cs | 4 +- .../Utf8GraphQLRequestParser.Utilities.cs | 10 +- .../Utf8GraphQLRequestParser.Values.cs | 6 +- .../Handlers/RavenFilterExpressionBuilder.cs | 2 +- .../Spatial/src/Types/WellKnownFields.cs | 2 +- .../Client/src/Core/OperationExecutor.cs | 26 ++++- .../src/Core/Serialization/Iso8601Duration.cs | 14 +-- .../src/Core/StorelessOperationExecutor.cs | 26 ++++- .../Builders/XmlCommentBuilder.cs | 6 +- .../CodeGeneration/ICSharpSyntaxGenerator.cs | 5 +- 48 files changed, 357 insertions(+), 167 deletions(-) create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/___DemoCode.txt diff --git a/.editorconfig b/.editorconfig index 8a4fbe864dc..6655a6828d9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -97,6 +97,7 @@ dotnet_style_require_accessibility_modifiers = always # Public API dotnet_diagnostic.rs0016.severity = warning +dotnet_diagnostic.rcs1194.severity = none # Require braces on all control statements resharper_braces_for_for = required diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c090665eab..726df2eb6dd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,8 +13,5 @@ "*.targets": "xml", "*.tasks": "xml" }, - "cSpell.words": [ - "Nats" - ], "dotnet.defaultSolution": "src/All.sln" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a76f831520f..b85b3ea8b9d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -17,22 +17,53 @@ } }, { - "label": "Build entire repository (Debug)", + "label": "Build src/All.sln", "command": "dotnet", "type": "shell", "args": [ "build", "src/All.sln", - // Ask dotnet build to generate full paths for file names. "/property:GenerateFullPaths=true", - // Do not generate summary otherwise it leads to duplicate errors in Problems panel - "/consoleloggerparameters:NoSummary", + "/consoleloggerparameters:NoSummary" ], "group": "build", "presentation": { "reveal": "silent" }, "problemMatcher": "$msCompile" - } + }, + { + "label": "Build src/HotChocolate/Core/HotChocolate.Core.sln", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + "src/HotChocolate/Core/HotChocolate.Core.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Test src/All.sln", + "command": "dotnet", + "type": "shell", + "args": [ + "test", + "src/All.sln", + "--verbosity q", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, ] } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0348169fee2..59a4de6a518 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -64,4 +64,10 @@ + + + + + + diff --git a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/Directives/ComposeDirectiveTests.cs b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/Directives/ComposeDirectiveTests.cs index d3c9bb6d070..61912a2b268 100644 --- a/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/Directives/ComposeDirectiveTests.cs +++ b/src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/Directives/ComposeDirectiveTests.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using CookieCrumble; using HotChocolate.ApolloFederation.Types; @@ -45,6 +46,7 @@ public class Address [DirectiveType(DirectiveLocation.FieldDefinition)] public sealed class Custom; + [AttributeUsage(AttributeTargets.All, AllowMultiple = false)] public sealed class CustomDirectiveAttribute() : DirectiveAttribute(new Custom()); } diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Extensions/ServiceCollectionExtensionTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Extensions/ServiceCollectionExtensionTests.cs index b2fd732af2b..6aad582e5e2 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Extensions/ServiceCollectionExtensionTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Extensions/ServiceCollectionExtensionTests.cs @@ -2,7 +2,7 @@ namespace Microsoft.Extensions.DependencyInjection; -public class ServiceCollectionExtensionTests +public static class ServiceCollectionExtensionTests { [Fact] public static void AddHttpRequestSerializer_OfT() diff --git a/src/HotChocolate/Caching/src/Caching/CacheControlAttribute.cs b/src/HotChocolate/Caching/src/Caching/CacheControlAttribute.cs index 387dddcda0e..06616d587ec 100644 --- a/src/HotChocolate/Caching/src/Caching/CacheControlAttribute.cs +++ b/src/HotChocolate/Caching/src/Caching/CacheControlAttribute.cs @@ -23,6 +23,9 @@ public CacheControlAttribute() { } + /// + /// Initializes a new instance of the class with the specified maximum age. + /// /// /// The maximum time, in seconds, the resource can be cached. /// diff --git a/src/HotChocolate/Core/src/Abstractions/DiagnosticEventSourceAttribute.cs b/src/HotChocolate/Core/src/Abstractions/DiagnosticEventSourceAttribute.cs index 52988c3fcd9..583206d25ae 100644 --- a/src/HotChocolate/Core/src/Abstractions/DiagnosticEventSourceAttribute.cs +++ b/src/HotChocolate/Core/src/Abstractions/DiagnosticEventSourceAttribute.cs @@ -6,6 +6,7 @@ namespace HotChocolate; /// This attribute can be used by custom diagnostic event listeners /// to specify the source to which a listener shall be bound to. /// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class DiagnosticEventSourceAttribute : Attribute { /// diff --git a/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs index d84f499caeb..db130cd781a 100644 --- a/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs +++ b/src/HotChocolate/Core/src/Abstractions/Execution/IExecutionResult.cs @@ -32,4 +32,4 @@ public interface IExecutionResult : IAsyncDisposable /// A cleanup task that will be executed when this result is disposed. /// void RegisterForCleanup(Func clean); -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs b/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs index 5171b9879e5..89ba6f7d29c 100644 --- a/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs +++ b/src/HotChocolate/Core/src/Execution/IRequestExecutor.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; diff --git a/src/HotChocolate/Core/src/Fetching/Extensions/GetDataLoaderAttribute.cs b/src/HotChocolate/Core/src/Fetching/Extensions/GetDataLoaderAttribute.cs index 0ddc205b3aa..ce2e6396993 100644 --- a/src/HotChocolate/Core/src/Fetching/Extensions/GetDataLoaderAttribute.cs +++ b/src/HotChocolate/Core/src/Fetching/Extensions/GetDataLoaderAttribute.cs @@ -2,4 +2,5 @@ namespace HotChocolate.Types; -internal sealed class GetDataLoaderAttribute : Attribute; \ No newline at end of file +[AttributeUsage(AttributeTargets.All, AllowMultiple = false)] +internal sealed class GetDataLoaderAttribute : Attribute; diff --git a/src/HotChocolate/Core/src/Subscriptions.Postgres/PostgresChannel.cs b/src/HotChocolate/Core/src/Subscriptions.Postgres/PostgresChannel.cs index cbeec04ed5c..c7dc49753ff 100644 --- a/src/HotChocolate/Core/src/Subscriptions.Postgres/PostgresChannel.cs +++ b/src/HotChocolate/Core/src/Subscriptions.Postgres/PostgresChannel.cs @@ -175,7 +175,7 @@ public async ValueTask DisposeAsync() command.CommandText = $"""UNLISTEN "{_channelName}" """; await command.ExecuteNonQueryAsync(); } - catch (Exception) + catch { // we swallow any exception because we dont care about the connection state } diff --git a/src/HotChocolate/Core/src/Subscriptions.Postgres/ResilientNpgsqlConnection.cs b/src/HotChocolate/Core/src/Subscriptions.Postgres/ResilientNpgsqlConnection.cs index adcfed606f2..cc26c5dd940 100644 --- a/src/HotChocolate/Core/src/Subscriptions.Postgres/ResilientNpgsqlConnection.cs +++ b/src/HotChocolate/Core/src/Subscriptions.Postgres/ResilientNpgsqlConnection.cs @@ -100,7 +100,7 @@ private async Task Disconnect(CancellationToken cancellationToken) { await _onDisconnect(cancellationToken); } - catch (Exception) + catch { // on disconnect we ignore all exceptions } @@ -108,7 +108,7 @@ private async Task Disconnect(CancellationToken cancellationToken) await Connection.DisposeAsync(); } } - catch (Exception) + catch { // on disconnect we ignore all exceptions } diff --git a/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/UsePagingAttribute.cs b/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/UsePagingAttribute.cs index 3a6f434b107..eecff1e41cf 100644 --- a/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/UsePagingAttribute.cs +++ b/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/UsePagingAttribute.cs @@ -10,6 +10,7 @@ namespace HotChocolate.Types; /// /// This attribute adds the cursor paging middleware to the annotated method or property. /// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false)] public sealed class UsePagingAttribute : DescriptorAttribute { private string? _connectionName; diff --git a/src/HotChocolate/Core/src/Types/Configuration/Validation/InputObjectTypeValidationRule.cs b/src/HotChocolate/Core/src/Types/Configuration/Validation/InputObjectTypeValidationRule.cs index 64cb6bb5b8d..d980f21cb30 100644 --- a/src/HotChocolate/Core/src/Types/Configuration/Validation/InputObjectTypeValidationRule.cs +++ b/src/HotChocolate/Core/src/Types/Configuration/Validation/InputObjectTypeValidationRule.cs @@ -42,7 +42,7 @@ public void Validate( EnsureFieldNamesAreValid(inputType, errors); EnsureOneOfFieldsAreValid(inputType, errors, ref names); EnsureFieldDeprecationIsValid(inputType, errors); - TryReachCycleRecursively(cycleValidationContext, inputType); + TryReachCycleRecursively(ref cycleValidationContext, inputType); cycleValidationContext.CycleStartIndex.Clear(); } @@ -58,7 +58,7 @@ private ref struct CycleValidationContext // https://github.com/IvanGoncharov/graphql-js/blob/408bcda9c88df85e039f5d072011b1cb465fe830/src/type/validate.js#L535 private static void TryReachCycleRecursively( - in CycleValidationContext context, + ref CycleValidationContext context, InputObjectType type) { if (!context.Visited.Add(type)) @@ -85,7 +85,7 @@ private static void TryReachCycleRecursively( } else { - TryReachCycleRecursively(context, inputObjectType); + TryReachCycleRecursively(ref context, inputObjectType); } context.FieldPath.Pop(); } diff --git a/src/HotChocolate/Core/src/Types/Types/Scalars/Iso8601Duration.cs b/src/HotChocolate/Core/src/Types/Types/Scalars/Iso8601Duration.cs index 21a74123bb5..bc99300e48a 100644 --- a/src/HotChocolate/Core/src/Types/Types/Scalars/Iso8601Duration.cs +++ b/src/HotChocolate/Core/src/Types/Types/Scalars/Iso8601Duration.cs @@ -359,13 +359,13 @@ internal static bool TryParse(string s, out TimeSpan? result) return false; } - /// Helper method that constructs an integer from leading digits starting at s[offset]. - /// "offset" is updated to contain an offset just beyond the last digit. - /// The number of digits consumed is returned in cntDigits. - /// The integer is returned (0 if no digits). If the digits cannot fit into an Int32: - /// 1. If eatDigits is true, then additional digits will be silently discarded - /// (don't count towards numDigits) - /// 2. If eatDigits is false, an overflow exception is thrown + // Helper method that constructs an integer from leading digits starting at s[offset]. + // "offset" is updated to contain an offset just beyond the last digit. + // The number of digits consumed is returned in cntDigits. + // The integer is returned (0 if no digits). If the digits cannot fit into an Int32: + // 1. If eatDigits is true, then additional digits will be silently discarded + // (don't count towards numDigits) + // 2. If eatDigits is false, an overflow exception is thrown private static bool TryParseDigits(string s, ref int offset, bool eatDigits, out int result, out int numDigits) { var offsetStart = offset; diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/HotChocolate.Types.Analyzers.Tests.csproj b/src/HotChocolate/Core/test/Types.Analyzers.Tests/HotChocolate.Types.Analyzers.Tests.csproj index 2a8ac1c418c..d8f49264f3b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/HotChocolate.Types.Analyzers.Tests.csproj +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/HotChocolate.Types.Analyzers.Tests.csproj @@ -1,34 +1,34 @@ - - - - net8.0 - enable - - false - $(InterceptorsPreviewNamespaces);HotChocolate.Execution.Generated - - - - - - HotChocolate.Types.Analyzers.Tests - HotChocolate.Types - - - - - - - - - - - Always - - - Always - - - - + + + + net8.0 + enable + + false + $(InterceptorsPreviewNamespaces);HotChocolate.Execution.Generated + + true + $(BaseIntermediateOutputPath)\GeneratedFiles + + + + HotChocolate.Types.Analyzers.Tests + HotChocolate.Types + + + + + + + + + + + Always + + + Always + + + + diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/___DemoCode.txt b/src/HotChocolate/Core/test/Types.Analyzers.Tests/___DemoCode.txt new file mode 100644 index 00000000000..254cee1bd3a --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/___DemoCode.txt @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using HotChocolate.Resolvers; + +namespace HotChocolate.Types; + +internal static class Resolvers +{ + private readonly static ResolverInfo[] _resolverInfos = + [ + new ResolverInfo( + 0, + [new GenParameterInfo("id", typeof(string), []) ]) + ]; + private readonly static FieldResolverDelegate[] _fieldResolver = [Query_GetPersonById]; + private readonly static ParameterBinding[] _args_Query_GetPersonById = new ParameterBinding[1]; + private static bool _bindingsInitialized = false; + + public static void InitializeParameterBindings(IParameterBindingResolver parameterBindingResolver) + { + if (_bindingsInitialized) + { + return; + } + + foreach (var resolverInfo in _resolverInfos) + { + // we get the right binding collection for the resolver + var bindings = resolverInfo.Id switch + { + 1 => _args_Query_GetPersonById, + _ => throw new InvalidOperationException() + }; + + // next we resolve all bindings so that we can resolve the values for the resolver parameters. + for (var i = 0; i < resolverInfo.Parameters.Length; i++) + { + var parameter = resolverInfo.Parameters[i]; + bindings[i] = parameterBindingResolver.GetBinding(parameter); + } + } + } + + // example resolver + private static ValueTask Query_GetPersonById(IResolverContext context) + { + var args = MemoryMarshal.GetReference(_args_Query_GetPersonById.AsSpan()); + var arg0 = Unsafe.Add(ref args, 0).Resolve(context); + var result = PersonLastName.GetPersonById(arg0); + return new ValueTask(result); + } + + // generator proxies + public sealed class ResolverInfo(int id, ParameterInfo[] parameters) + { + public int Id { get; } = id; + + public ParameterInfo[] Parameters { get; } = parameters; + + public DescriptorAttributeInfo[] Attributes { get; } = []; + } + + public sealed class DescriptorAttributeInfo + { + public ICustomAttributeProvider Element { get; } + + public DescriptorAttribute Attribute { get; } + } + + public sealed class GenParameterInfo : ParameterInfo + { + public GenParameterInfo(string name, Type parameterType, CustomAttributeData[] customAttributes) + { + + } + + public override string? Name { get; } + + public override Type ParameterType => base.ParameterType; + + public override IEnumerable CustomAttributes => base.CustomAttributes; + + public override bool IsDefined(Type attributeType, bool inherit) + { + return base.IsDefined(attributeType, inherit); + } + } + + // this goes onto the core lib + public abstract class ParameterBinding + { + public abstract T Resolve(IResolverContext context); + } + + public sealed class ArgumentParameterBinding(string argumentName) : ParameterBinding + { + public override T Resolve(IResolverContext context) + => context.ArgumentValue(argumentName); + } + + public interface IParameterBindingResolver + { + ParameterBinding GetBinding(ParameterInfo parameter); + } +} diff --git a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/PagingObjectFieldDescriptorExtensions.cs b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/PagingObjectFieldDescriptorExtensions.cs index 61b06fcbe67..27a46175708 100644 --- a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/PagingObjectFieldDescriptorExtensions.cs +++ b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/PagingObjectFieldDescriptorExtensions.cs @@ -4,7 +4,7 @@ namespace HotChocolate.Types.Pagination; -public class PagingObjectFieldDescriptorExtensionsTests +public static class PagingObjectFieldDescriptorExtensionsTests { [Fact] public static void ObjectFieldDescriptor_UseOffsetPaging_Descriptor_Is_Null() @@ -37,4 +37,4 @@ public static void InterfaceFieldDescriptor_AddOffsetPagingArguments_Descriptor_ () => PagingObjectFieldDescriptorExtensions.AddPagingArguments( default(IInterfaceFieldDescriptor)!)); } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/OffsetPagingObjectFieldDescriptorExtensionsTests.cs b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/OffsetPagingObjectFieldDescriptorExtensionsTests.cs index 52cd6c9ffda..2c4d3bffb92 100644 --- a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/OffsetPagingObjectFieldDescriptorExtensionsTests.cs +++ b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/OffsetPagingObjectFieldDescriptorExtensionsTests.cs @@ -2,40 +2,39 @@ #nullable enable -namespace HotChocolate.Types.Pagination +namespace HotChocolate.Types.Pagination; + +public static class OffsetPagingObjectFieldDescriptorExtensionsTests { - public class OffsetPagingObjectFieldDescriptorExtensionsTests + [Fact] + public static void ObjectFieldDescriptor_UseOffsetPaging_Descriptor_Is_Null() { - [Fact] - public static void ObjectFieldDescriptor_UseOffsetPaging_Descriptor_Is_Null() - { - Assert.Throws( - () => OffsetPagingObjectFieldDescriptorExtensions.UseOffsetPaging( - default(IObjectFieldDescriptor)!)); - } + Assert.Throws( + () => OffsetPagingObjectFieldDescriptorExtensions.UseOffsetPaging( + default(IObjectFieldDescriptor)!)); + } - [Fact] - public static void ObjectFieldDescriptor_AddOffsetPagingArguments_Descriptor_Is_Null() - { - Assert.Throws( - () => OffsetPagingObjectFieldDescriptorExtensions.AddOffsetPagingArguments( - default(IObjectFieldDescriptor)!)); - } + [Fact] + public static void ObjectFieldDescriptor_AddOffsetPagingArguments_Descriptor_Is_Null() + { + Assert.Throws( + () => OffsetPagingObjectFieldDescriptorExtensions.AddOffsetPagingArguments( + default(IObjectFieldDescriptor)!)); + } - [Fact] - public static void InterfaceFieldDescriptor_UseOffsetPaging_Descriptor_Is_Null() - { - Assert.Throws( - () => OffsetPagingObjectFieldDescriptorExtensions.UseOffsetPaging( - default(IInterfaceFieldDescriptor)!)); - } + [Fact] + public static void InterfaceFieldDescriptor_UseOffsetPaging_Descriptor_Is_Null() + { + Assert.Throws( + () => OffsetPagingObjectFieldDescriptorExtensions.UseOffsetPaging( + default(IInterfaceFieldDescriptor)!)); + } - [Fact] - public static void InterfaceFieldDescriptor_AddOffsetPagingArguments_Descriptor_Is_Null() - { - Assert.Throws( - () => OffsetPagingObjectFieldDescriptorExtensions.AddOffsetPagingArguments( - default(IInterfaceFieldDescriptor)!)); - } + [Fact] + public static void InterfaceFieldDescriptor_AddOffsetPagingArguments_Descriptor_Is_Null() + { + Assert.Throws( + () => OffsetPagingObjectFieldDescriptorExtensions.AddOffsetPagingArguments( + default(IInterfaceFieldDescriptor)!)); } -} \ No newline at end of file +} diff --git a/src/HotChocolate/Core/test/Types.Tests/Configuration/Validation/TypeValidationTestBase.cs b/src/HotChocolate/Core/test/Types.Tests/Configuration/Validation/TypeValidationTestBase.cs index b5ef6801534..84a15d8a723 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Configuration/Validation/TypeValidationTestBase.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Configuration/Validation/TypeValidationTestBase.cs @@ -4,7 +4,7 @@ namespace HotChocolate.Configuration.Validation; -public class TypeValidationTestBase +public abstract class TypeValidationTestBase { public static void ExpectValid(string schema) { diff --git a/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverTaskNullTests.cs b/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverTaskNullTests.cs index 56fed83b3e0..2d722d12262 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverTaskNullTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Resolvers/ResolverTaskNullTests.cs @@ -69,7 +69,7 @@ public Task Case1(string name) { if (name is null) { - return null; + return null!; } return Task.FromResult(name); } @@ -81,7 +81,7 @@ public Task Case2(string name) { if (name is null) { - return null; + return null!; } return Task.FromResult(name); } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/DefaultTypeInspectorTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/DefaultTypeInspectorTests.cs index c8885e2dfc1..d51b8302b26 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/DefaultTypeInspectorTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/DefaultTypeInspectorTests.cs @@ -700,24 +700,24 @@ public string ShouldNotBeFound( public string ShouldBeFound( - [SomeAttribute] + [Some] object o) => null; } public class TaskObjectMethodWithTypeAttribute { - public Task ShouldNotBeFound() => null; + public Task ShouldNotBeFound() => null!; [GraphQLType(typeof(StringType))] - public Task ShouldBeFound() => null; + public Task ShouldBeFound() => null!; } public class TaskObjectMethodWithDescriptorAttribute { - public Task ShouldNotBeFound() => null; + public Task ShouldNotBeFound() => null!; - [SomeAttribute] - public Task ShouldBeFound() => null; + [Some] + public Task ShouldBeFound() => null!; } public class ValueTaskObjectMethodWithTypeAttribute @@ -736,8 +736,8 @@ public class ValueTaskObjectMethodWithDescriptorAttribute public ValueTask ShouldBeFound() => default; } - public sealed class SomeAttribute - : DescriptorAttribute + [AttributeUsage(AttributeTargets.All, AllowMultiple = false)] + public sealed class SomeAttribute : DescriptorAttribute { protected internal override void TryConfigure( IDescriptorContext context, diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/InterfaceTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/InterfaceTypeTests.cs index 5335341e61e..92f5c68ab6a 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/InterfaceTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/InterfaceTypeTests.cs @@ -532,7 +532,7 @@ public void AnnotationBased_Interface_Issue_3577_Inheritance_Control() { SchemaBuilder.New() .AddQueryType() - .AddType() + .AddType() .AddType() .Create() .Print() @@ -739,7 +739,7 @@ public async Task Ensure_Interface_Field_Is_Requested_When_Applying_NamingConven .Name("Query") .Field("foo") .Type>() - .Resolve(() => null)) + .Resolve(() => null!)) .AddResolver("Foo", "bar", x => 1) .ModifyOptions(o => o.StrictValidation = false) .BuildSchemaAsync() @@ -755,7 +755,7 @@ public async Task StripLeadingIFromInterface() .Name("Query") .Field("foo") .Type>() - .Resolve(() => null)) + .Resolve(() => null!)) .AddResolver("Foo", "bar", x => 1) .ModifyOptions(o => o.StrictValidation = false) .ModifyOptions(o => o.StripLeadingIFromInterface = true) @@ -886,12 +886,12 @@ public class Pet public string Name { get; set; } } - public class Canina : Pet + public class Canine : Pet { } [ObjectType] - public class Dog : Canina + public class Dog : Canine { } } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeExtensionTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeExtensionTests.cs index f0f6a52943d..9c978d85315 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeExtensionTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeExtensionTests.cs @@ -1,3 +1,5 @@ +#pragma warning disable RCS1102 // Make class static + using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -1146,3 +1148,5 @@ public class QueryExtensions public string Bar() => "baz"; } } + +#pragma warning restore RCS1102 // Make class static diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs index 163d835e968..ec057b184a4 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/ObjectTypeTests.cs @@ -1788,7 +1788,7 @@ public void Specify_Field_Type_With_SDL_Syntax() d => { d.Name("Query"); - d.Field("Foo").Type("String").Resolve(_ => null); + d.Field("Foo").Type("String").Resolve(_ => null!); }) .Create() .Print() @@ -1806,7 +1806,7 @@ public void Specify_Argument_Type_With_SDL_Syntax() d.Field("Foo") .Argument("a", t => t.Type("Int")) .Type("String") - .Resolve(_ => null); + .Resolve(_ => null!); }) .Create() .Print() diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeResolverTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeResolverTests.cs index 75ff8ae2245..c83a83fd7e8 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeResolverTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeResolverTests.cs @@ -1,3 +1,4 @@ +#pragma warning disable RCS1102 // Make class static using System.Threading.Tasks; using HotChocolate.Execution; using HotChocolate.Language; @@ -269,6 +270,7 @@ public class Entity2 [Node] [ExtendObjectType(typeof(Entity))] + public class EntityExtension { public static Entity GetEntity(string id) => new() { Name = id, }; @@ -297,3 +299,4 @@ public class EntityExtension4 public static Entity GetEntity(string id) => new() { Name = id, }; } } +#pragma warning restore RCS1102 // Make class static diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/InterfaceTypeTests.AnnotationBased_Interface_Issue_3577_Inheritance_Control.snap b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/InterfaceTypeTests.AnnotationBased_Interface_Issue_3577_Inheritance_Control.snap index bc905fe9000..d4e0f07c066 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/InterfaceTypeTests.AnnotationBased_Interface_Issue_3577_Inheritance_Control.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/InterfaceTypeTests.AnnotationBased_Interface_Issue_3577_Inheritance_Control.snap @@ -2,7 +2,7 @@ query: PetQuery } -interface Canina implements Pet { +interface Canine implements Pet { name: String } @@ -10,7 +10,7 @@ interface Pet { name: String } -type Dog implements Canina & Pet { +type Dog implements Canine & Pet { name: String } diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/SortTypeAttributeTests.cs b/src/HotChocolate/Data/test/Data.Sorting.Tests/SortTypeAttributeTests.cs index 835d2a42fec..1c3ef80e5ac 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/SortTypeAttributeTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/SortTypeAttributeTests.cs @@ -52,8 +52,8 @@ public class FooFields [SortFieldAttributeTest] public string Field { get; set; } = default!; } - public class GenericTypeSortAttribute - : DescriptorAttribute + [AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)] + public class GenericTypeSortAttribute : DescriptorAttribute { public static string TypeName { get; } = "ThisIsATest"; diff --git a/src/HotChocolate/Fusion/src/Core/Execution/Diagnostic/IFusionDiagnosticEventListener.cs b/src/HotChocolate/Fusion/src/Core/Execution/Diagnostic/IFusionDiagnosticEventListener.cs index 05c83fa6377..72323535c1c 100644 --- a/src/HotChocolate/Fusion/src/Core/Execution/Diagnostic/IFusionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion/src/Core/Execution/Diagnostic/IFusionDiagnosticEventListener.cs @@ -1,7 +1,3 @@ namespace HotChocolate.Fusion.Execution.Diagnostic; -/// -public interface IFusionDiagnosticEventListener : IFusionDiagnosticEvents -{ - -} +public interface IFusionDiagnosticEventListener : IFusionDiagnosticEvents; diff --git a/src/HotChocolate/Language/src/Language.Utf8/TokenHelper.cs b/src/HotChocolate/Language/src/Language.Utf8/TokenHelper.cs index f5715822537..65789129380 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/TokenHelper.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/TokenHelper.cs @@ -20,7 +20,7 @@ static TokenHelper() } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsDescription(in Utf8GraphQLReader reader) + public static bool IsDescription(ref Utf8GraphQLReader reader) { ref var searchSpace = ref MemoryMarshal.GetReference(_isString.AsSpan()); var index = (int)reader.Kind; @@ -28,7 +28,7 @@ public static bool IsDescription(in Utf8GraphQLReader reader) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsString(in Utf8GraphQLReader reader) + public static bool IsString(ref Utf8GraphQLReader reader) { ref var searchSpace = ref MemoryMarshal.GetReference(_isString.AsSpan()); var index = (int)reader.Kind; @@ -36,7 +36,7 @@ public static bool IsString(in Utf8GraphQLReader reader) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsScalarValue(in Utf8GraphQLReader reader) + public static bool IsScalarValue(ref Utf8GraphQLReader reader) { ref var searchSpace = ref MemoryMarshal.GetReference(_isScalar.AsSpan()); var index = (int)reader.Kind; diff --git a/src/HotChocolate/Language/src/Language.Utf8/TokenPrinter.cs b/src/HotChocolate/Language/src/Language.Utf8/TokenPrinter.cs index 0c2fea40a9a..cf0ddc6e5c6 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/TokenPrinter.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/TokenPrinter.cs @@ -31,7 +31,7 @@ internal static class TokenPrinter { TokenKind.Dot, "." }, }; - public static string Print(in Utf8GraphQLReader reader) + public static string Print(ref Utf8GraphQLReader reader) => _cachedStrings[reader.Kind]; public static string Print(TokenKind tokenKind) diff --git a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs index 5aee14e9822..7d2d97e6cb9 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs @@ -172,7 +172,7 @@ private SelectionSetNode ParseSelectionSet() CultureInfo.InvariantCulture, ParseMany_InvalidOpenToken, TokenKind.LeftBrace, - TokenPrinter.Print(in _reader))); + TokenPrinter.Print(ref _reader))); } var selections = new List(); diff --git a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.TypeDefinition.cs b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.TypeDefinition.cs index fc71219e504..490671a0b5d 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.TypeDefinition.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.TypeDefinition.cs @@ -16,7 +16,7 @@ public ref partial struct Utf8GraphQLParser /// private StringValueNode? ParseDescription() { - if (TokenHelper.IsDescription(in _reader)) + if (TokenHelper.IsDescription(ref _reader)) { return ParseStringLiteral(); } @@ -42,7 +42,7 @@ private SchemaDefinitionNode ParseSchemaDefinition() throw new SyntaxException(_reader, ParseMany_InvalidOpenToken, TokenKind.LeftBrace, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var operationTypeDefinitions = diff --git a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Utilities.cs b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Utilities.cs index 3f8ac36338d..915c8c4d15c 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Utilities.cs @@ -87,7 +87,7 @@ private string ExpectName() [MethodImpl(MethodImplOptions.AggressiveInlining)] private string ExpectString() { - if (TokenHelper.IsString(in _reader)) + if (TokenHelper.IsString(ref _reader)) { var value = _reader.GetString(); MoveNext(); diff --git a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Values.cs b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Values.cs index 88c2993f046..1a8a865785a 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Values.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Values.cs @@ -40,7 +40,7 @@ internal IValueNode ParseValueLiteral(bool isConstant) return ParseObject(isConstant); } - if (TokenHelper.IsScalarValue(in _reader)) + if (TokenHelper.IsScalarValue(ref _reader)) { return ParseScalarValue(); } @@ -91,7 +91,7 @@ private ListValueNode ParseList(bool isConstant) _reader, ParseMany_InvalidOpenToken, TokenKind.LeftBracket, - Print(in _reader)); + Print(ref _reader)); } var items = new List(); @@ -136,7 +136,7 @@ private ObjectValueNode ParseObject(bool isConstant) _reader, ParseMany_InvalidOpenToken, TokenKind.LeftBrace, - Print(in _reader)); + Print(ref _reader)); } var fields = new List(); @@ -170,7 +170,7 @@ private ObjectValueNode ParseObject(bool isConstant) [MethodImpl(MethodImplOptions.AggressiveInlining)] private IValueNode ParseScalarValue() { - if (TokenHelper.IsString(in _reader)) + if (TokenHelper.IsString(ref _reader)) { return ParseStringLiteral(); } @@ -178,7 +178,7 @@ private IValueNode ParseScalarValue() var start = Start(); var kind = _reader.Kind; - if (!TokenHelper.IsScalarValue(in _reader)) + if (!TokenHelper.IsScalarValue(ref _reader)) { throw new SyntaxException(_reader, Parser_InvalidScalarToken, _reader.Kind); } diff --git a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs index a2f9b44b932..eeb643c3000 100644 --- a/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs +++ b/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs @@ -89,7 +89,7 @@ public DocumentNode Parse() private IDefinitionNode ParseDefinition() { _description = null; - if (TokenHelper.IsDescription(in _reader)) + if (TokenHelper.IsDescription(ref _reader)) { _description = ParseDescription(); } diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Response.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Response.cs index edbc7faf026..f330714a0c4 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Response.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Response.cs @@ -46,7 +46,7 @@ private void ParseResponseObjectFieldSyntax( throw new SyntaxException(_reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var name = _reader.GetString(); @@ -65,7 +65,7 @@ private List ParseResponseList() throw new SyntaxException(_reader, ParseMany_InvalidOpenToken, TokenKind.LeftBracket, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var list = new List(); diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Syntax.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Syntax.cs index 83650935d61..7ff16b4bdc1 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Syntax.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Syntax.cs @@ -45,7 +45,7 @@ private ObjectFieldNode ParseObjectFieldSyntax() throw new SyntaxException(_reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var name = _reader.GetString(); @@ -64,7 +64,7 @@ private ListValueNode ParseListSyntax() throw new SyntaxException(_reader, ParseMany_InvalidOpenToken, TokenKind.LeftBracket, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var list = new List(); diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs index d1feeebfea1..e41d14c0141 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Utilities.cs @@ -47,7 +47,7 @@ public ref partial struct Utf8GraphQLRequestParser { case TokenKind.LeftBrace: return new[] { ParseVariablesObject(), }; - + case TokenKind.LeftBracket: var list = new List>(); _reader.Expect(TokenKind.LeftBracket); @@ -56,7 +56,7 @@ public ref partial struct Utf8GraphQLRequestParser { list.Add(ParseObject()); } - + _reader.Expect(TokenKind.RightBracket); return list; @@ -69,7 +69,7 @@ public ref partial struct Utf8GraphQLRequestParser throw ThrowHelper.ExpectedObjectOrNull(_reader); } } - + private IReadOnlyDictionary ParseVariablesObject() { switch (_reader.Kind) @@ -87,7 +87,7 @@ public ref partial struct Utf8GraphQLRequestParser _reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var name = _reader.GetString(); @@ -148,7 +148,7 @@ public ref partial struct Utf8GraphQLRequestParser _reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var name = _reader.GetString(); diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Values.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Values.cs index 5dafcdc7736..c146518f5a7 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Values.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.Values.cs @@ -78,7 +78,7 @@ private void ParseObjectField(IDictionary obj) _reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var name = _reader.GetString(); @@ -97,7 +97,7 @@ private void SkipObjectField() _reader, ParseMany_InvalidOpenToken, TokenKind.String, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } _reader.MoveNext(); @@ -114,7 +114,7 @@ private void SkipObjectField() _reader, ParseMany_InvalidOpenToken, TokenKind.LeftBracket, - TokenPrinter.Print(in _reader)); + TokenPrinter.Print(ref _reader)); } var list = new List(); diff --git a/src/HotChocolate/Raven/src/Data/Filtering/Handlers/RavenFilterExpressionBuilder.cs b/src/HotChocolate/Raven/src/Data/Filtering/Handlers/RavenFilterExpressionBuilder.cs index 3a166b1d388..4d4e6fe41c7 100644 --- a/src/HotChocolate/Raven/src/Data/Filtering/Handlers/RavenFilterExpressionBuilder.cs +++ b/src/HotChocolate/Raven/src/Data/Filtering/Handlers/RavenFilterExpressionBuilder.cs @@ -5,7 +5,7 @@ namespace HotChocolate.Data.Raven.Filtering.Handlers; -public class RavenFilterExpressionBuilder +public static class RavenFilterExpressionBuilder { private static readonly MethodInfo _inMethod = typeof(RavenQueryableExtensions) diff --git a/src/HotChocolate/Spatial/src/Types/WellKnownFields.cs b/src/HotChocolate/Spatial/src/Types/WellKnownFields.cs index 37065372c5a..c17ec02706b 100644 --- a/src/HotChocolate/Spatial/src/Types/WellKnownFields.cs +++ b/src/HotChocolate/Spatial/src/Types/WellKnownFields.cs @@ -1,6 +1,6 @@ namespace HotChocolate.Types.Spatial; -internal class WellKnownFields +internal static class WellKnownFields { public const string TypeFieldName = "type"; diff --git a/src/StrawberryShake/Client/src/Core/OperationExecutor.cs b/src/StrawberryShake/Client/src/Core/OperationExecutor.cs index f1ebb3bbac0..ae2eae2a677 100644 --- a/src/StrawberryShake/Client/src/Core/OperationExecutor.cs +++ b/src/StrawberryShake/Client/src/Core/OperationExecutor.cs @@ -44,7 +44,18 @@ public OperationExecutor( _strategy = strategy; } - /// + /// + /// Executes the result and returns the result. + /// + /// + /// The operation request. + /// + /// + /// The cancellation token. + /// + /// + /// Returns the operation result. + /// public async Task> ExecuteAsync( OperationRequest request, CancellationToken cancellationToken = default) @@ -85,7 +96,18 @@ public async Task> ExecuteAsync( return result; } - /// + /// + /// Registers a requests and subscribes to updates on the request results. + /// + /// + /// The operation request. + /// + /// + /// The request execution strategy. + /// + /// + /// The observable that can be used to subscribe to results. + /// public IObservable> Watch( OperationRequest request, ExecutionStrategy? strategy = null) diff --git a/src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs b/src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs index 899fc02bd80..a6e14862ab3 100644 --- a/src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs +++ b/src/StrawberryShake/Client/src/Core/Serialization/Iso8601Duration.cs @@ -364,13 +364,13 @@ internal static bool TryParse(string s, out TimeSpan? result) return false; } - /// Helper method that constructs an integer from leading digits starting at s[offset]. - /// "offset" is updated to contain an offset just beyond the last digit. - /// The number of digits consumed is returned in cntDigits. - /// The integer is returned (0 if no digits). If the digits cannot fit into an Int32: - /// 1. If eatDigits is true, then additional digits will be silently discarded - /// (don't count towards numDigits) - /// 2. If eatDigits is false, an overflow exception is thrown + // Helper method that constructs an integer from leading digits starting at s[offset]. + // "offset" is updated to contain an offset just beyond the last digit. + // The number of digits consumed is returned in cntDigits. + // The integer is returned (0 if no digits). If the digits cannot fit into an Int32: + // 1. If eatDigits is true, then additional digits will be silently discarded + // (don't count towards numDigits) + // 2. If eatDigits is false, an overflow exception is thrown private static bool TryParseDigits( string s, ref int offset, diff --git a/src/StrawberryShake/Client/src/Core/StorelessOperationExecutor.cs b/src/StrawberryShake/Client/src/Core/StorelessOperationExecutor.cs index 03641fb64ef..1817970d09a 100644 --- a/src/StrawberryShake/Client/src/Core/StorelessOperationExecutor.cs +++ b/src/StrawberryShake/Client/src/Core/StorelessOperationExecutor.cs @@ -37,7 +37,18 @@ public StorelessOperationExecutor( throw new ArgumentNullException(nameof(resultPatcher)); } - /// + /// + /// Executes the result and returns the result. + /// + /// + /// The operation request. + /// + /// + /// The cancellation token. + /// + /// + /// Returns the operation result. + /// public async Task> ExecuteAsync( OperationRequest request, CancellationToken cancellationToken = default) @@ -76,7 +87,18 @@ public async Task> ExecuteAsync( return result; } - /// + /// + /// Registers a requests and subscribes to updates on the request results. + /// + /// + /// The operation request. + /// + /// + /// The request execution strategy. + /// + /// + /// The observable that can be used to subscribe to results. + /// public IObservable> Watch( OperationRequest request, ExecutionStrategy? strategy = null) diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/XmlCommentBuilder.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/XmlCommentBuilder.cs index 456daffcaa1..6def21e3328 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/XmlCommentBuilder.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/XmlCommentBuilder.cs @@ -22,10 +22,6 @@ public XmlCommentBuilder AddCode(string code) public static XmlCommentBuilder New() => new(); - /// - /// - /// - /// public void Build(CodeWriter writer) { if (_summary is not null) @@ -62,4 +58,4 @@ private void WriteCommentLines(CodeWriter writer, string str) } while (line is not null); } -} \ No newline at end of file +} diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/ICSharpSyntaxGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/ICSharpSyntaxGenerator.cs index 18d56480391..fb472e18797 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/ICSharpSyntaxGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/ICSharpSyntaxGenerator.cs @@ -2,9 +2,6 @@ namespace StrawberryShake.CodeGeneration; -/// -/// -/// public interface ICSharpSyntaxGenerator { /// @@ -34,4 +31,4 @@ bool CanHandle( CSharpSyntaxGeneratorResult Generate( ICodeDescriptor descriptor, CSharpSyntaxGeneratorSettings settings); -} \ No newline at end of file +} From 0dfde76a7d25d233f6ce427646eea4f21801ad10 Mon Sep 17 00:00:00 2001 From: Glen Date: Mon, 3 Jun 2024 09:00:30 +0200 Subject: [PATCH 2/3] Fix CI Build (#7135) --- .github/workflows/ci.yml | 11 +---------- .github/workflows/pr-labeler.yml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 855598b3eff..bfe4282f817 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI on: - pull_request_target: + pull_request: branches: - main @@ -55,15 +55,6 @@ jobs: echo "::set-output name=src_changes::false" fi - pr-labeler: - name: Apply Labels - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - uses: actions/labeler@v5 - spellcheck: name: "Spellcheck Documentation" runs-on: ubuntu-latest diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 00000000000..7af7d8ce11f --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,17 @@ +name: Pull Request Labeler + +on: + pull_request_target: + branches: + - main + +permissions: + contents: read + pull-requests: write + +jobs: + pr-labeler: + name: Apply Labels + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 From 5843a9f447dec5619d5b287a23228d1f25e25827 Mon Sep 17 00:00:00 2001 From: Glen Date: Mon, 3 Jun 2024 09:03:08 +0200 Subject: [PATCH 3/3] Use the correct middleware in the UseTimeout extension method (#7136) --- .../RequestExecutorBuilderExtensions.UseRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs index 647e78dabe3..0aa3d4185af 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/RequestExecutorBuilderExtensions.UseRequest.cs @@ -100,7 +100,7 @@ public static IRequestExecutorBuilder UseExceptions( public static IRequestExecutorBuilder UseTimeout( this IRequestExecutorBuilder builder) => - builder.UseRequest(DocumentParserMiddleware.Create()); + builder.UseRequest(TimeoutMiddleware.Create()); public static IRequestExecutorBuilder UseInstrumentation( this IRequestExecutorBuilder builder) =>