Skip to main content
.NETStandard2.0

Source Generator to help multi-targeting projects.

Published
Oct 7, 2023
3y ago
Total Downloads
685.5K
685,519

Install

dotnet add package Meziantou.Polyfill --version 1.0.29
ProductVersions
.NET Standard
netstandard2.0

README

Meziantou.Polyfill

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

You can use the following MSBuild properties to configure which polyfills are generated:

<PropertyGroup>
  <!-- semi-column 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>

How to add a new polyfill

  • Create a new file named .cs in the project Meziantou.Polyfill.Editor
  • Run Meziantou.Polyfill.Generator

Notes:

  • All files must be self contained. Use a file class if needed.
  • If you need to generate a file only when another polyfill is generated, add // when in the file

Changes from Previous Version

No structural changes between v1.0.28 and v1.0.29.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.