PolySharp 1.3.0

This package has a SemVer 2.0.0 package version: 1.3.0+6a2efbbea40172b38fa57f0e72bd8daadfaaebbe.
There is a newer version of this package available.
See the version list below for details.
dotnet add package PolySharp --version 1.3.0
NuGet\Install-Package PolySharp -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PolySharp" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PolySharp --version 1.3.0
#r "nuget: PolySharp, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PolySharp as a Cake Addin
#addin nuget:?package=PolySharp&version=1.3.0

// Install PolySharp as a Cake Tool
#tool nuget:?package=PolySharp&version=1.3.0

image

What is it? 🚀

PolySharp provides generated, source-only polyfills for C# language features, to easily use all runtime-agnostic features downlevel. The package is distributed as a source generator, so that it will automatically detect which polyfills are needed depending on the target framework and project in use: just add a reference to PolySharp, set your C# language version to latest, and have fun!

Documentation 📖

PolySharp includes the following polyfills:

  • Nullability attributes (for nullable reference types):
    • [AllowNull]
    • [DisallowNull]
    • [DoesNotReturn]
    • [DoesNotReturnIf]
    • [MaybeNull]
    • [MaybeNullWhen]
    • [MemberNotNull]
    • [MemberNotNullWhen]
    • [NotNull]
    • [NotNullIfNotNull]
    • [NotNullWhen]
  • Index and Range (see indices and ranges)
  • [UnscopedRef] (see low-level struct improvements)
  • Required members (see required modifier)
    • [RequiredMember]
    • [SetsRequiredMembers]
  • [CompilerFeatureRequired] (needed to support several features)
  • [IsExternalInit] (needed for init-only properties)
  • [SkipLocalsInit] (see docs)
  • Interpolated string handlers (see docs)
    • [InterpolatedStringHandler]
    • [InterpolatedStringHandlerArgument]
  • [CallerArgumentExpression] (see docs)
  • [RequiresPreviewFeatures] (needed for preview features)

To leverage them, make sure to bump your C# language version. You can do this by setting the <LangVersion> MSBuild property in your project. For instance, by adding <LangVersion>11.0</LangVersion> (or your desired C# version) to the first <PropertyGroup> of your .csproj file. For more info on this, see here, but remember that you don't need to manually copy polyfills anymore: simply adding a reference to PolySharp will do this for you automatically.

It also includes the following optional runtime-supported polyfills:

  • Reflection annotation attributes (see docs):
    • [DynamicallyAccessedMembers]
    • [DynamicDependency]
    • [RequiresUnreferencedCode]
    • [UnconditionalSuppressMessage]
  • [StackTraceHidden] (see here)
  • [UnmanagedCallersOnly] (see docs))
  • Platform support annotation attributes (see docs):
    • [ObsoletedOSPlatform]
    • [SupportedOSPlatform]
    • [SupportedOSPlatformGuard]
    • [TargetPlatform]
    • [UnsupportedOSPlatform]
    • [UnsupportedOSPlatformGuard]

Options ⚙️

PolySharp's generation can be configured through some MSBuild properties to set in consuming projects.

The following properties are available:

  • "PolySharpUsePublicAccessibilityForGeneratedTypes": makes all generated types public.
  • "PolySharpIncludeRuntimeSupportedAttributes": enables polyfills for (dummy) runtime-supported attributes too.
  • "PolySharpExcludeGeneratedTypes": excludes specific types from generation (';' or ',' separated type names).
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (20)

Showing the top 5 NuGet packages that depend on PolySharp:

Package Downloads
K4os.Xpovoc.Core

Simple job scheduler for .NET/.NET Core

K4os.Xpovoc.MySql

Simple job scheduler for .NET/.NET Core

K4os.Xpovoc.PgSql

Simple job scheduler for .NET/.NET Core

K4os.Xpovoc.SqLite

Simple job scheduler for .NET/.NET Core

aqua.tool.Validation

Provides C# source generated extension methods for argument validation.

GitHub repositories (85)

Showing the top 5 popular GitHub repositories that depend on PolySharp:

Repository Stars
files-community/Files
Building the best file manager for Windows
unoplatform/uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
serilog/serilog
Simple .NET logging with fully-structured events
lepoco/wpfui
WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
PrismLibrary/Prism
Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..
Version Downloads Last updated
1.14.1 301,499 12/18/2023
1.14.0 34,342 11/28/2023
1.13.2 572,615 5/16/2023
1.13.1 78,794 4/6/2023
1.12.1 276,556 1/21/2023
1.10.0 270,835 1/15/2023
1.9.0 1,957 1/14/2023
1.8.3 11,392 1/9/2023
1.8.2 138 1/8/2023
1.8.1 20,785 11/22/2022
1.8.0 781 11/16/2022
1.7.1 22,260 10/29/2022
1.7.0 120 10/28/2022
1.6.0 291 10/26/2022
1.5.0 115 10/26/2022
1.4.0 113 10/25/2022
1.3.0 278 10/23/2022
1.2.0 103 10/22/2022
1.1.0 96 10/22/2022
1.0.1 104 10/22/2022
1.0.0 2,411 10/22/2022