cuid.net icon indicating copy to clipboard operation
cuid.net copied to clipboard

feat(net): add support for .netstandard2.0

Open xaevik opened this issue 9 months ago • 2 comments

Tasks

  • [x] Implement support for .netstandard2.0
  • [x] Implement support for .NET Framework (minimum target is .net472)
  • [x] Restore support for .net6.0 (was removed in release 5.0.x)
  • [x] Replace NSec.Crytopgraphy with BouncyCastle.Cryptography due to platform limitations
  • [ ] Fix unit test and code coverage reporting

2024-05-11 18:21 EDT

It has been quite a painful process but getting there. PolySharp definitely made the process less of a headache by providing numerous polyfills for .netstandard2.0. There are still quite a few issues with Cuid operating correctly. ~~Additionally, parameterless struct constructors are not supported in .netstandard2.0 due to the language version level (C# 10 is required, the .netstandard2.0 implementation is targeting C# 8 for polyfills) so I am not sure how to handle that yet, may require a separate static method (like Cuid.NewCuid).~~

~~Hopefully, I won't have to throw all this work out. It would be nice to bring cuid.net to .NET Framework and friends.~~

2024-05-13 08:45 EDT

Additional refinements have been made to improve .netstandard2.0 compatibility, unfortunately now with one more caveat. All maintenance and work will now have to be done in a Windows environment (normally, I do all my personal projects on my mac). There are two reasons for this:

  1. Project leverages the RestoreLockedMode flag in CI environments and as there is no native support for NET Framework on Mac, the packages.lock.json file cannot be appropriately updated.
  2. I cannot run net472 target framework unit tests on Mac which means regressions/bugs can slip through.

~~This will slow down work and maintenance a bit while I explore options. Either by running a Windows VM (not sure what the performance impact of doing so on the M2 Pro chip is) or delegating the work to my Windows laptop (which means maintenance is restricted to the weekend as I keep separate physical computing environments in my home for mental health reasons).~~

2024-05-16 09:25 EDT

Found a working solution so that I can continue to dev/test for .NET Framework. Additionally, I resolved the parameterless struct constructor issue for older frameworks as well.

~~The remaining impediment is packages.lock.json. It is not building correctly for the multiple targets due to conditions. Trying to investigate viable solutions as I'd rather not disable RestoreLockedMode for stability reasons.~~

2024-05-20 11:40 EDT

I had no choice but to remove RestoreLockedMode as there's no real workaround for conditional depends. Also removed NSec.Cryptography entirely as there is no support for Windows/ARM64.

The final impediment is that unit tests results are not getting parsed and codacy is unable to find reports. Not sure if this is a bug with windows-latest or the action or both.

xaevik avatar May 11 '24 12:05 xaevik