Conversation
There was a problem hiding this comment.
Pull request overview
This PR focuses on resolving analyzer/compiler issues across the Mocha and HotChocolate codebases by cleaning up unused usings, aligning formatting, and modernizing C# syntax (type inference, collection expressions, method groups).
Changes:
- Simplify generic calls (e.g.,
SendAsync<T>→SendAsync) and DI registrations via type inference. - Remove unused
usingdirectives and apply formatting tweaks/modern C# constructs (collection expressions, projection initializers). - Minor refactors in runtime/builder code to satisfy formatting/analyzer rules.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Mocha/test/Mocha.Mediator.Tests/NotificationStrategyTests.cs | Simplifies AddScoped registrations via type inference. |
| src/Mocha/test/Mocha.Mediator.Tests/NamedMediatorTests.cs | Removes explicit SendAsync<string> type arguments. |
| src/Mocha/test/Mocha.Mediator.Tests/MiddlewarePipelineTests.cs | Removes explicit SendAsync<string> type arguments; minor DI registration simplification. |
| src/Mocha/test/Mocha.Mediator.Tests/MiddlewareFactoryContextTests.cs | Refactors SendAsync<string> usage and adjusts middleware opt-out blocks; introduces nullability issue. |
| src/Mocha/test/Mocha.Mediator.Tests/ContextPoolingTests.cs | Removes explicit SendAsync<string> type arguments. |
| src/Mocha/test/Mocha.Mediator.Tests/AddHandlerTests.cs | Uses method group for Assert.Throws call. |
| src/Mocha/test/Mocha.Analyzers.Tests/TestHelper.cs | Removes unnecessary using; simplifies typeof(...) references for metadata references. |
| src/Mocha/test/Mocha.Analyzers.Tests/MessagingTestHelper.cs | Removes unused using Mocha.Analyzers;. |
| src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs | Formatting changes; list initialization cleanup; adds #pragma to silence formatting analyzer in a ternary block. |
| src/Mocha/src/Mocha.Mediator/Pipeline/PipelineBuilder.cs | Removes unused using. |
| src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorServiceCollectionExtensions.cs | Uses generic type inference for TryAdd* registrations. |
| src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorHostBuilderExtensions.cs | Removes unused using. |
| src/Mocha/src/Mocha.Mediator.Abstractions/Unit.cs | XML doc cref simplified (System.Void → Void). |
| src/Mocha/src/Mocha.Analyzers/Utils/ImmutableEquatableArray.cs | Uses collection expression for empty immutable array creation. |
| src/Mocha/src/Mocha.Analyzers/MediatorGenerator.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/KnownTypeSymbols.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/NotificationHandlerInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/MultipleHandlerInterfaceInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/MessagingHandlerInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/MessageTypeInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/ISyntaxInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/HandlerInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/AbstractMessagingHandlerInspector.cs | Removes unused using. |
| src/Mocha/src/Mocha.Analyzers/Inspectors/AbstractHandlerInspector.cs | Removes unused using. |
| src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Transport/Http/DefaultGraphQLHttpClientTests.cs | Replaces ImmutableArray.Create(...) with collection expressions; removes unused using. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/CancellationTests.cs | Removes unused using. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/JsonVariableCoercion.cs | Removes unused using. |
| src/HotChocolate/Fusion/src/Fusion.Execution/DependencyInjection/HotChocolateFusionServiceCollectionExtensions.cs | Removes unused using. |
| src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs | Removes unused using. |
| src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs | Removes unused using. |
| src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpResponse.cs | Removes unused using under conditional compilation. |
| src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpRequest.cs | Removes unused using under conditional compilation. |
| src/HotChocolate/AspNetCore/src/Transport.Http/GraphQLHttpClientExtensions.cs | Removes unused using under conditional compilation. |
| src/HotChocolate/AspNetCore/src/Transport.Http/DefaultGraphQLHttpClient.cs | Reorders/conditions usings; formatting fixes; small collection-expression spacing adjustment. |
| src/GreenDonut/test/GreenDonut.Data.EntityFramework.Tests/PagingHelperIntegrationTests.cs | Uses anonymous-type projection initializers (page.Value.Items) instead of explicit member name. |
Comments suppressed due to low confidence (2)
src/Mocha/test/Mocha.Mediator.Tests/MiddlewareFactoryContextTests.cs:35
capturedResponseTypeis inferred as non-nullableTypeviavar, but the middleware callback isAction<Type?>and later assertions expect it to becomenull. With nullable warnings treated as errors in this repo, assigning aType?toTypewill fail the build. Declare this asType?(e.g.,Type? capturedResponseType = typeof(object);) so the null assignment is valid.
src/Mocha/test/Mocha.Mediator.Tests/MiddlewareFactoryContextTests.cs:73- Same issue as above:
capturedResponseTypeis inferred as non-nullableType, butCaptureTypesMiddlewaremay assignnull(Action<Type?>) and the test assertsAssert.Null(capturedResponseType). This will trigger nullable warnings (treated as errors). UseType?here as well.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9474 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of the changes (Less than 80 chars)