Skip to content

Commit 8154a51

Browse files
committed
CSHARP-5782: Add .NET10 to unittests and smoke tests
1 parent cf91a58 commit 8154a51

File tree

17 files changed

+138
-22
lines changed

17 files changed

+138
-22
lines changed

evergreen/evergreen.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,13 @@ tasks:
11271127
FRAMEWORK: net6.0
11281128
- func: run-unit-tests
11291129

1130+
- name: unit-tests-net100
1131+
commands:
1132+
- func: configure-framework
1133+
vars:
1134+
FRAMEWORK: net10.0
1135+
- func: run-unit-tests
1136+
11301137
- name: test-net472
11311138
commands:
11321139
- func: setup-csfle-secrets
@@ -1701,6 +1708,17 @@ tasks:
17011708
- func: bootstrap-mongo-orchestration
17021709
- func: run-smoke-tests
17031710

1711+
- name: test-smoke-tests-net100
1712+
depends_on:
1713+
- name: push-packages-myget
1714+
variant: ".push-packages-myget"
1715+
commands:
1716+
- func: configure-framework
1717+
vars:
1718+
FRAMEWORK: net10.0
1719+
- func: bootstrap-mongo-orchestration
1720+
- func: run-smoke-tests
1721+
17041722
- name: test-csharp-spec-benchmarks
17051723
commands:
17061724
- func: bootstrap-mongo-orchestration
@@ -2380,6 +2398,7 @@ buildvariants:
23802398
- name: unit-tests-net472
23812399
- name: unit-tests-netstandard21
23822400
- name: unit-tests-net60
2401+
- name: unit-tests-net100
23832402

23842403
- name: unit-tests-ubuntu
23852404
display_name: Unit Tests on Ubuntu
@@ -2389,6 +2408,7 @@ buildvariants:
23892408
tasks:
23902409
- name: unit-tests-netstandard21
23912410
- name: unit-tests-net60
2411+
- name: unit-tests-net100
23922412

23932413
- name: unit-tests-macos
23942414
display_name: Unit Tests on MacOs
@@ -2398,6 +2418,7 @@ buildvariants:
23982418
tasks:
23992419
- name: unit-tests-netstandard21
24002420
- name: unit-tests-net60
2421+
- name: unit-tests-net100
24012422

24022423
- name: unit-tests-macos-arm
24032424
display_name: Unit Tests on MacOs Arm
@@ -2406,6 +2427,7 @@ buildvariants:
24062427
OS: "macos-14-arm64"
24072428
tasks:
24082429
- name: unit-tests-net60
2430+
- name: unit-tests-net100
24092431

24102432
- matrix_name: stable-api-tests
24112433
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: ["standalone", "sharded-cluster"], auth: "auth", ssl: "nossl", os: "windows-64" }
@@ -2778,6 +2800,7 @@ buildvariants:
27782800
- name: test-smoke-tests-net50
27792801
- name: test-smoke-tests-net60
27802802
- name: test-smoke-tests-net80
2803+
- name: test-smoke-tests-net100
27812804
rules:
27822805
- if: { version: "*", topology: "*", ssl: "*", os: ["ubuntu-2004", "macos-14"] }
27832806
then:

evergreen/install-dotnet.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -o errexit # Exit the script with error if any of the commands fail
33

44
DOTNET_ROOT="${DOTNET_ROOT:-./.dotnet}"
5-
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-8.0}"
5+
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-10.0}"
66

77
echo "runtime: $FRAMEWORK"
88

@@ -13,6 +13,8 @@ if [ -n "$FRAMEWORK" ]; then
1313
RUNTIME_VERSION="6.0"
1414
elif [ "$FRAMEWORK" = "net8.0" ]; then
1515
RUNTIME_VERSION="8.0"
16+
elif [ "$FRAMEWORK" = "net10.0" ]; then
17+
RUNTIME_VERSION="10.0"
1618
elif [ "$FRAMEWORK" = "netstandard2.1" ]; then
1719
RUNTIME_VERSION="3.1"
1820
elif [ "$FRAMEWORK" = "netcoreapp3.1" ]; then

tests/BuildProps/Tests.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<PropertyGroup>
9-
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
9+
<TargetFrameworks>netcoreapp3.1;net6.0;net10.0</TargetFrameworks>
1010
<TargetFrameworks Condition="'$(IsWindows)'=='true'">$(TargetFrameworks);net472</TargetFrameworks>
1111
<IsPackable>false</IsPackable>
1212
<SignAssembly>true</SignAssembly>

tests/MongoDB.Bson.Tests/IO/BsonStreamAdapterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ public void Read_should_throw_when_subject_is_disposed()
599599
var count = 2;
600600
subject.Dispose();
601601

602+
#pragma warning disable CA2022
602603
Action action = () => subject.Read(buffer, offset, count);
604+
#pragma warning restore CA2022
603605

604606
action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
605607
}

tests/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ public void Read_should_throw_when_buffer_is_null()
362362
{
363363
var subject = CreateSubject();
364364

365+
#pragma warning disable CA2022
365366
Action action = () => subject.Read(null, 0, 0);
367+
#pragma warning restore CA2022
366368

367369
action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("buffer");
368370
}
@@ -379,7 +381,9 @@ public void Read_should_throw_when_count_is_out_of_range(int destinationSize, in
379381
var subject = CreateSubject();
380382
var destination = new byte[destinationSize];
381383

384+
#pragma warning disable CA2022
382385
Action action = () => subject.Read(destination, offset, count);
386+
#pragma warning restore CA2022
383387

384388
action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("count");
385389
}
@@ -394,7 +398,9 @@ public void Read_should_throw_when_offset_is_out_of_range(int destinationSize, i
394398
var subject = CreateSubject();
395399
var destination = new byte[destinationSize];
396400

401+
#pragma warning disable CA2022
397402
Action action = () => subject.Read(destination, offset, 0);
403+
#pragma warning restore CA2022
398404

399405
action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("offset");
400406
}
@@ -405,7 +411,9 @@ public void Read_should_throw_when_subject_is_disposed()
405411
var subject = CreateDisposedSubject();
406412
var destination = new byte[1];
407413

414+
#pragma warning disable CA2022
408415
Action action = () => subject.Read(destination, 0, 1);
416+
#pragma warning restore CA2022
409417

410418
action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("ByteBufferStream");
411419
}

tests/MongoDB.Bson.Tests/Serialization/BsonClassMapTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,9 @@ private BsonClassMap WithKnownTypes(BsonClassMap classMap, List<Type> value)
681681

682682
private BsonClassMap Clone(BsonClassMap classMap)
683683
{
684+
#pragma warning disable SYSLIB0050
684685
var clone = (BsonClassMap)FormatterServices.GetUninitializedObject(classMap.GetType());
686+
#pragma warning restore SYSLIB0050
685687
Reflector.SetFieldValue(clone, "_baseClassMap", Reflector.GetFieldValue(classMap, "_baseClassMap"));
686688
Reflector.SetFieldValue(clone, "_classType", Reflector.GetFieldValue(classMap, "_classType"));
687689
Reflector.SetFieldValue(clone, "_creator", Reflector.GetFieldValue(classMap, "_creator"));

tests/MongoDB.Bson.Tests/Serialization/BsonMemberMapTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ private BsonMemberMap CreateBsonMemberMap()
411411

412412
private BsonMemberMap Clone(BsonMemberMap memberMap)
413413
{
414+
#pragma warning disable SYSLIB0050
414415
var clone = (BsonMemberMap)FormatterServices.GetUninitializedObject(memberMap.GetType());
416+
#pragma warning restore SYSLIB0050
415417
Reflector.SetFieldValue(clone, "_classMap", Reflector.GetFieldValue(memberMap, "_classMap"));
416418
Reflector.SetFieldValue(clone, "_defaultValue", Reflector.GetFieldValue(memberMap, "_defaultValue"));
417419
Reflector.SetFieldValue(clone, "_defaultValueCreator", Reflector.GetFieldValue(memberMap, "_defaultValueCreator"));

tests/MongoDB.Driver.Examples/MongoDB.Driver.Examples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1717
</ItemGroup>
1818

19-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net6.0'">
19+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net10.0'">
2020
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
2121
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.2.0" />
2222
</ItemGroup>

tests/MongoDB.Driver.TestHelpers/Core/CoreTestConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ public static ClusterBuilder ConfigureCluster(ClusterBuilder builder)
151151
X509Certificate cert;
152152
if (password == null)
153153
{
154-
cert = new X509Certificate2(certificateFilename);
154+
cert = X509CertificateLoader.LoadCertificateFromFile(certificateFilename);
155155
}
156156
else
157157
{
158-
cert = new X509Certificate2(certificateFilename, password);
158+
cert = X509CertificateLoader.LoadPkcs12FromFile(certificateFilename, password);
159159
}
160160
return ssl.With(
161161
clientCertificates: new[] { cert });
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Copyright 2010-present MongoDB Inc.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using System;
17+
using System.Security.Cryptography.X509Certificates;
18+
19+
namespace MongoDB.Driver.TestHelpers;
20+
21+
#if !NET8_0_OR_GREATER
22+
23+
public static class X509CertificateLoader
24+
{
25+
public static X509Certificate2 LoadCertificate(ReadOnlySpan<byte> certificateData) =>
26+
new(certificateData.ToArray());
27+
28+
public static X509Certificate2 LoadCertificateFromFile(string certificateFilename) =>
29+
new (certificateFilename);
30+
31+
public static X509Certificate2 LoadPkcs12FromFile(string certificateFilename, string password) =>
32+
new(certificateFilename, password);
33+
}
34+
35+
#endif

0 commit comments

Comments
 (0)