Skip to content

DreadLordMikey/PolySharpFeatureDemo

Repository files navigation

PolySharp Feature Tests

Contents of this Project

This project contains unit tests that verify the availability of C# features that were added in C# 8.0 or higher using polyfills provided by PolySharp when targeting .NET Framework 4.5.1 through 4.8. Wherever possible, the tests use samples from Microsoft's own online documentation for the individual features.

NOTE: Tests for .NET Framework 4.5 are not provided as the .NET Framework 4.5 SDK is well past its end of life and Microsoft no longer makes it available for download from .NET SDK Downloads for Visual Studio.

As the SDK can no longer be acquired, forks of this repository would not be able to run these tests if they did not already have the SDK installed.

This document lists all C# features that were added from C# 8 forward, and notes where features are either not supported or require additional setup or configuration.

PolySharp is sponsored by Sergio Pedri, and be found on github here. The NuGet package is available at NuGet.org here.

Adding PolySharp to a Project

  1. Add a reference to PolySharp from NuGet Package Manager.
  2. Manually add the analyzer to the project. In Solution Explorer, expand References, and right-click Analyzers. Select Add Analyzer. Browse to packages\PolySharp.1.10.0\analyzers\dotnet\cs\ and select PolySharp.SourceGenerators.dll. Then clean and rebuild your solution.

If your project uses a packages.config file, consider migrating it to use the newer PackageReference element in the .csproj file. Source code generation is more reliable when PackageReference elements are used as opposed to a packages.config file.

Test Results by Version

Each of the pages below provides a feature compatibility matrix that describes the availability of each feature in each version of the .NET Framework tested.

Polyfills by C# Version

In each section below, if a bullet point is a hyperlink, the feature has been tested via unit test. Unless otherwise specified, the presence of a hyperlink indicates that the tests pass, and the feature is available via polyfill and works as documented in the linked Microsoft online documentation.

C# 8

C# 9

C# 10

C# 11

  • Raw string literals
  • Generic math support
  • Generic attributes
  • UTF-8 string literals
  • Newlines in string interpolation expressions
  • List patterns
  • File-local types
  • Required members
  • Auto-default structs
  • Pattern match Span<char> on a constant string
  • Extended nameof scope
  • Numeric IntPtr
  • ref fields and scoped ref
  • Improved method group conversion to delegate
  • Warning wave 7

About

Polysharp polyfill unit tests.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages