baltermia / barcodereader-imagesharp

A barcode reader compatible with SixLabors.ImageSharp using ZXing. Trying to remove System.Drawing.Common dependencies.
MIT License
8 stars 3 forks source link

Adds support for more frameworks #2

Closed PrzemyslawKlys closed 2 years ago

PrzemyslawKlys commented 2 years ago

Since I want to use your project in PowerShell 5.1 and PowerShell 7 I need to add support for at least 4.7.2 and .NET Standard 2.0. Had to downgrade some code, and add dependencies

PrzemyslawKlys commented 2 years ago

.NET Standard is just a specification for .NET API, not an actual framework.

.Net Standard is not a framework or platform of its own. It does not have implementations or a runtime, it just defines a specification of what different .Net platforms have to implement to remain .Net Standard compliant. For Instance, .Net Core is a framework with a runtime that implements .NetStandard. In other words, .Net Standard defines a set of API’s that the platforms has to implement to be compliant with .Net Standard. By implementing this specification, the base class libraries of different platforms are unified which were otherwise evolving independently though many of the library functions are common. On the other hand, this also means the developers need not learn different Base Class Libraries for learning different platforms.

as per http://www.codedigest.com/quick-start/9/what-is-netstandard

Here's what Microsoft says on it:

When you have .NET Standard 2.0 it actually supports the use of those frameworks

image

And for .NET 2.1 those:

image

So when you try to add net standard 2.0/net standard 2.1 it won't really execute. That's why I chose 3.1 for tests.

baltermia commented 2 years ago

That's very interesting, I didn't know that. So if you specify say .netstandard2.1 you actually kinda specify all the versions listed in the screenshot above, do I understand that right?

Also, how could I test it to work with those .netstandard versions when I can't add them to the Test project?

PrzemyslawKlys commented 2 years ago
  1. Yes to the first question.
  2. I have no idea on the 2nd question how it actually works. When I added .NET Standard 2.0/.NET standard 2.1 in tests it skipped those. Then I remembered that I already hit that problem before.

Here's a bit more explanation:

.NET Standard is not itself a runtime it is a type forwarding mechanism for multiple different runtimes. Therefore, it is not possible to create anything but a non-executable class library in .NET Standard, just as was the case with PCLs. This enables the class library to be consumed by executable assemblies that target specific runtimes (.NET Framework, .NET Core, Xamarin.iOS, Mono, etc).

My understanding of it - when you add support for .NET Standard 2.0 or 2.1 you don't need to do the specific implementation for .NET Framework or .NET Core, but simply publish those, and whenever nuget gets downloaded it will work with .NET Standard, if there's no specific .NET implementation - just like for .NET CORE 3.1 which is not added, but works correctly.

The largest coverage is .NET Standard 1.0, but it heavily limits the API. Not sure if your code would be able to support this.

image