[CSHARP-2592] Add .NET Standard 2.0 support Created: 17/Apr/19  Updated: 28/Oct/23  Resolved: 28/Jan/20

Status: Closed
Project: C# Driver
Component/s: Build
Affects Version/s: 2.11.0
Fix Version/s: 2.11.0

Type: Improvement Priority: Major - P3
Reporter: Vincent Kam (Inactive) Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
backports CSHARP-2758 Add Span<T> support to ObjectId Backlog
Cloners
is cloned by MONGOCRYPT-253 Add .NET Standard 2.0 support Closed
Related
related to CSHARP-2595 BsonClassMap type initializer throws ... Closed
related to CSHARP-2394 Remove dependency on System.Reflectio... Closed
related to CSHARP-2714 Update minimum .NET & .NET Standard v... Closed
is related to CSHARP-2797 Map version numbers in client metadat... Closed

 Description   

Per Microsoft's guidance for open source libraries (https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting), we should consider adding support for .NET Standard 2.0.

We should be able to accomplish this while still maintaining support for .NET Standard 1.5 until we decide when we want to drop support for .NET Standard 1.5.

For testing, we could ensure that the our test projects test both libraries by having the test projects target .NET Core 1.0 and 2.x, with the former consuming the .NET Standard 1.5 driver and the latter consuming the .NET Standard 2.x driver



 Comments   
Comment by Githook User [ 28/Jan/20 ]

Author:

{'email': 'dmitry.lukyanov@mongodb.com', 'username': 'DmitryLukyanov', 'name': 'DmitryLukyanov'}

Message: CSHARP-2592: Add .NET Standard 2.0 support.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/9e567e23615c8bb5c7ac1489427c2d15b2124522

Comment by Yuheng Xiang [ 13/Jan/20 ]

You will think it a true statement if you look deep into it.

.NET Standard actually have various meanings during the discussion. It's original definition is a set of APIs, which is not likely to be deprecated as you explained, but what we are actually dealing with is a target that the program in built against, which is about the packages versioning and shipping.

As linked above multi-targeting, it's true that .NET Standard 1.x is marked to be avoided.

.NET Standard 1.x is distributed as a granular set of NuGet packages, which creates a large package dependency graph and results in developers downloading a lot of packages when building. Modern .NET platforms, including .NET Framework 4.6.1, UWP and Xamarin, all support .NET Standard 2.0. You should only target .NET Standard 1.x if you specifically need to target an older platform.

It is not only a problem about pattern or styling. It causes problems.
1. Unneeded dependencies. As referenced above, a .NET Standard 1.x package brings a large graph of dependency packages in, which are already included in modern versions of .NET Standard.
2. Conflict. For those projects that works with complex reflection or assembly loading without specifically handling this, the duplicate packages brought by a .NET Standard 1.x package may cause runtime exceptions due to assembly and type conflict.

Comment by Robert Stam [ 13/Jan/20 ]

I don't think that is a true statement.

Since .NET Standard versions are just different sets of APIs, I don't think any version of .NET Standard is ever deprecated.

Only the frameworks that implement .NET Standard versions get deprecated.

You can use the .NET Driver with any current version of either .NET Core or .NET Framework.

We definitely intend to target .NET Standard 2.0 at some point, but I don't think it is as urgent as you say.

Comment by Yuheng Xiang [ 13/Jan/20 ]

This should be considered prior to everything else.

Targeting a deprecated framework also makes the whole driver deprecated.

In other words,

MONGODB HAS CURRENTLY NO QUALIFIED SUPPORT FOR .NET

Comment by Jimmy Bogard [ 13/Aug/19 ]

I opened a PR for `netstandard2.0` support:

https://github.com/mongodb/mongo-csharp-driver/pull/377

Comment by Jimmy Bogard [ 13/Aug/19 ]

Do you need any help on this one? I've converted all my OSS projects to add `netstandard2.0` support, it hasn't been too bad doing so. I'd be happy to open a PR for it.

 

Selfishly it would allow us to target `netstandard2.0` instead of `netcoreapp2.2` in some of our shared libraries that reference this package.

Comment by Robert Stam [ 30/Apr/19 ]

Even if we use nothing new from .NET Standard 2.0 there are benefits to targetting netstandard2.0 as well as netstandard1.5.

See "DO include a netstandard2.0 target if you require a netstandard1.x target." here

https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting#multi-targeting

On the other hand, that article also says: "You should only target .NET Standard 1.x if you specifically need to target an older platform."

Generated at Wed Feb 07 21:42:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.