CSHARP-6161: Enable the code-style rules that need little or no reformatting - #2092
Open
papafe wants to merge 1 commit into
Open
CSHARP-6161: Enable the code-style rules that need little or no reformatting#2092papafe wants to merge 1 commit into
papafe wants to merge 1 commit into
Conversation
…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.
Contributor
There was a problem hiding this comment.
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
.editorconfigstyle severities (notablycsharp_preferred_modifier_ordertowarning) and enables a naming rule for interfaceI-prefixing. - Applies widespread modifier-order fixes (
static readonly,public new, etc.) acrosssrc/andtests/. - 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; |
ajcvickers
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://jira.mongodb.org/browse/CSHARP-6161