Our great sponsors
-
PolySharp
PolySharp provides generated, source-only polyfills for C# language features, to easily use all runtime-agnostic features downlevel. Add a reference, set your C# version to latest and have fun! 🚀
-
IsExternalInit
A source code only package which allows you to use C# 9's init and record features in older target frameworks like .NET Standard 2.0 or the "old" .NET Framework by providing a polyfill for the IsExternalInit class.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Or the PolySharp NuGet package, which uses source generators to polyfill the language features you're actually using.
You can also just reference the https://github.com/manuelroemer/IsExternalInit NuGet package.
You can checkout my library RandN for an example of a package that targeting both C# 11, and old .NET versions - currently it targets .NET 7, .NET 6, .NET Core 3.1, .NET Standard 2.1, and .NET Standard 2.0 without any issues. Some workarounds are necessary that aren't in older runtimes (e.g. MaybeNullWhenAttribute), but overall it causes no issues.