PolySharp 1.5.0
See the version list below for details.
dotnet add package PolySharp --version 1.5.0
NuGet\Install-Package PolySharp -Version 1.5.0
<PackageReference Include="PolySharp" Version="1.5.0" />
<PackageVersion Include="PolySharp" Version="1.5.0" />
<PackageReference Include="PolySharp" />
paket add PolySharp --version 1.5.0
#r "nuget: PolySharp, 1.5.0"
#:package PolySharp@1.5.0
#addin nuget:?package=PolySharp&version=1.5.0
#tool nuget:?package=PolySharp&version=1.5.0

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]
IndexandRange(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)[AsyncMethodBuilder](needed for custom method builder types)
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).
- "PolySharpIncludeGeneratedTypes": only includes specific types for generation (';' or ',' separated type names).
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages (39)
Showing the top 5 NuGet packages that depend on PolySharp:
| Package | Downloads |
|---|---|
|
AdaptiveCards.Templating
This library implements a JSON-to-JSON templating/data-binding engine. While it is designed to be used with Adaptive Cards, it is not dependent on Adaptive Cards and can therefore be used in many contexts and applications. |
|
|
Bing.Utils
Bing.Utils是Bing应用框架的核心帮助类库。 |
|
|
FluentCommand
Fluent Wrapper for DbCommand |
|
|
TinyIpc
.NET inter process broadcast message bus. |
|
|
TinyLogger
Tiny extendable logger that plugins into Microsoft.Extensions.Logging |
GitHub repositories (178)
Showing the top 20 popular GitHub repositories that depend on PolySharp:
| Repository | Stars |
|---|---|
|
files-community/Files
A modern file manager that helps users organize their files and folders.
|
|
|
spectreconsole/spectre.console
A .NET library that makes it easier to create beautiful console applications.
|
|
|
LuckyPennySoftware/AutoMapper
A convention-based object-object mapper in .NET.
|
|
|
restsharp/RestSharp
Simple REST and HTTP API Client for .NET
|
|
|
unoplatform/uno
Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
|
|
|
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.
|
|
|
serilog/serilog
Simple .NET logging with fully-structured events
|
|
|
elsa-workflows/elsa-core
A .NET workflows library
|
|
|
stride3d/stride
Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
|
|
|
PrismLibrary/Prism
Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..
|
|
|
AssetRipper/AssetRipper
GUI Application to work with engine assets, asset bundles, and serialized files
|
|
|
graphql-dotnet/graphql-dotnet
GraphQL for .NET
|
|
|
ClosedXML/ClosedXML
ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API.
|
|
|
tModLoader/tModLoader
A mod to make and play Terraria mods. Supports Terraria 1.4 (and earlier) installations
|
|
|
UnigramDev/Unigram
Telegram for Windows
|
|
|
Cysharp/ZLinq
Zero allocation LINQ with LINQ to Span, LINQ to SIMD, and LINQ to Tree (FileSystem, JSON, GameObject, etc.) for all .NET platforms and Unity, Godot.
|
|
|
BililiveRecorder/BililiveRecorder
录播姬 | mikufans 生放送录制
|
|
|
ExcelDataReader/ExcelDataReader
Lightweight and fast library written in C# for reading Microsoft Excel files
|
|
|
sshnet/SSH.NET
SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
|
|
|
Cysharp/MagicOnion
Unified Realtime/API framework for .NET platform and Unity.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.15.0 | 2,447,778 | 11/21/2024 |
| 1.14.1 | 4,371,966 | 12/18/2023 |
| 1.14.0 | 53,263 | 11/28/2023 |
| 1.13.2 | 798,150 | 5/16/2023 |
| 1.13.1 | 166,827 | 4/6/2023 |
| 1.12.1 | 417,451 | 1/21/2023 |
| 1.10.0 | 683,841 | 1/15/2023 |
| 1.9.0 | 3,122 | 1/14/2023 |
| 1.8.3 | 14,576 | 1/9/2023 |
| 1.8.2 | 301 | 1/8/2023 |
| 1.8.1 | 28,745 | 11/22/2022 |
| 1.8.0 | 968 | 11/16/2022 |
| 1.7.1 | 33,270 | 10/29/2022 |
| 1.7.0 | 265 | 10/28/2022 |
| 1.6.0 | 508 | 10/26/2022 |
| 1.5.0 | 265 | 10/26/2022 |
| 1.4.0 | 274 | 10/25/2022 |
| 1.3.0 | 448 | 10/23/2022 |
| 1.2.0 | 264 | 10/22/2022 |
| 1.1.0 | 251 | 10/22/2022 |
| 1.0.1 | 253 | 10/22/2022 |
| 1.0.0 | 7,747 | 10/22/2022 |