Ad

PolySharp: C# polyfills for older .NET runtimes

PolySharp provides source-only polyfills for C# language features, enabling newer language capabilities in older .NET versions. It automatically generates the necessary code to support modern C# features downlevel, simplifying compatibility.
Screenshot of Sergio0694/PolySharp homepage

PolySharp generates source-only polyfills for C# language features, allowing developers to utilize newer language constructs in older .NET runtimes. By adding a reference to PolySharp and setting the target C# version to the latest, the package automatically generates the required code to support these features. This eliminates the need for manual polyfill implementation, simplifying development and ensuring compatibility.

PolySharp simplifies the process of using new C# language features in older .NET runtimes by automating polyfill generation. It supports a wide range of attributes and language features, including nullability annotations, index/range operators, and experimental syntax. The source-only nature of the polyfills allows for easy integration with existing projects. The project aims to maintain a minimal dependency footprint.

  • Nullability Attributes: Enables features like nullable reference types, [AllowNull], [NotNull] and more.
  • Index and Range Operators: Provides support for the Index and Range types for easier collection manipulation.
  • Configuration via MSBuild Properties: Allows customization of polyfill generation behavior through MSBuild properties, providing flexibility for specific project needs.
  • Extensive Attribute Support: Includes numerous attributes for various features such as required members, trimmed code, and experimental syntax.
  • Automatic Polyfill Generation: Automatically generates required code based on the target framework and C# version, eliminating manual implementation.
  • Targeting modern C#: By simply setting the <LangVersion> property, you can target modern C# versions and automatically benefit from the polyfills.
  • Widely Applicable: Applicable to a broad range of C# features, including but not limited to pattern matching, interpolation, and more.

PolySharp is an active project with consistent updates and a growing number of supported features. Regular commits and a responsive community indicate ongoing maintenance and support. Comprehensive documentation and clear examples aid in understanding and utilizing the library. The project is steadily maturing and gaining wider adoption.

Developers working with older .NET runtimes (e.g., .NET Framework 4.x, UWP) who want to leverage modern C# features will benefit from PolySharp. It allows them to use language features like nullability, pattern matching, and interpolated strings without upgrading their entire runtime environment. PolySharp reduces the complexity of compatibility by automating the provision of necessary code without impacting project dependencies significantly.

Languages:
Summarize:
Share:
Stars
2,211
Forks
72
Issues
33
Created
3 years ago
Commit
3 months ago
License
MIT
Archived
No
Updated 17 days ago

Similar Repositories