From 2415355da1e0e0c8b318bb42d2178ce4d6333da4 Mon Sep 17 00:00:00 2001 From: Glen Date: Fri, 24 Apr 2026 17:22:55 +0200 Subject: [PATCH 1/3] Fix various analyzer errors Co-authored-by: Copilot --- .../Formatters/StableSnapshotHelpers.cs | 5 +- .../Pipeline/RequestClassMiddlewareFactory.cs | 3 +- .../SchemaBuilderExtensions.Middleware.cs | 12 ++-- .../ObjectFieldDataLoaderExtensions.cs | 3 +- .../Types/Attributes/SubscribeAttribute.cs | 1 - .../Conventions/DefaultNamingConventions.cs | 1 - .../Conventions/DefaultTypeInspector.cs | 4 +- .../RemoveFederationInfrastructure.cs | 8 +-- .../Products/ProductListType.cs | 1 - .../Suites/Fed2ExternalExtends/A/QueryType.cs | 5 +- .../Suites/Fed2ExternalExtends/A/UserType.cs | 10 ++-- .../Suites/Fed2ExternalExtends/B/UserType.cs | 8 +-- .../Fed2ExternalExtension/A/QueryType.cs | 5 +- .../Fed2ExternalExtension/A/UserType.cs | 10 ++-- .../Fed2ExternalExtension/B/UserType.cs | 8 +-- .../Accounts/UserType.cs | 4 +- .../Products/ProductType.cs | 4 +- .../Reviews/ReviewType.cs | 5 +- .../FusionArchiveTests.cs | 2 +- .../Outbox/PostgresMessageOutbox.cs | 4 +- .../Commands/Fusion/FusionComposeCommand.cs | 2 - .../Commands/Fusion/FusionPublishCommand.cs | 1 - .../Fusion/FusionMigrationHelpersTests.cs | 55 +++++++++---------- .../CommandLine.Tests/GlobalOptionsTests.cs | 2 +- 24 files changed, 72 insertions(+), 91 deletions(-) diff --git a/src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/StableSnapshotHelpers.cs b/src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/StableSnapshotHelpers.cs index bbc705507f7..c56e4f8f066 100644 --- a/src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/StableSnapshotHelpers.cs +++ b/src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/StableSnapshotHelpers.cs @@ -554,10 +554,7 @@ public void AddPayload(JsonElement root) { PayloadCount++; - if (InitialPayload is null) - { - InitialPayload = root.Clone(); - } + InitialPayload ??= root.Clone(); if (root.TryGetProperty("pending", out var pending)) { diff --git a/src/HotChocolate/Core/src/Types/Execution/Pipeline/RequestClassMiddlewareFactory.cs b/src/HotChocolate/Core/src/Types/Execution/Pipeline/RequestClassMiddlewareFactory.cs index b0ba0037bbb..969ddb5ab50 100644 --- a/src/HotChocolate/Core/src/Types/Execution/Pipeline/RequestClassMiddlewareFactory.cs +++ b/src/HotChocolate/Core/src/Types/Execution/Pipeline/RequestClassMiddlewareFactory.cs @@ -26,8 +26,7 @@ internal static class RequestClassMiddlewareFactory .GetMethod(nameof(IServiceProvider.GetService))!; internal static RequestMiddleware Create< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] - TMiddleware>() + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] TMiddleware>() where TMiddleware : class { return (context, next) => diff --git a/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Middleware.cs b/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Middleware.cs index 1003af5af63..664d1e9f89c 100644 --- a/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Middleware.cs +++ b/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Middleware.cs @@ -6,8 +6,7 @@ namespace HotChocolate; public static partial class SchemaBuilderExtensions { public static ISchemaBuilder Use< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] - TMiddleware>( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] TMiddleware>( this ISchemaBuilder builder) where TMiddleware : class { @@ -16,8 +15,7 @@ public static ISchemaBuilder Use< } public static ISchemaBuilder Use< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] - TMiddleware>( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] TMiddleware>( this ISchemaBuilder builder, Func factory) where TMiddleware : class @@ -38,8 +36,7 @@ public static ISchemaBuilder Map( } public static ISchemaBuilder Map< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] - TMiddleware>( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] TMiddleware>( this ISchemaBuilder builder, FieldReference fieldReference) where TMiddleware : class @@ -56,8 +53,7 @@ public static ISchemaBuilder Map< } public static ISchemaBuilder Map< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] - TMiddleware>( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods)] TMiddleware>( this ISchemaBuilder builder, FieldReference fieldReference, Func factory) diff --git a/src/HotChocolate/Core/src/Types/Fetching/Extensions/ObjectFieldDataLoaderExtensions.cs b/src/HotChocolate/Core/src/Types/Fetching/Extensions/ObjectFieldDataLoaderExtensions.cs index 19c166803b2..967201e29d4 100644 --- a/src/HotChocolate/Core/src/Types/Fetching/Extensions/ObjectFieldDataLoaderExtensions.cs +++ b/src/HotChocolate/Core/src/Types/Fetching/Extensions/ObjectFieldDataLoaderExtensions.cs @@ -14,8 +14,7 @@ public static class DataLoaderObjectFieldExtensions { [RequiresDynamicCode("Creates generic types at runtime for data loader middleware.")] public static IObjectFieldDescriptor UseDataLoader< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] - TDataLoader>( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] TDataLoader>( this IObjectFieldDescriptor descriptor) where TDataLoader : IDataLoader => UseDataLoader(descriptor, typeof(TDataLoader)); diff --git a/src/HotChocolate/Core/src/Types/Types/Attributes/SubscribeAttribute.cs b/src/HotChocolate/Core/src/Types/Types/Attributes/SubscribeAttribute.cs index 1db771d2907..df3a102c969 100644 --- a/src/HotChocolate/Core/src/Types/Types/Attributes/SubscribeAttribute.cs +++ b/src/HotChocolate/Core/src/Types/Types/Attributes/SubscribeAttribute.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using System.Reflection; using HotChocolate.Resolvers; using HotChocolate.Subscriptions; diff --git a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultNamingConventions.cs b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultNamingConventions.cs index 56f3019ca9a..1ccf97e01de 100644 --- a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultNamingConventions.cs +++ b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultNamingConventions.cs @@ -1,5 +1,4 @@ using System.Buffers; -using System.Diagnostics.CodeAnalysis; using System.Reflection; using HotChocolate.Internal; using HotChocolate.Utilities; diff --git a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultTypeInspector.cs b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultTypeInspector.cs index e0a330d93c7..40474265c33 100644 --- a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultTypeInspector.cs +++ b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DefaultTypeInspector.cs @@ -252,8 +252,8 @@ public virtual IEnumerable GetEnumValues(Type enumType) if (enumType != typeof(object) && enumType.IsEnum) { -// Enum.GetValues requires dynamic code but the enum type -// is schema-registered and guaranteed to be available. + // Enum.GetValues requires dynamic code but the enum type + // is schema-registered and guaranteed to be available. #pragma warning disable IL3050 return Enum.GetValues(enumType).Cast(); #pragma warning restore IL3050 diff --git a/src/HotChocolate/Fusion/src/Fusion.Composition.ApolloFederation/RemoveFederationInfrastructure.cs b/src/HotChocolate/Fusion/src/Fusion.Composition.ApolloFederation/RemoveFederationInfrastructure.cs index 790ff2a9432..74c665aeec4 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Composition.ApolloFederation/RemoveFederationInfrastructure.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Composition.ApolloFederation/RemoveFederationInfrastructure.cs @@ -8,7 +8,7 @@ namespace HotChocolate.Fusion.ApolloFederation; /// internal static class RemoveFederationInfrastructure { - private static readonly HashSet _federationDirectiveNames = new(StringComparer.Ordinal) + private static readonly HashSet s_federationDirectiveNames = new(StringComparer.Ordinal) { FederationDirectiveNames.Key, FederationDirectiveNames.Requires, @@ -26,7 +26,7 @@ internal static class RemoveFederationInfrastructure FederationDirectiveNames.Policy }; - private static readonly HashSet _federationScalarNames = new(StringComparer.Ordinal) + private static readonly HashSet s_federationScalarNames = new(StringComparer.Ordinal) { FederationTypeNames.Any, FederationTypeNames.FieldSet, @@ -42,13 +42,13 @@ internal static class RemoveFederationInfrastructure public static void Apply(MutableSchemaDefinition schema) { // Remove federation directive definitions. - foreach (var name in _federationDirectiveNames) + foreach (var name in s_federationDirectiveNames) { schema.DirectiveDefinitions.Remove(name); } // Remove federation scalar types. - foreach (var name in _federationScalarNames) + foreach (var name in s_federationScalarNames) { schema.Types.Remove(name); } diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/ComplexEntityCall/Products/ProductListType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/ComplexEntityCall/Products/ProductListType.cs index a03b5b03f2e..16be50c3e96 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/ComplexEntityCall/Products/ProductListType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/ComplexEntityCall/Products/ProductListType.cs @@ -1,6 +1,5 @@ using HotChocolate.ApolloFederation.Resolvers; using HotChocolate.ApolloFederation.Types; -using HotChocolate.Language; using HotChocolate.Types; namespace HotChocolate.Fusion.Suites.ComplexEntityCall.Products; diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/QueryType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/QueryType.cs index aea5b7dbfa5..96234f83670 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/QueryType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/QueryType.cs @@ -5,8 +5,9 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtends.A; /// /// Root Query type for the a subgraph. Exposes -/// randomUser: User and providedRandomUser: User @provides(fields: -/// "name"). The providedRandomUser path returns a user with the +/// randomUser: User and +/// providedRandomUser: User @provides(fields: "name"). +/// The providedRandomUser path returns a user with the /// otherwise external name field already populated so the gateway /// can read name without dispatching a separate entity call to /// subgraph b. diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/UserType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/UserType.cs index 82a8754d66d..6dc4ccf362d 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/UserType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/A/UserType.cs @@ -5,11 +5,11 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtends.A; /// /// Apollo Federation descriptor for the User entity as extended by -/// the a subgraph. Mirrors the audit SDL: -/// type User @key(fields: "id") @extends { id: ID! @external, name: -/// String! @external, rid: ID }. The reference resolver returns the -/// seeded by id so subsequent paths can fetch -/// rid. +/// the a subgraph. Mirrors the audit SDL +/// type User @key(fields: "id") @extends with fields +/// id: ID! @external, name: String! @external, and rid: ID. +/// The reference resolver returns the seeded by +/// id so subsequent paths can fetch rid. /// public sealed class UserType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/B/UserType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/B/UserType.cs index b7a8caf5024..b8a173e5073 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/B/UserType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtends/B/UserType.cs @@ -5,10 +5,10 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtends.B; /// /// Apollo Federation descriptor for the User entity owned by the -/// b subgraph. Mirrors the audit SDL: -/// type User @key(fields: "id") { id: ID!, name: String! @shareable, -/// nickname: String }. The reference resolver looks up users by -/// id. +/// b subgraph. Mirrors the audit SDL +/// type User @key(fields: "id") with fields +/// id: ID!, name: String! @shareable, and nickname: String. +/// The reference resolver looks up users by id. /// public sealed class UserType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/QueryType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/QueryType.cs index 6f42208ed26..18807e685a6 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/QueryType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/QueryType.cs @@ -5,8 +5,9 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtension.A; /// /// Root Query type for the a subgraph. Exposes -/// randomUser: User and providedRandomUser: User @provides(fields: -/// "name"). The providedRandomUser path returns a user with the +/// randomUser: User and +/// providedRandomUser: User @provides(fields: "name"). +/// The providedRandomUser path returns a user with the /// otherwise external name field already populated so the gateway /// can read name without dispatching a separate entity call to /// subgraph b. diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/UserType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/UserType.cs index 5f31b3c9852..89377a34e18 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/UserType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/A/UserType.cs @@ -5,11 +5,11 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtension.A; /// /// Apollo Federation descriptor for the User entity as projected -/// by the a subgraph. Mirrors the audit SDL: -/// extend type User @key(fields: "id") { id: ID! @external, name: -/// String! @external, rid: ID }. The reference resolver returns the -/// seeded by id so subsequent paths can fetch -/// rid. +/// by the a subgraph. Mirrors the audit SDL +/// extend type User @key(fields: "id") with fields +/// id: ID! @external, name: String! @external, and rid: ID. +/// The reference resolver returns the seeded by +/// id so subsequent paths can fetch rid. /// public sealed class UserType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/B/UserType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/B/UserType.cs index f6c355add79..4785570a6ed 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/B/UserType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/Fed2ExternalExtension/B/UserType.cs @@ -5,10 +5,10 @@ namespace HotChocolate.Fusion.Suites.Fed2ExternalExtension.B; /// /// Apollo Federation descriptor for the User entity owned by the -/// b subgraph. Mirrors the audit SDL: -/// type User @key(fields: "id") { id: ID!, name: String! @shareable, -/// nickname: String }. The reference resolver looks up users by -/// id. +/// b subgraph. Mirrors the audit SDL +/// type User @key(fields: "id") with fields +/// id: ID!, name: String! @shareable, and nickname: String. +/// The reference resolver looks up users by id. /// public sealed class UserType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Accounts/UserType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Accounts/UserType.cs index f2dc0075da4..2469df11afe 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Accounts/UserType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Accounts/UserType.cs @@ -6,8 +6,8 @@ namespace HotChocolate.Fusion.Suites.SimpleRequiresProvides.Accounts; /// /// Apollo Federation descriptor for the User entity owned by the /// accounts subgraph. Mirrors the audit Schema Definition Language -/// (SDL): type User @key(fields: "id") { id: ID!, name: String, -/// username: String @shareable }. +/// (SDL) type User @key(fields: "id") with fields +/// id: ID!, name: String, and username: String @shareable. /// public sealed class UserType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Products/ProductType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Products/ProductType.cs index 5538263eb11..115a936a667 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Products/ProductType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Products/ProductType.cs @@ -6,8 +6,8 @@ namespace HotChocolate.Fusion.Suites.SimpleRequiresProvides.Products; /// /// Apollo Federation descriptor for the Product entity owned by the /// products subgraph. Mirrors the audit Schema Definition Language -/// (SDL): type Product @key(fields: "upc") { upc: String!, name: String, -/// price: Int, weight: Int }. +/// (SDL) type Product @key(fields: "upc") with fields +/// upc: String!, name: String, price: Int, and weight: Int. /// public sealed class ProductType : ObjectType { diff --git a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Reviews/ReviewType.cs b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Reviews/ReviewType.cs index 489a8cf7341..ee04e5b3ccd 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Reviews/ReviewType.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Connectors.ApolloFederation.Compliance.Tests/Suites/SimpleRequiresProvides/Reviews/ReviewType.cs @@ -6,8 +6,9 @@ namespace HotChocolate.Fusion.Suites.SimpleRequiresProvides.Reviews; /// /// Apollo Federation descriptor for the Review entity owned by the /// reviews subgraph. Mirrors the audit Schema Definition Language -/// (SDL): type Review @key(fields: "id") { id: ID!, body: String, -/// author: User @provides(fields: "username"), product: Product }. +/// (SDL) type Review @key(fields: "id") with fields +/// id: ID!, body: String, +/// author: User @provides(fields: "username"), and product: Product. /// The author resolver inlines username alongside the /// returned so the gateway can satisfy the provides /// selection without dispatching a fresh entity call to the diff --git a/src/HotChocolate/Fusion/test/Fusion.Packaging.Tests/FusionArchiveTests.cs b/src/HotChocolate/Fusion/test/Fusion.Packaging.Tests/FusionArchiveTests.cs index 6485d65e2f3..8f699ef9b1c 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Packaging.Tests/FusionArchiveTests.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Packaging.Tests/FusionArchiveTests.cs @@ -666,7 +666,7 @@ public async Task SetLegacyArchiveFile_WithValidContent_RoundTripsCorrectly() { // arrange await using var stream = CreateStream(); - var content = Encoding.UTF8.GetBytes("legacy archive payload"); + var content = "legacy archive payload"u8.ToArray(); await using var contentStream = new MemoryStream(content); // act diff --git a/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs b/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs index b272581c927..2ab2c27a2a4 100644 --- a/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs +++ b/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs @@ -83,8 +83,6 @@ public async ValueTask PersistAsync(MessageEnvelope envelope, CancellationToken await connection.OpenAsync(cancellationToken); } - var transaction = _originalDbContext.Database.CurrentTransaction?.GetDbTransaction() as NpgsqlTransaction; - await using var writer = new Utf8JsonWriter(_arrayWriter); writer.WriteEnvelope(envelope); writer.Flush(); // we know it's not async @@ -99,7 +97,7 @@ public async ValueTask PersistAsync(MessageEnvelope envelope, CancellationToken await command.ExecuteNonQueryAsync(cancellationToken); - if (transaction is null) + if (_originalDbContext.Database.CurrentTransaction?.GetDbTransaction() is not NpgsqlTransaction transaction) { _signal.Set(); } diff --git a/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionComposeCommand.cs b/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionComposeCommand.cs index e7876772c59..c71bcdb1bb5 100644 --- a/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionComposeCommand.cs +++ b/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionComposeCommand.cs @@ -1,7 +1,5 @@ using System.Text; -using System.Text.Json; using System.Threading.Channels; -using ChilliCream.Nitro.CommandLine.FusionCompatibility; using ChilliCream.Nitro.CommandLine.Services; using HotChocolate.Fusion; using HotChocolate.Fusion.Logging; diff --git a/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionPublishCommand.cs b/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionPublishCommand.cs index 5d099964f40..7729aa73947 100644 --- a/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionPublishCommand.cs +++ b/src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionPublishCommand.cs @@ -6,7 +6,6 @@ using ChilliCream.Nitro.Client; using ChilliCream.Nitro.Client.FusionConfiguration; using ChilliCream.Nitro.CommandLine.Commands.Fusion.PublishCommand; -using ChilliCream.Nitro.CommandLine.FusionCompatibility; using ChilliCream.Nitro.CommandLine.Helpers; using ChilliCream.Nitro.CommandLine.Services; using ChilliCream.Nitro.CommandLine.Services.Sessions; diff --git a/src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Fusion/FusionMigrationHelpersTests.cs b/src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Fusion/FusionMigrationHelpersTests.cs index ae2e88ce98d..49f6d150bf9 100644 --- a/src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Fusion/FusionMigrationHelpersTests.cs +++ b/src/Nitro/CommandLine/test/CommandLine.Tests/Commands/Fusion/FusionMigrationHelpersTests.cs @@ -1,4 +1,3 @@ -using System.Text; using System.Text.Json; using ChilliCream.Nitro.CommandLine.Commands.Fusion; @@ -12,7 +11,7 @@ public sealed class FusionMigrationHelpersTests public void MigrateSubgraphConfig_Should_WriteEmptyName_When_InputIsEmptyObject() { // arrange - var input = Encoding.UTF8.GetBytes("{}"); + var input = "{}"u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -25,7 +24,7 @@ public void MigrateSubgraphConfig_Should_WriteEmptyName_When_InputIsEmptyObject( public void MigrateSubgraphConfig_Should_RenameSubgraphToName_When_SubgraphPropertyPresent() { // arrange - var input = Encoding.UTF8.GetBytes("""{"subgraph":"products"}"""); + var input = """{"subgraph":"products"}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -38,8 +37,7 @@ public void MigrateSubgraphConfig_Should_RenameSubgraphToName_When_SubgraphPrope public void MigrateSubgraphConfig_Should_RenameHttpBaseAddressToUrlUnderTransports_When_HttpPresent() { // arrange - var input = Encoding.UTF8.GetBytes( - """{"subgraph":"products","http":{"baseAddress":"http://localhost/graphql"}}"""); + var input = """{"subgraph":"products","http":{"baseAddress":"http://localhost/graphql"}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -53,8 +51,8 @@ public void MigrateSubgraphConfig_Should_RenameHttpBaseAddressToUrlUnderTranspor public void MigrateSubgraphConfig_Should_PreserveOtherHttpProperties_When_HttpHasMoreThanBaseAddress() { // arrange - var input = Encoding.UTF8.GetBytes( - """{"subgraph":"products","http":{"baseAddress":"http://x/gql","clientName":"Fusion","timeout":"00:00:30"}}"""); + var input = + """{"subgraph":"products","http":{"baseAddress":"http://x/gql","clientName":"Fusion","timeout":"00:00:30"}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -68,8 +66,7 @@ public void MigrateSubgraphConfig_Should_PreserveOtherHttpProperties_When_HttpHa public void MigrateSubgraphConfig_Should_PreserveHttpProperties_When_BaseAddressIsMissing() { // arrange - var input = Encoding.UTF8.GetBytes( - """{"subgraph":"products","http":{"clientName":"Fusion"}}"""); + var input = """{"subgraph":"products","http":{"clientName":"Fusion"}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -83,8 +80,7 @@ public void MigrateSubgraphConfig_Should_PreserveHttpProperties_When_BaseAddress public void MigrateSubgraphConfig_Should_DropWebsocketProperty_When_WebsocketPresent() { // arrange - var input = Encoding.UTF8.GetBytes( - """{"subgraph":"products","websocket":{"baseAddress":"ws://localhost/ws"}}"""); + var input = """{"subgraph":"products","websocket":{"baseAddress":"ws://localhost/ws"}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -97,8 +93,7 @@ public void MigrateSubgraphConfig_Should_DropWebsocketProperty_When_WebsocketPre public void MigrateSubgraphConfig_Should_PreserveUnknownTopLevelProperties_When_AdditionalFieldsPresent() { // arrange - var input = Encoding.UTF8.GetBytes( - """{"subgraph":"products","extensions":{"custom":true},"retryCount":3}"""); + var input = """{"subgraph":"products","extensions":{"custom":true},"retryCount":3}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -112,7 +107,7 @@ public void MigrateSubgraphConfig_Should_PreserveUnknownTopLevelProperties_When_ public void MigrateSubgraphConfig_Should_ProduceFullMigration_When_AllKnownPropertiesPresent() { // arrange - var input = Encoding.UTF8.GetBytes( + var input = """ { "subgraph": "products", @@ -120,7 +115,7 @@ public void MigrateSubgraphConfig_Should_ProduceFullMigration_When_AllKnownPrope "websocket": { "baseAddress": "ws://x/ws" }, "extensions": { "custom": true } } - """); + """u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -134,7 +129,7 @@ public void MigrateSubgraphConfig_Should_ProduceFullMigration_When_AllKnownPrope public void MigrateSubgraphConfig_Should_PreserveExistingVersion_When_VersionAlreadyPresent() { // arrange - var input = Encoding.UTF8.GetBytes("""{"subgraph":"products","version":"9.9.9"}"""); + var input = """{"subgraph":"products","version":"9.9.9"}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -147,7 +142,7 @@ public void MigrateSubgraphConfig_Should_PreserveExistingVersion_When_VersionAlr public void MigrateSubgraphConfig_Should_InjectDefaultVersion_When_VersionMissing() { // arrange - var input = Encoding.UTF8.GetBytes("""{"subgraph":"products"}"""); + var input = """{"subgraph":"products"}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateSubgraphConfig(input); @@ -160,7 +155,7 @@ public void MigrateSubgraphConfig_Should_InjectDefaultVersion_When_VersionMissin public void MigrateSubgraphConfig_Should_Throw_When_InputIsInvalidJson() { // arrange - var input = Encoding.UTF8.GetBytes("not json"); + var input = "not json"u8.ToArray(); // act & assert Assert.ThrowsAny(() => FusionMigrationHelpers.MigrateSubgraphConfig(input)); @@ -174,7 +169,7 @@ public void MigrateSubgraphConfig_Should_Throw_When_InputIsInvalidJson() public void MigrateGatewaySettings_Should_EmitDefaultScaffolding_When_InputIsEmptyObject() { // arrange - var input = Encoding.UTF8.GetBytes("{}"); + var input = "{}"u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -187,7 +182,7 @@ public void MigrateGatewaySettings_Should_EmitDefaultScaffolding_When_InputIsEmp public void MigrateGatewaySettings_Should_AddEnableGlobalObjectIdentificationTrue_When_NodeFieldEnabled() { // arrange - var input = Encoding.UTF8.GetBytes("""{"nodeField":{"enabled":true}}"""); + var input = """{"nodeField":{"enabled":true}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -201,7 +196,7 @@ public void MigrateGatewaySettings_Should_AddEnableGlobalObjectIdentificationTru public void MigrateGatewaySettings_Should_AddEnableGlobalObjectIdentificationFalse_When_NodeFieldDisabled() { // arrange - var input = Encoding.UTF8.GetBytes("""{"nodeField":{"enabled":false}}"""); + var input = """{"nodeField":{"enabled":false}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -215,7 +210,7 @@ public void MigrateGatewaySettings_Should_AddEnableGlobalObjectIdentificationFal public void MigrateGatewaySettings_Should_OmitEnableGlobalObjectIdentification_When_NodeFieldHasNoEnabled() { // arrange - var input = Encoding.UTF8.GetBytes("""{"nodeField":{}}"""); + var input = """{"nodeField":{}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -228,7 +223,7 @@ public void MigrateGatewaySettings_Should_OmitEnableGlobalObjectIdentification_W public void MigrateGatewaySettings_Should_AddTagMergeBehaviorInclude_When_TagDirectiveMakePublicTrue() { // arrange - var input = Encoding.UTF8.GetBytes("""{"tagDirective":{"makePublic":true}}"""); + var input = """{"tagDirective":{"makePublic":true}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -242,7 +237,7 @@ public void MigrateGatewaySettings_Should_AddTagMergeBehaviorInclude_When_TagDir public void MigrateGatewaySettings_Should_OmitTagMergeBehavior_When_TagDirectiveMakePublicFalse() { // arrange - var input = Encoding.UTF8.GetBytes("""{"tagDirective":{"makePublic":false}}"""); + var input = """{"tagDirective":{"makePublic":false}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -255,7 +250,7 @@ public void MigrateGatewaySettings_Should_OmitTagMergeBehavior_When_TagDirective public void MigrateGatewaySettings_Should_AddExcludeByTag_When_TagDirectiveExcludeNonEmpty() { // arrange - var input = Encoding.UTF8.GetBytes("""{"tagDirective":{"exclude":["internal","beta"]}}"""); + var input = """{"tagDirective":{"exclude":["internal","beta"]}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -269,7 +264,7 @@ public void MigrateGatewaySettings_Should_AddExcludeByTag_When_TagDirectiveExclu public void MigrateGatewaySettings_Should_OmitExcludeByTag_When_TagDirectiveExcludeEmpty() { // arrange - var input = Encoding.UTF8.GetBytes("""{"tagDirective":{"exclude":[]}}"""); + var input = """{"tagDirective":{"exclude":[]}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -282,7 +277,7 @@ public void MigrateGatewaySettings_Should_OmitExcludeByTag_When_TagDirectiveExcl public void MigrateGatewaySettings_Should_OmitExcludeByTag_When_TagDirectiveExcludeMissing() { // arrange - var input = Encoding.UTF8.GetBytes("""{"tagDirective":{"makePublic":true}}"""); + var input = """{"tagDirective":{"makePublic":true}}"""u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -296,7 +291,7 @@ public void MigrateGatewaySettings_Should_OmitExcludeByTag_When_TagDirectiveExcl public void MigrateGatewaySettings_Should_CombineAllMigrations_When_AllRelevantPropertiesPresent() { // arrange - var input = Encoding.UTF8.GetBytes( + var input = """ { "tagDirective": { "makePublic": true, "exclude": ["internal"] }, @@ -304,7 +299,7 @@ public void MigrateGatewaySettings_Should_CombineAllMigrations_When_AllRelevantP "transport": { "defaultClientName": "Fusion" }, "reEncodeIds": { "enabled": true } } - """); + """u8.ToArray(); // act using var result = FusionMigrationHelpers.MigrateGatewaySettings(input); @@ -318,7 +313,7 @@ public void MigrateGatewaySettings_Should_CombineAllMigrations_When_AllRelevantP public void MigrateGatewaySettings_Should_Throw_When_InputIsInvalidJson() { // arrange - var input = Encoding.UTF8.GetBytes("not json"); + var input = "not json"u8.ToArray(); // act & assert Assert.ThrowsAny(() => FusionMigrationHelpers.MigrateGatewaySettings(input)); diff --git a/src/Nitro/CommandLine/test/CommandLine.Tests/GlobalOptionsTests.cs b/src/Nitro/CommandLine/test/CommandLine.Tests/GlobalOptionsTests.cs index 39e4253a6c9..e7a3871a3e9 100644 --- a/src/Nitro/CommandLine/test/CommandLine.Tests/GlobalOptionsTests.cs +++ b/src/Nitro/CommandLine/test/CommandLine.Tests/GlobalOptionsTests.cs @@ -233,7 +233,7 @@ await rootCommand.ExecuteAsync( return provider; } - private static System.Net.Http.HttpClient CreateApiClient(ServiceProvider provider) + private static HttpClient CreateApiClient(ServiceProvider provider) { var factory = provider.GetRequiredService(); return factory.CreateClient(ApiClient.ClientName); From a0ba8d13f686f1b5a1ad049a8dbc28f92f0b92a0 Mon Sep 17 00:00:00 2001 From: Glen Date: Fri, 24 Apr 2026 19:49:14 +0200 Subject: [PATCH 2/3] Address Copilot feedback --- .../Outbox/PostgresMessageOutbox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs b/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs index 2ab2c27a2a4..5a21cad7169 100644 --- a/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs +++ b/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/PostgresMessageOutbox.cs @@ -97,7 +97,7 @@ public async ValueTask PersistAsync(MessageEnvelope envelope, CancellationToken await command.ExecuteNonQueryAsync(cancellationToken); - if (_originalDbContext.Database.CurrentTransaction?.GetDbTransaction() is not NpgsqlTransaction transaction) + if (_originalDbContext.Database.CurrentTransaction?.GetDbTransaction() is not NpgsqlTransaction) { _signal.Set(); } From cccb53f8578e1bbb070ba65caf128cc625278266 Mon Sep 17 00:00:00 2001 From: Glen Date: Sun, 26 Apr 2026 11:53:15 +0200 Subject: [PATCH 3/3] Update snapshot --- ...UseDataLoader_Should_ThrowException_When_NotADataLoader.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/__snapshots__/UseDataLoaderTests.UseDataLoader_Should_ThrowException_When_NotADataLoader.snap b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/__snapshots__/UseDataLoaderTests.UseDataLoader_Should_ThrowException_When_NotADataLoader.snap index 5d95eb256c4..13178d97eaf 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/__snapshots__/UseDataLoaderTests.UseDataLoader_Should_ThrowException_When_NotADataLoader.snap +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/__snapshots__/UseDataLoaderTests.UseDataLoader_Should_ThrowException_When_NotADataLoader.snap @@ -5,7 +5,7 @@ For more details look at the `Errors` property. 1. The provided type HotChocolate.Execution.Integration.DataLoader.UseDataLoaderTests+Foo is not a DataLoader. (HotChocolate.Types.ObjectType) - at HotChocolate.Types.DataLoaderObjectFieldExtensions.UseDataLoader(IObjectFieldDescriptor descriptor, Type dataLoaderType) in ObjectFieldDataLoaderExtensions.cs:line 33 + at HotChocolate.Types.DataLoaderObjectFieldExtensions.UseDataLoader(IObjectFieldDescriptor descriptor, Type dataLoaderType) in ObjectFieldDataLoaderExtensions.cs:line 32 at HotChocolate.Execution.Integration.DataLoader.UseDataLoaderTests.<>c.b__0_1(IObjectTypeDescriptor`1 x) in UseDataLoaderTests.cs:line 16 at HotChocolate.Types.ObjectType`1.CreateConfiguration(ITypeDiscoveryContext context) in ObjectType~1.cs:line 47 at HotChocolate.Types.TypeSystemObject`1.Initialize(ITypeDiscoveryContext context) in TypeSystemObjectBase~1.cs:line 29