Skip to content

Fix various analyzer errors#9474

Merged
glen-84 merged 1 commit intomainfrom
gai/fix-analyzer-errors
Mar 28, 2026
Merged

Fix various analyzer errors#9474
glen-84 merged 1 commit intomainfrom
gai/fix-analyzer-errors

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented Mar 28, 2026

Summary of the changes (Less than 80 chars)

  • Fix various analyzer errors.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 using directives 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.VoidVoid).
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

  • capturedResponseType is inferred as non-nullable Type via var, but the middleware callback is Action<Type?> and later assertions expect it to become null. With nullable warnings treated as errors in this repo, assigning a Type? to Type will fail the build. Declare this as Type? (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: capturedResponseType is inferred as non-nullable Type, but CaptureTypesMiddleware may assign null (Action<Type?>) and the test asserts Assert.Null(capturedResponseType). This will trigger nullable warnings (treated as errors). Use Type? here as well.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glen-84 glen-84 merged commit 1537f8e into main Mar 28, 2026
131 checks passed
@glen-84 glen-84 deleted the gai/fix-analyzer-errors branch March 28, 2026 14:08
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (b461ecb) to head (1a09edc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9474   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants