Skip to content

Conversation

@BorisDog
Copy link
Contributor

@BorisDog BorisDog commented Dec 1, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 1, 2025 20:20
@BorisDog BorisDog requested a review from a team as a code owner December 1, 2025 20:20
@BorisDog BorisDog requested a review from ajcvickers December 1, 2025 20:20
@BorisDog BorisDog added the chore Non–user-facing code changes (tests, build scripts, etc.). label Dec 1, 2025
@BorisDog BorisDog requested review from sanych-sun and removed request for ajcvickers December 1, 2025 20:21
Copy link
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 adds C# 14 testing infrastructure to the MongoDB C# driver project to ensure compatibility with the upcoming C# 14 language version. The changes include creating a new Release_CSharp_14 build configuration, updating test code to be compatible with C# 14 syntax changes, and configuring CI/CD pipelines to run tests with C# 14.

  • Added new Release_CSharp_14 build configuration with LangVersion 14 for test projects while keeping source projects on C# 12
  • Updated test code to address C# 14 breaking changes: escaped field identifiers, explicit array syntax for string.Concat, and disambiguated Reverse() calls
  • Configured CI/CD to run unit tests with C# 14 on .NET 10.0 across all platforms

Reviewed changes

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

Show a summary per file
File Description
tests/BuildProps/Tests.Build.props Added Release_CSharp_14 configuration with LangVersion 14 and CSHARP_14 conditional compilation symbol
src/Directory.Build.props Added Release_CSharp_14 configuration for source projects (keeps LangVersion at 12)
CSharpDriver.sln Added Release_CSharp_14 configuration mappings for all projects in the solution
evergreen/evergreen.yml Added unit-tests-net100-v14 task for C# 14 testing on all platforms (Windows, Ubuntu, macOS)
evergreen/run-unit-tests.sh Added CONFIGURATION environment variable support with default to 'Release'
evergreen/compile-sources.sh Added CONFIGURATION environment variable support for build command
tests/MongoDB.Bson.Tests/Serialization/ExtensionMembersTests.cs New test file validating C# 14 extension members feature compatibility with serialization
tests/MongoDB.Bson.Tests/IO/*.cs (8 files) Renamed field variables to @field to avoid conflicts with C# 14's contextual keyword in property accessors
tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationWithLinq2Tests/Translators/AggregateProjectTranslatorTests.cs Cast to IEnumerable before calling Reverse() to disambiguate overload resolution
tests/MongoDB.Driver.Encryption.Tests/BasicTests.cs Changed to Enumerable.Reverse() static method to avoid C# 14 overload ambiguity
tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Translators/ExpressionToAggregationExpressionTranslators/MethodTranslators/StringConcatMethodToAggregationExpressionTranslatorTests.cs Updated string.Concat calls to use explicit array syntax instead of params
tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp5071Tests.cs Updated string.Concat calls to use explicit array syntax in 22 test cases
tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp5749Tests.cs Reformatted long method call lines for better readability

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

"stringconstant+stringproperty+stringconstant" => collection.AsQueryable().Select(x => string.Concat(new[] { "X" + x.B + "Z" })),
"stringconstant+stringproperty+stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { "X" + x.B + x.C })),
"stringproperty+intconstant+stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { x.A + 2 + x.C })),
"stringproperty+intproperty+stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { x.A + x.J + x.C})),
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

Missing space before the closing brace. Should be x.C } instead of x.C} for consistency with the other lines in this switch expression.

Suggested change
"stringproperty+intproperty+stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { x.A + x.J + x.C})),
"stringproperty+intproperty+stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { x.A + x.J + x.C })),

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

damieng
damieng previously approved these changes Dec 4, 2025
Copy link
Member

@damieng damieng left a comment

Choose a reason for hiding this comment

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

Just one minor optional suggestion.

var field = _instance.GetType().GetField("_disposed", BindingFlags.NonPublic | BindingFlags.Instance);
return (bool)field.GetValue(_instance);
var @field = _instance.GetType().GetField("_disposed", BindingFlags.NonPublic | BindingFlags.Instance);
return (bool)@field.GetValue(_instance);
Copy link
Member

Choose a reason for hiding this comment

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

A static extension method on Object called GetPrivateValue(string name) would be useful in this test lib and reduce a lot of boilerplate/noise across all these methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something very much like that exists in the Reflector.cs file in the MongoDB.Bson.TestHelpers project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

{
"intproperty" => collection.AsQueryable().Select(x => string.Concat(x.I)),
"stringproperty" => collection.AsQueryable().Select(x => string.Concat(x.A)),
"stringproperty" => collection.AsQueryable().Select(x => string.Concat(new[] { x.A })),
Copy link
Member

Choose a reason for hiding this comment

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

Another one to add to the C# 14/.NET 10 gotcha list I suspect.

sanych-sun
sanych-sun previously approved these changes Dec 5, 2025
Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

LGTM + minor comments

}

static Expression VisitSequenceEqualMethod(MethodCallExpression node, MethodInfo method, ReadOnlyCollection<Expression> arguments)
static Expression VisitSequenceEqualMethod(MethodCallExpression node, MethodInfo method,
Copy link
Member

Choose a reason for hiding this comment

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

Minor: all parameters on the same line, or each on it's own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, not sure how this happened.

Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

LGTM

@BorisDog BorisDog merged commit fe6f12f into mongodb:main Dec 5, 2025
33 of 36 checks passed
@BorisDog BorisDog deleted the csharp5797 branch December 5, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Non–user-facing code changes (tests, build scripts, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants