Skip to content

CSHARP-6161: Enable the code-style rules that need little or no reformatting - #2092

Open
papafe wants to merge 1 commit into
mongodb:mainfrom
papafe:csharp6161
Open

CSHARP-6161: Enable the code-style rules that need little or no reformatting#2092
papafe wants to merge 1 commit into
mongodb:mainfrom
papafe:csharp6161

Conversation

@papafe

@papafe papafe commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

…matting

Turns on the agreed severities for CS-CF-02 (braces), CS-TV-02 (modifier
order), CS-CF-08 (using declaration), CS-NM-04 (interface prefix) and flips the
CS-EL-11 index/range keys now that those operators are allowed. CS-EX-01 and
CS-CF-05 were already at the agreed severity.

Code changes are limited to what the new severities require: the 36 files of
modifier reordering (applied with dotnet format --diagnostics IDE0036) and one
missing pair of braces on an else.
@papafe
papafe requested a review from a team as a code owner August 4, 2026 13:43
@papafe
papafe requested review from ajcvickers and Copilot August 4, 2026 13:43
@papafe papafe added the maintenance Non-code maintenance (deps, docs, configs, etc.). label Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates repository code-style configuration and applies low-impact formatting changes across the driver and test code to comply with newly-enabled analyzers (primarily modifier ordering and related style rules).

Changes:

  • Tightens/adjusts .editorconfig style severities (notably csharp_preferred_modifier_order to warning) and enables a naming rule for interface I-prefixing.
  • Applies widespread modifier-order fixes (static readonly, public new, etc.) across src/ and tests/.
  • Includes a behavioral change in CombinedProjectionDefinition<TSource> flattening logic (adds non-combined projections into the combined list), which should be confirmed as intended for a “style-only” PR.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/SkippableTestMessageBus.cs Reorders static readonly field modifiers to match preferred modifier order.
tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs Reorders static readonly schema constants (and array) modifiers for style compliance.
tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/JoinAfterSelectManyToPipelineTests.cs Reorders static test fixture fields’ modifiers to preferred order.
tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterHeartbeatConcurrencyTests.cs Reorders static test fields’ modifiers to preferred order.
tests/MongoDB.Driver.Tests/Core/Clusters/MultiServerClusterHandshakeNetworkErrorTests.cs Reorders static test fields’ modifiers to preferred order.
tests/MongoDB.Bson.Tests/Serialization/Serializers/MemorySerializerTests.cs Reorders TestData member modifiers to preferred order.
tests/MongoDB.Bson.Tests/Serialization/Serializers/BinaryVectorSerializerTests.cs Reorders TestData members’ modifiers to preferred order.
src/MongoDB.Driver/ProjectionDefinitionBuilder.cs Fixes modifier/style and updates combined-projection flattening logic (functional change).
src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/MethodTranslators/InjectMethodToFilterTranslator.cs Reorders static readonly field modifiers to preferred order.
src/MongoDB.Driver/Linq/Linq3Implementation/Misc/ConvertHelper.cs Reorders static readonly field modifiers to preferred order.
src/MongoDB.Driver/Linq/Linq3Implementation/Ast/AstSortField.cs Reorders static readonly cached instances’ modifiers to preferred order.
src/MongoDB.Driver/GridFS/GridFSFileInfoCompat.cs Reorders public new property modifiers to preferred order.
src/MongoDB.Driver/GridFS/GridFSFileInfo.cs Reorders public new property modifiers to preferred order.
src/MongoDB.Driver/DensifyRange.cs Reorders static readonly cached instances’ modifiers to preferred order.
src/MongoDB.Driver/Core/Logging/StructuredLogTemplateProviders.cs Reorders static readonly field modifiers to preferred order.
src/MongoDB.Driver/Core/Clusters/ServerSelectors/WritableServerSelector.cs Reorders singleton instance field modifiers to preferred order.
src/MongoDB.Driver/Core/ChangeStreamDocument.cs Reorders public new property modifiers to preferred order.
src/MongoDB.Driver/ChangeStreamPreAndPostImagesOptions.cs Reorders public new property modifiers to preferred order.
src/MongoDB.Driver/AsyncCursorHelper.cs Reorders static async method modifiers to preferred order.
src/MongoDB.Bson/Serialization/Serializers/ObjectSerializer.cs Reorders static readonly fields in allowed-types implementation to preferred order.
src/MongoDB.Bson/Serialization/Serializers/NullableSerializer.cs Reorders cached serializer instance fields’ modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonTimestamp.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonSymbol.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonString.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonRegularExpression.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonObjectId.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonJavaScriptWithScope.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonJavaScript.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonInt64.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonInt32.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonDouble.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonDocument.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonDecimal128.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonDateTime.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonBoolean.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonBinaryData.cs Reorders public static new factory method modifiers to preferred order.
src/MongoDB.Bson/ObjectModel/BsonArray.cs Reorders public static new factory method modifiers to preferred order.
.editorconfig Enables/adjusts analyzer rules and severities (modifier order warning, braces preference, using statement preference, interface naming suggestion).

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

Comment on lines 981 to 985
else
{
current.Add(projection);
}
return current;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Non-code maintenance (deps, docs, configs, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants