-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to .NET Standard #72
Conversation
Note: I left the JSON.NET dependency at 9.x. There's a new major version, but I figured that would be better suited for a separate PR. |
Sure: .NET Standard is the new way of creating portable libraries (it replaces PCLs). When you target a version of .NET Standard (1.2, 1.3, etc), you get an API surface area that is common across multiple platforms. Higher = more APIs = less platforms. So, a library targeting You can think of .NET Standard as an interface, which is implemented by the actual frameworks: .NET Framework ("full" .NET), .NET Core, Mono, etc. This table shows the compatibility matrix. For example, .NET Standard 1.2 is implemented by .NET Framework 4.5.1+ and .NET Core 1.0+. The lowest we can target is 1.3, because the System.Security.Cryptography.Csp package requires 1.3. Tl;dr - packages created now and in the future should target some level of .NET Standard, preferably the lowest level that still includes the API support it needs. Then it'll be compatible with .NET Framework, .NET Core, future versions of Mono/Xamarin, future frameworks, etc. |
Re: .NET 3.5 (To add some more complexity to the topic... 😄 ) You'll notice that the table I linked to only shows .NET Framework down to v4.5 (which implements .NET Standard 1.0 and 1.1). This means that a library built to target For .NET Framework compatibility <4.5, you have to "multi-target" your project and build a separate binary for those framework versions. It's confusing at first, but it works. In this PR, I targeted |
See my new commit - this should now be compatible with:
I had to remove |
Thanks for great explanation! I'm mostly old/full .NET guy. Got sick with all this PCL crap that don't want to touch it now. And don't have much need too. Yes, let's target 3.5 in Full .NET mode and the lowest possible in NetStandard. I was thinking to make few child packages: one that depends on Json.Net to remove this dependency from parent package, and now maybe one that depends on cryptography if this would allow to lower target NetStandard? |
No problem 👍 It took me a while to wrap my head around the new world. It's complex at first, but no more PCLs!
Who would use this? People who want to bring their own |
I could see some benefit of splitting the package up into child packages. I think that might be out of scope of the PR though, happy to address that in a separate one 👍 |
To discuss the split #76 |
Hello, I tried to use this library https://github.com/viniciusmelquiades/jwt which is a fork of this one but I got this message when I try to encode a jwt : You need to set a JSON serializer. You only need to do this once. |
@paddyfink hi, please open another issue, will discuss it there. |
@abatishchev Any changes you need on this before merging? (other than resolving the nuspec conflict) |
Hmm, is there a way it to work in VS2015? Currently I'm getting an error opening projects:
Or I just don't have the latest Core tooling installed? |
The new project format requires VS2017 as far as I know. I've been using the free Community Edition: https://www.visualstudio.com/downloads/ |
Bummer. And might be quite inconvenient not just to me but to other people too. Can you please double check? Should be a way to make it work in VS2015? I haven't heard this is a well-known limitation of new Core tooling. However still might be it. |
Yeah, unfortunately that is the case. The new project system (csproj tooling for .NET Core/.NET Standard) requires VS2017. However the project can still be built on the command line (without VS) using How do you want to proceed? |
As I saw in other OSS projects her eon GitHub, I'm not alone in this kind of struggle. Let me install VS2017 on my machine, try and let you know, we'll merge it it. Can I ask for a favor and meanwhile resolve the conflicts? |
eca1b29
to
a186063
Compare
I rebased this against master. It should be totally up-to-date with the latest changes you pushed for v2.3. (If I missed something, let me know!) I changed the version to |
Current status: installing VS 2017 :) Sorry to make you waiting on this. |
No problem at all, I've been too busy to look at it these past few days anyway. 😄 |
Can you please push the branch to this repo rather then yours? Or we'll have to recreate the pr? |
Yes, seems so. I can change the base but can't change the source. |
I'm asking because GitHub (at least to my knowledge) makes in non-trivial to clone source repo/branch where the pr from created from. |
I got it https://github.com/nbarbettini/jwt/tree/netstandard but again it wasn't trivial like a direct link from pr's page |
Yeah, it's a little awkward. AFAIK the best way to checkout a remote fork PR is to check out that repo. |
Looks good!
|
Should we rename/lower-case JWT.Tests.NETFramework to NetFramework? |
Yay! Thanks a lot for this work!! |
I think it's only a few members that need XML comments. I can add them later. 👍
Doesn't matter much, but "NETFramework" is/was used in the context of TFMs. |
This PR makes the project compatible with .NET Standard/.NET Core. You should be able to open and build the new solution with Visual Studio 2017 (Community is fine), or build the project on other platforms with the
dotnet
tooling.Here's what I changed:
dotnet pack
will produce the package now!netstandard1.3
will make this package compatible (see the table) with .NET Framework 4.6+, .NET Core 1.0+, UWP, etc. If Downgrading target framework version to .NET 3.5 #71 is merged, then it should be possible to target .NET Framework 3.5 with the same approach.All the tests pass! 😄