Skip to content

Conversation

@Vincent-X-Zhang
Copy link

For better multi-framework compatibility

@Vincent-X-Zhang
Copy link
Author

@derek-will plz take a quick about this pr, thx!

@derek-will
Copy link
Owner

This library already supports .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8, and .NET 9 due to targeting .NET Standard 2.0.

It actually supports many more target frameworks - You can view the list here: https://www.nuget.org/packages/SocketCANSharp/#supportedframeworks-body-tab

@Vincent-X-Zhang
Copy link
Author

Vincent-X-Zhang commented Apr 22, 2025

This library already supports .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8, and .NET 9 due to targeting .NET Standard 2.0.

It actually supports many more target frameworks - You can view the list here: https://www.nuget.org/packages/SocketCANSharp/#supportedframeworks-body-tab

U did a great job on multi-frameworks! But each framework has it's own new api, such as:

/// <summary>
/// Number of the last error which indicates what went wrong. Set by system calls and some library functions when an error occurs.
/// </summary>
public static int Errno =>
#if NET6_0_OR_GREATER
Marshal.GetLastPInvokeError();
#else
Marshal.GetLastWin32Error();
#endif

I want to add new api for different frameworks to make code run better :)

@derek-will
Copy link
Owner

Ah! I see! I support this change then. Great idea!

Allow me a bit of time to read up on multi-framework targeting.

@derek-will
Copy link
Owner

This was a good read.

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

@derek-will
Copy link
Owner

I'm good with merging this pull request if we scale back from:

<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>

To:

<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>

Rationale is that .NET 5, 7, 9 are non-LTS releases. I see other open source .NET projects doing the same.

.NET Core 3.1, although an LTS release, is just a bit too old to justify that level of support.

Does this work for you?

@Vincent-X-Zhang
Copy link
Author

I'm good with merging this pull request if we scale back from:

<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>

To:

<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>

Rationale is that .NET 5, 7, 9 are non-LTS releases. I see other open source .NET projects doing the same.

.NET Core 3.1, although an LTS release, is just a bit too old to justify that level of support.

Does this work for you?

The targetframework in user's project can be everyone and they may not update the it for some reason.
I mean, as the provider of the base library, I would recommand target to everyframework.

@Vincent-X-Zhang
Copy link
Author

I'm good with merging this pull request if we scale back from:

<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>

To:

<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>

Rationale is that .NET 5, 7, 9 are non-LTS releases. I see other open source .NET projects doing the same.

.NET Core 3.1, although an LTS release, is just a bit too old to justify that level of support.

Does this work for you?

bro, i created a sever in discord named SocketCANSharp. Plz join it! Here is the link https://discord.gg/adgb3hxrJr.

@derek-will
Copy link
Owner

The targetframework in user's project can be everyone and they may not update the it for some reason.
I mean, as the provider of the base library, I would recommand target to everyframework.

The .NET Standard library serves as the fallback library for the cases where SocketCAN# does not offer a framework-specific implementation. Targeting older and non-LTS releases increases the size of the Nuget package and requires maintenance for older unsupported and non-mainstream versions of .NET.

In these circumstances, I tend to look to the giants of .NET Open Source to see what they are doing for guidance...

Json.NET

<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net8.0;net6.0;net45;net40;net35;net20;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>

Source: https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Newtonsoft.Json.csproj

Command Line Parser

<TargetFrameworks>netstandard2.0;net40;net45;net461</TargetFrameworks>

Source: https://github.com/commandlineparser/commandline/blob/master/src/CommandLine/CommandLine.csproj

Castle Core

<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>

Source: https://github.com/castleproject/Core/blob/master/src/Castle.Core/Castle.Core.csproj

Serilog

<TargetFrameworks>$(TargetFrameworks);net9.0;net8.0;net6.0;netstandard2.0</TargetFrameworks>

Source: https://github.com/serilog/serilog/blob/dev/src/Serilog/Serilog.csproj

Serilog goes further in a comment to say....

Policy is to trim TFM-specific builds to netstandard2.0, net6.0, all active LTS versions, and optionally the latest RTM version, when releasing new major Serilog versions.

In general, I agree with what these other developers of major projects have done. Scale back the number of TFM-specific builds to what is reasonable. For this project, I believe that to be .NET Standard 2.0, plus the active LTS versions. And while, yes, .NET 6 is technically unsupported as of this date, I am fine with the supporting it for now.

@derek-will
Copy link
Owner

bro, i created a sever in discord named SocketCANSharp. Plz join it! Here is the link https://discord.gg/adgb3hxrJr.

I am considering starting a "Discussions" here. For now, please use the pull request and issue threads on GitHub. Thanks!

@Vincent-X-Zhang
Copy link
Author

In general, I agree with what these other developers of major projects have done. Scale back the number of TFM-specific builds to what is reasonable. For this project, I believe that to be .NET Standard 2.0, plus the active LTS versions. And while, yes, .NET 6 is technically unsupported as of this date, I am fine with the supporting it for now.

Please add .NET 8 as it provides better AOT support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants