meziantou / Meziantou.Polyfill

MIT License
44 stars 1 forks source link

Meziantou.Polyfill

NuGet

Source Generator that adds polyfill methods and types. This helps working with multi-targeted projects.

Read more about the project: Polyfills in .NET to ease multi-targeting

Installation

dotnet add package Meziantou.Polyfill

Then, you should see the generated types in the solution explorer

Generated files in the Visual Studio's Solution Explorer

Customization

By default, all needed polyfills are generated. You can configure which polyfills should be generated by editing the .csproj file and adding the following properties:

<PropertyGroup>
  <!-- semicolon-separated or pipe-separated list of name prefix -->
  <!-- Tip: The name of the generated polyfills are available in the generated "Debug.g.cs" file -->
  <MeziantouPolyfill_IncludedPolyfills>T:Type1|T:Type2|M:Member1</MeziantouPolyfill_IncludedPolyfills>
  <MeziantouPolyfill_ExcludedPolyfills>M:System.Diagnostics.</MeziantouPolyfill_ExcludedPolyfills>

  <!-- Optional: Output the generated files to the obj\GeneratedFiles folder  -->
  <EmitCompilerGeneratedFiles>True</EmitCompilerGeneratedFiles>
  <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

Supported polyfills

Types

Methods

Contribution

How to add a new polyfill

Notes: