Skip to content

Use null-conditional assignment#9561

Merged
glen-84 merged 1 commit intomainfrom
gai/null-conditional-assignment
Apr 16, 2026
Merged

Use null-conditional assignment#9561
glen-84 merged 1 commit intomainfrom
gai/null-conditional-assignment

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented Apr 16, 2026

Summary of the changes (Less than 80 chars)

  • Use null-conditional assignment.

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 applies null-propagation / null-conditional assignment patterns across multiple projects (HotChocolate, Fusion, StrawberryShake, Mocha, GreenDonut) and enables the corresponding ReSharper highlighting to encourage the style consistently.

Changes:

  • Replaced explicit null checks/early-returns with null-propagation (?., ??) and null-conditional assignment patterns.
  • Simplified several small helper methods and disposal/enrichment blocks by using conditional access chaining.
  • Enabled resharper_use_null_propagation_highlighting = warning in .editorconfig and added a targeted suppression comment where needed.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/StrawberryShake/Client/src/Transport.Http/HttpConnection.cs Uses null-conditional assignment when writing into an optional copy dictionary.
src/Mocha/src/Mocha/Instrumentation/ActivityMessagingDiagnosticListener.cs Simplifies activity enrichment blocks using conditional access chaining.
src/HotChocolate/Fusion/src/Fusion.Utilities/Rewriters/DocumentRewriter.cs Uses null-propagation when removing references from an optional dictionary.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/Partitioners/SelectionSetPartitioner.cs Collapses a null-check + return into a single null-propagating query.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs Simplifies disposal of singleResult with conditional access.
src/HotChocolate/Core/test/Types.Tests/SchemaBuilderTests.cs Uses null-conditional assignment when mutating optional configuration in a test.
src/HotChocolate/Core/src/Types/Types/Directive.cs Uses null-conditional assignment for optional rewritten-argument buffer.
src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DescriptorContext.Services.cs Simplifies GetService<T> fallback behavior with ??.
src/HotChocolate/Core/src/Types/Execution/Processing/VariableRewriter.cs Uses null-conditional assignment when populating optional rewritten buffers.
src/HotChocolate/Core/src/Types/Configuration/AggregateTypeInterceptor.cs Uses null-conditional assignment when appending into optional temp array.
src/HotChocolate/Core/src/Types.Analyzers/WrongAuthorizationAttributeCodeFixProvider.cs Adds a targeted ReSharper suppression comment for a known issue.
src/HotChocolate/Core/src/Types.Analyzers/NodeResolverIdParameterCodeFixProvider.cs Removes an early-return in favor of null-propagation when locating nodes.
src/HotChocolate/Core/src/Types.Analyzers/IdAttributeOnRecordParameterCodeFixProvider.cs Removes an early-return in favor of null-propagation when locating nodes.
src/HotChocolate/Core/src/Types.Analyzers/Helpers/SymbolExtensions.cs Uses null-propagation to return null when type symbol resolution fails.
src/HotChocolate/Core/src/Types.Analyzers/Helpers/GeneratorUtils.cs Uses null-propagation to return null for string escaping when input is null.
src/HotChocolate/Core/src/Abstractions/ExtensionData.cs Simplifies CopyTo with nullable interface cast + conditional call.
src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/TestHelper.cs Uses ?.Invoke for optional mock setup callback.
src/GreenDonut/src/GreenDonut.Data.EntityFramework/Extensions/PagingQueryableExtensions.cs Uses null-conditional assignment when clearing an optional interceptor holder.
.editorconfig Enables ReSharper null-propagation highlighting as a warning.

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

@glen-84 glen-84 merged commit 74d8c51 into main Apr 16, 2026
138 checks passed
@glen-84 glen-84 deleted the gai/null-conditional-assignment branch April 16, 2026 14:26
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

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

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

☔ 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