Skip to content

Commit 27d4661

Browse files
authored
CSHARP-4904: Add .NET 6 target framework (#1445)
1 parent aa61ebe commit 27d4661

32 files changed

+165
-146
lines changed

evergreen/evergreen.yml

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,13 @@ tasks:
11561156
vars:
11571157
FRAMEWORK: netstandard21
11581158

1159+
- name: test-net60
1160+
commands:
1161+
- func: bootstrap-mongo-orchestration
1162+
- func: run-tests
1163+
vars:
1164+
FRAMEWORK: net60
1165+
11591166
- name: test-csfle-with-mongocryptd-net472
11601167
commands:
11611168
- func: bootstrap-mongo-orchestration
@@ -1170,6 +1177,13 @@ tasks:
11701177
vars:
11711178
FRAMEWORK: netstandard21
11721179

1180+
- name: test-csfle-with-mongocryptd-net60
1181+
commands:
1182+
- func: bootstrap-mongo-orchestration
1183+
- func: run-csfle-with-mongocryptd-tests
1184+
vars:
1185+
FRAMEWORK: net60
1186+
11731187
- name: test-csfle-with-mocked-kms-tls-net472
11741188
commands:
11751189
- func: start-kms-mock-servers
@@ -1192,6 +1206,17 @@ tasks:
11921206
vars:
11931207
FRAMEWORK: netstandard21
11941208

1209+
- name: test-csfle-with-mocked-kms-tls-net60
1210+
commands:
1211+
- func: start-kms-mock-servers
1212+
- func: start-kms-mock-kmip-server
1213+
- func: start-kms-mock-gcp-server
1214+
- func: start-kms-mock-azure-imds-server
1215+
- func: bootstrap-mongo-orchestration
1216+
- func: run-csfle-with-mocked-kms-tests
1217+
vars:
1218+
FRAMEWORK: net60
1219+
11951220
- name: test-load-balancer-netstandard21
11961221
commands:
11971222
- func: bootstrap-mongo-orchestration
@@ -1203,6 +1228,17 @@ tasks:
12031228
FRAMEWORK: netstandard21
12041229
- func: stop-load-balancer
12051230

1231+
- name: test-load-balancer-net60
1232+
commands:
1233+
- func: bootstrap-mongo-orchestration
1234+
vars:
1235+
LOAD_BALANCER: 'true'
1236+
- func: run-load-balancer
1237+
- func: run-load-balancer-tests
1238+
vars:
1239+
FRAMEWORK: net60
1240+
- func: stop-load-balancer
1241+
12061242
- name: atlas-connectivity-tests
12071243
commands:
12081244
- func: assume-ec2-role
@@ -1224,6 +1260,12 @@ tasks:
12241260
vars:
12251261
FRAMEWORK: netstandard21
12261262

1263+
- name: test-gssapi-net60
1264+
commands:
1265+
- func: run-gssapi-auth-tests
1266+
vars:
1267+
FRAMEWORK: net60
1268+
12271269
- name: plain-auth-tests
12281270
commands:
12291271
- func: run-plain-auth-tests
@@ -1266,6 +1308,16 @@ tasks:
12661308
FRAMEWORK: netstandard21
12671309
REQUIRE_API_VERSION: true
12681310

1311+
- name: stable-api-tests-net60
1312+
commands:
1313+
- func: bootstrap-mongo-orchestration
1314+
vars:
1315+
REQUIRE_API_VERSION: true
1316+
- func: run-tests
1317+
vars:
1318+
FRAMEWORK: net60
1319+
REQUIRE_API_VERSION: true
1320+
12691321
- name: atlas-data-lake-test
12701322
commands:
12711323
- func: bootstrap-mongohoused
@@ -2028,6 +2080,10 @@ axes:
20282080
display_name: netstandard21
20292081
variables:
20302082
FRAMEWORK: netstandard21
2083+
- id: "net60"
2084+
display_name: net60
2085+
variables:
2086+
FRAMEWORK: net60
20312087

20322088
- id: serverless
20332089
display_name: Serverless
@@ -2321,6 +2377,7 @@ buildvariants:
23212377
tasks:
23222378
- name: stable-api-tests-net472
23232379
- name: stable-api-tests-netstandard21
2380+
- name: stable-api-tests-net60
23242381

23252382
# Secure tests
23262383
- matrix_name: "secure-tests-windows"
@@ -2330,27 +2387,31 @@ buildvariants:
23302387
tasks:
23312388
- name: test-net472
23322389
- name: test-netstandard21
2390+
- name: test-net60
23332391

23342392
- matrix_name: "secure-tests-macOS"
23352393
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: "replicaset", auth: "auth", ssl: "ssl", os: ["macos-14", "macos-14-arm64"] }
23362394
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23372395
tags: ["tests-variant"]
23382396
tasks:
23392397
- name: test-netstandard21
2398+
- name: test-net60
23402399

23412400
- matrix_name: "secure-tests-linux-1804"
23422401
matrix_spec: { version: ["4.0", "4.2", "4.4", "5.0", "6.0"], topology: "*", auth: "auth", ssl: "ssl", os: "ubuntu-1804" }
23432402
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23442403
tags: ["tests-variant"]
23452404
tasks:
23462405
- name: test-netstandard21
2406+
- name: test-net60
23472407

23482408
- matrix_name: "secure-tests-linux-2004"
23492409
matrix_spec: { version: ["7.0", "8.0", "rapid", "latest"], topology: "*", auth: "auth", ssl: "ssl", os: "ubuntu-2004" }
23502410
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23512411
tags: ["tests-variant"]
23522412
tasks:
23532413
- name: test-netstandard21
2414+
- name: test-net60
23542415

23552416
# Unsecure tests
23562417
- matrix_name: "unsecure-tests-windows"
@@ -2360,27 +2421,31 @@ buildvariants:
23602421
tasks:
23612422
- name: test-net472
23622423
- name: test-netstandard21
2424+
- name: test-net60
23632425

23642426
- matrix_name: "unsecure-tests-macOS"
23652427
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: "replicaset", auth: "noauth", ssl: "nossl", os: ["macos-14", "macos-14-arm64"] }
23662428
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23672429
tags: ["tests-variant"]
23682430
tasks:
23692431
- name: test-netstandard21
2432+
- name: test-net60
23702433

23712434
- matrix_name: "unsecure-tests-linux-1804"
23722435
matrix_spec: { version: ["4.0", "4.2", "4.4", "5.0", "6.0"], topology: "*", auth: "noauth", ssl: "nossl", os: "ubuntu-1804" }
23732436
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23742437
tags: ["tests-variant"]
23752438
tasks:
23762439
- name: test-netstandard21
2440+
- name: test-net60
23772441

23782442
- matrix_name: "unsecure-tests-linux-2004"
23792443
matrix_spec: { version: ["7.0", "8.0", "rapid", "latest"], topology: "*", auth: "noauth", ssl: "nossl", os: "ubuntu-2004" }
23802444
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
23812445
tags: ["tests-variant"]
23822446
tasks:
23832447
- name: test-netstandard21
2448+
- name: test-net60
23842449

23852450
# Compression tests
23862451
- matrix_name: "tests-compression-windows"
@@ -2390,27 +2455,31 @@ buildvariants:
23902455
tasks:
23912456
- name: test-net472
23922457
- name: test-netstandard21
2458+
- name: test-net60
23932459

23942460
- matrix_name: "tests-compression-macOS"
23952461
matrix_spec: { compressor : ["snappy", "zstandard"], auth: "noauth", ssl: "nossl", version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: "standalone", os: ["macos-14", "macos-14-arm64"] }
23962462
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${os} "
23972463
tags: ["tests-variant"]
23982464
tasks:
23992465
- name: test-netstandard21
2466+
- name: test-net60
24002467

24012468
- matrix_name: "tests-compression-linux-1804"
24022469
matrix_spec: { compressor: "*", auth: "noauth", ssl: "nossl", version: ["4.0", "4.2", "4.4", "5.0", "6.0"], topology: "standalone", os: "ubuntu-1804" }
24032470
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${os} "
24042471
tags: ["tests-variant"]
24052472
tasks:
24062473
- name: test-netstandard21
2474+
- name: test-net60
24072475

24082476
- matrix_name: "tests-compression-linux-2004"
24092477
matrix_spec: { compressor: "*", auth: "noauth", ssl: "nossl", version: ["7.0", "8.0", "rapid", "latest"], topology: "standalone", os: "ubuntu-2004" }
24102478
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${os} "
24112479
tags: ["tests-variant"]
24122480
tasks:
24132481
- name: test-netstandard21
2482+
- name: test-net60
24142483

24152484
# Auth tests
24162485
- matrix_name: plain-auth-tests
@@ -2474,37 +2543,41 @@ buildvariants:
24742543
tasks:
24752544
- name: test-gssapi-net472
24762545
- name: test-gssapi-netstandard21
2546+
- name: test-gssapi-net60
24772547

24782548
- name: gssapi-auth-tests-linux
24792549
run_on:
24802550
- ubuntu1804-test
24812551
display_name: "GSSAPI (Kerberos) Auth tests - Linux"
24822552
tasks:
24832553
- name: test-gssapi-netstandard21
2554+
- name: test-gssapi-net60
24842555

24852556
# Load balancer tests
24862557
- matrix_name: load-balancer-tests
24872558
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], auth: "noauth", ssl: "nossl", topology: "sharded-cluster", os: "ubuntu-2004" }
24882559
display_name: "Load Balancer ${version} ${auth} ${ssl} ${os}"
24892560
tasks:
24902561
- name: "test-load-balancer-netstandard21"
2562+
- name: "test-load-balancer-net60"
24912563

24922564
- matrix_name: load-balancer-tests-secure
24932565
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], auth: "auth", ssl: "ssl", topology: "sharded-cluster", os: "ubuntu-2004" }
24942566
display_name: "Load Balancer ${version} ${auth} ${ssl} ${os}"
24952567
tasks:
24962568
- name: "test-load-balancer-netstandard21"
2569+
- name: "test-load-balancer-net60"
24972570

24982571
# Serverless tests
24992572
- matrix_name: serverless-tests-windows
2500-
matrix_spec: { auth: "auth", ssl: "ssl", compressor: "zlib", os: "windows-64", target_framework: ["net472", "netstandard21"], serverless: "*" }
2573+
matrix_spec: { auth: "auth", ssl: "ssl", compressor: "zlib", os: "windows-64", target_framework: ["net472", "netstandard21", "net60"], serverless: "*" }
25012574
display_name: "${serverless} ${compressor} ${auth} ${ssl} ${os} ${target_framework}"
25022575
batchtime: 10080 # 7 days
25032576
tasks:
25042577
- name: serverless-task-group
25052578

25062579
- matrix_name: serverless-tests-ubuntu
2507-
matrix_spec: { auth: "auth", ssl: "ssl", compressor: "zlib", os: "ubuntu-2004", target_framework: ["netstandard21"], serverless: "*" }
2580+
matrix_spec: { auth: "auth", ssl: "ssl", compressor: "zlib", os: "ubuntu-2004", target_framework: ["netstandard21", "net60"], serverless: "*" }
25082581
display_name: "${serverless} ${compressor} ${auth} ${ssl} ${os} ${target_framework}"
25092582
batchtime: 10080 # 7 days
25102583
tasks:
@@ -2562,29 +2635,37 @@ buildvariants:
25622635
tasks:
25632636
- name: test-csfle-with-mocked-kms-tls-net472
25642637
- name: test-csfle-with-mocked-kms-tls-netstandard21
2638+
- name: test-csfle-with-mocked-kms-tls-net60
25652639
- name: test-csfle-with-mongocryptd-net472
25662640
- name: test-csfle-with-mongocryptd-netstandard21
2641+
- name: test-csfle-with-mongocryptd-net60
25672642

25682643
- matrix_name: "csfle-with-mocked-kms-tests-linux-1804"
25692644
matrix_spec: { os: "ubuntu-1804", ssl: "nossl", version: ["4.2", "4.4", "5.0", "6.0"], topology: ["replicaset"] }
25702645
display_name: "CSFLE Mocked KMS ${version} ${os}"
25712646
tasks:
25722647
- name: test-csfle-with-mocked-kms-tls-netstandard21
2648+
- name: test-csfle-with-mocked-kms-tls-net60
25732649
- name: test-csfle-with-mongocryptd-netstandard21
2650+
- name: test-csfle-with-mongocryptd-net60
25742651

25752652
- matrix_name: "csfle-with-mocked-kms-tests-linux-2004"
25762653
matrix_spec: { os: "ubuntu-2004", ssl: "nossl", version: ["7.0", "8.0", "rapid", "latest"], topology: ["replicaset"] }
25772654
display_name: "CSFLE Mocked KMS ${version} ${os}"
25782655
tasks:
25792656
- name: test-csfle-with-mocked-kms-tls-netstandard21
2657+
- name: test-csfle-with-mocked-kms-tls-net60
25802658
- name: test-csfle-with-mongocryptd-netstandard21
2659+
- name: test-csfle-with-mongocryptd-net60
25812660

25822661
- matrix_name: "csfle-with-mocked-kms-tests-macOS"
25832662
matrix_spec: { os: ["macos-14", "macos-14-arm64"], ssl: "nossl", version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: ["replicaset"] }
25842663
display_name: "CSFLE Mocked KMS ${version} ${os}"
25852664
tasks:
25862665
- name: test-csfle-with-mocked-kms-tls-netstandard21
2666+
- name: test-csfle-with-mocked-kms-tls-net60
25872667
- name: test-csfle-with-mongocryptd-netstandard21
2668+
- name: test-csfle-with-mongocryptd-net60
25882669

25892670
- matrix_name: "csfle-with-azure-kms-tests-linux"
25902671
matrix_spec: { ssl: "nossl", os: "ubuntu-1804" }
@@ -2593,6 +2674,7 @@ buildvariants:
25932674
tasks:
25942675
- name: testazurekms-task-group
25952676
- name: test-csfle-with-mongocryptd-netstandard21
2677+
- name: test-csfle-with-mongocryptd-net60
25962678

25972679
- matrix_name: "csfle-with-gcp-kms-tests-linux"
25982680
matrix_spec: { ssl: "nossl", os: "ubuntu-1804" }
@@ -2601,6 +2683,7 @@ buildvariants:
26012683
tasks:
26022684
- name: testgcpkms-task-group
26032685
- name: test-csfle-with-mongocryptd-netstandard21
2686+
- name: test-csfle-with-mongocryptd-net60
26042687

26052688
# Smoke tests
26062689
- matrix_name: "smoke-tests-windows"

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55

66
<PropertyGroup>
7-
<TargetFrameworks>netstandard2.1;net472</TargetFrameworks>
7+
<TargetFrameworks>netstandard2.1;net472;net6.0</TargetFrameworks>
88
<LangVersion>10.0</LangVersion>
99
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1010
<CodeAnalysisRuleSet>..\..\MongoDB.ruleset</CodeAnalysisRuleSet>

src/MongoDB.Bson/IO/BsonBinaryReader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ namespace MongoDB.Bson.IO
2525
public class BsonBinaryReader : BsonReader
2626
{
2727
// private fields
28+
#pragma warning disable CA2213 // Disposable never disposed
2829
private readonly Stream _baseStream;
30+
#pragma warning restore CA2213 // Disposable never disposed
2931
private readonly BsonStream _bsonStream;
3032
private BsonBinaryReaderContext _context;
3133

src/MongoDB.Bson/IO/BsonBinaryWriter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ namespace MongoDB.Bson.IO
2525
public class BsonBinaryWriter : BsonWriter
2626
{
2727
// private fields
28+
#pragma warning disable CA2213 // Disposable never disposed
2829
private readonly Stream _baseStream;
30+
#pragma warning restore CA2213 // Disposable never disposed
2931
private readonly BsonStream _bsonStream;
3032
private BsonBinaryWriterContext _context;
3133

src/MongoDB.Bson/IO/JsonWriter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ namespace MongoDB.Bson.IO
2727
public class JsonWriter : BsonWriter
2828
{
2929
// private fields
30-
private TextWriter _textWriter;
30+
#pragma warning disable CA2213 // Disposable never disposed
31+
private readonly TextWriter _textWriter;
32+
#pragma warning restore CA2213 // Disposable never disposed
3133
private JsonWriterContext _context;
3234

3335
// constructors

src/MongoDB.Bson/TargetFramework.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ internal static class TargetFramework
2222
"net472";
2323
#elif NETSTANDARD2_1
2424
"netstandard21";
25+
#elif NET6_0
26+
"net60";
2527
#endif
2628
}
2729
}

src/MongoDB.Driver/Authentication/Oidc/FileOidcCallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public OidcAccessToken GetOidcAccessToken(OidcCallbackParameters parameters, Can
4545

4646
public async Task<OidcAccessToken> GetOidcAccessTokenAsync(OidcCallbackParameters parameters, CancellationToken cancellationToken)
4747
{
48-
#if NETSTANDARD2_1_OR_GREATER
48+
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
4949
var accessToken = await File.ReadAllTextAsync(_path, cancellationToken).ConfigureAwait(false);
5050
#else
5151
using var streamReader = new StreamReader(_path, System.Text.Encoding.UTF8, detectEncodingFromByteOrderMarks: true);

src/MongoDB.Driver/Authentication/Oidc/HttpRequestOidcCallback.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ private HttpWebRequest CreateRequest(OidcCallbackParameters parameters)
5050
{
5151
var metadataInfo = GetHttpRequestParams(parameters);
5252

53+
#pragma warning disable SYSLIB0014 // Type or member is obsolete
5354
var request = WebRequest.CreateHttp(metadataInfo.Uri);
55+
#pragma warning restore SYSLIB0014 // Type or member is obsolete
5456
request.Method = "GET";
5557
foreach (var header in metadataInfo.headers)
5658
{

src/MongoDB.Driver/Authentication/ScramSha/ScramCache.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using System.Linq;
1717
using System.Security;
18+
using MongoDB.Driver.Core.Misc;
1819
using MongoDB.Shared;
1920

2021
namespace MongoDB.Driver.Authentication.ScramSha

src/MongoDB.Driver/Authentication/ScramSha/ScramSha1Algorithm.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public byte[] Hi(UsernamePasswordCredential credential, byte[] salt, int iterati
4141

4242
public byte[] Hmac(UTF8Encoding encoding, byte[] data, string key)
4343
{
44+
#if NET6_0_OR_GREATER
45+
using (var hmac = new HMACSHA1(data))
46+
#else
4447
using (var hmac = new HMACSHA1(data, useManagedSha1: true))
48+
#endif
4549
{
4650
return hmac.ComputeHash(encoding.GetBytes(key));
4751
}

0 commit comments

Comments
 (0)