Skip to content

CSHARP-6117: Consolidate target frameworks to net472, net6.0, net8.0 and net10.0 - #2089

Draft
ajcvickers wants to merge 1 commit into
mongodb:mainfrom
ajcvickers:CSHARP-6117
Draft

CSHARP-6117: Consolidate target frameworks to net472, net6.0, net8.0 and net10.0#2089
ajcvickers wants to merge 1 commit into
mongodb:mainfrom
ajcvickers:CSHARP-6117

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Replace netstandard2.1;net472;net6.0 with net472;net6.0;net8.0;net10.0. Drops netstandard2.1, whose only remaining unique consumers were out of support (.NET Core 3.1, .NET 5, Xamarin, standalone Mono) plus current Mono/IL2CPP Unity, and adds first-class net8.0 and net10.0 assets. net6.0 is retained.

Test projects move to net6.0;net8.0;net10.0 (+net472 on Windows), dropping the netcoreapp3.1 target that existed only to exercise the netstandard2.1 asset. The SmokeTests consumer targets netcoreapp3.1 and net5.0 are removed, as they can no longer resolve a compatible asset.

Polyfill package references are scoped to net472; all NETSTANDARD2_1 branches are removed and the remaining conditionals normalised to NET6_0_OR_GREATER and NET472, so the three modern assets expose an identical public surface.

Fixes three latent issues surfaced by the new targets:

  • BsonClassMap used FormatterServices.GetUninitializedObject (obsolete as SYSLIB0050 from .NET 8), now RuntimeHelpers.GetUninitializedObject.
  • ScramSha1/ScramSha256 used Rfc2898DeriveBytes constructors (obsolete as SYSLIB0060 from .NET 10), now the static Rfc2898DeriveBytes.Pbkdf2.
  • The X509CertificateLoader test shim was guarded !NET8_0_OR_GREATER, but the BCL type arrived in .NET 9; corrected to !NET9_0_OR_GREATER.

Also gives net10.0 the full integration matrix in Evergreen, and fixes the gcp KMS test case, which an #if NETCOREAPP3_0 that no target framework defines had silently disabled.

NOTE: the test-analyzer task now passes TARGET_FRAMEWORK=net8.0 and requires a matching change in mongodb/mongo-csharp-analyzer before it can pass.

@ajcvickers
ajcvickers force-pushed the CSHARP-6117 branch 2 times, most recently from aa9be5e to 98fe8db Compare August 4, 2026 16:16
…and net10.0

Replace netstandard2.1;net472;net6.0 with net472;net6.0;net8.0;net10.0. Drops
netstandard2.1, whose only remaining unique consumers were out of support
(.NET Core 3.1, .NET 5, Xamarin, standalone Mono) plus current Mono/IL2CPP
Unity, and adds first-class net8.0 and net10.0 assets. net6.0 is retained.

Test projects move to net6.0;net8.0;net10.0 (+net472 on Windows), dropping the
netcoreapp3.1 target that existed only to exercise the netstandard2.1 asset.
The SmokeTests consumer targets netcoreapp3.1 and net5.0 are removed, as no
supported asset applies to them.

Blocks the asset fallback that dropping netstandard2.1 would otherwise expose.
Removing the netstandard2.1 asset does not make those consumers fail: NuGet's
AssetTargetFallback silently hands any .NETStandard or pre-6.0 .NETCoreApp
project the net472 assets, reporting only warning NU1701, so the build succeeds
and then misbehaves at run time. MongoDB.Bson now ships an MSBuild check at
buildTransitive/netstandard2.0 that raises MONGO1001 for those frameworks.

That placement is load-bearing twice over. Because NuGet picks a package's
nearest compatible framework from the union of all asset groups, shipping a
buildTransitive asset at netstandard2.0 also makes the package directly
compatible with netstandard2.0, so AssetTargetFallback is never attempted for
lib and such a consumer resolves no assemblies at all. The net472 assets
therefore become structurally unselectable on .NET (Core) and .NET Standard,
not merely diagnosed, and there is deliberately no opt-out property: one could
suppress the message but could never restore a working net472 reference. Since
every other driver package depends on MongoDB.Bson and buildTransitive assets
flow through the package graph, the single file covers all four packages.

The same placement suppresses NU1202 for the other netstandard2.0-compatible
frameworks that have no asset here (net461-net471, Xamarin, Tizen, UAP), so
those fail with a plain unresolved-type error instead. Accepted deliberately:
none is a supported target and none can bind the net472 assets either.

Polyfill package references are scoped to net472; all NETSTANDARD2_1 branches
are removed and the remaining conditionals normalised to NET6_0_OR_GREATER and
NET472, so the three modern assets expose an identical public surface.

Fixes three latent issues surfaced by the new targets:
- BsonClassMap used FormatterServices.GetUninitializedObject (obsolete as
  SYSLIB0050 from .NET 8), now RuntimeHelpers.GetUninitializedObject.
- ScramSha1/ScramSha256 used Rfc2898DeriveBytes constructors (obsolete as
  SYSLIB0060 from .NET 10), now the static Rfc2898DeriveBytes.Pbkdf2.
- The X509CertificateLoader test shim was guarded !NET8_0_OR_GREATER, but the
  BCL type arrived in .NET 9; corrected to !NET9_0_OR_GREATER.

Applies dotnet format to five test files. Their #if NET6_0_OR_GREATER regions
were never analysed before, because the first test target framework was
netcoreapp3.1, where that symbol is inactive; with net6.0 first they become
active and their pre-existing whitespace violations now fail the CSHARP-6147
format check. The changes are whitespace only.

Also gives net10.0 the full integration matrix in Evergreen, and fixes the
gcp KMS test case, which an #if NETCOREAPP3_0 that no target framework defines
had silently disabled.

NOTE: the test-analyzer task now passes TARGET_FRAMEWORK=net8.0 and requires a
matching change in mongodb/mongo-csharp-analyzer before it can pass.
@ajcvickers ajcvickers added maintenance Non-code maintenance (deps, docs, configs, etc.). breaking change PR contains some breaking changes. labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change PR contains some breaking changes. maintenance Non-code maintenance (deps, docs, configs, etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant