Skip to content

IL weaver to add nullability annotations to .NET reference assemblies

License

Notifications You must be signed in to change notification settings

jnm2/ReferenceAssemblyAnnotator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reference Assembly Annotator

IL weaver for adding nullability annotations to .NET Framework and .NET Standard reference assemblies.

Build status

codecov

Join the chat at https://gitter.im/tunnelvisionlabs/ReferenceAssemblyAnnotator

Requirements

  • Build: C# compiler version 3.2 Beta 2 or newer (ships with Visual Studio 2019 version 16.3 Preview 2 and newer). Older versions of the compiler interpret nullable metadata differently, which can lead to incorrect build warnings.
  • Editing experience: Visual Studio 2019 version 16.3 Preview 2 or newer.

Usage

Assemblies included by default

  • .NET Framework targets
    • mscorlib
    • System
    • System.Core
    • System.Data
    • System.Drawing
    • System.IO.Compression.FileSystem
    • System.Numerics
    • System.Runtime.Serialization
    • System.Xml
    • System.Xml.Linq
  • .NET Standard targets
    • All assemblies which are defined by the .NET Standard

Example configuration

<PropertyGroup>
  <!-- Specifies the version of this rewriter to use -->
  <TunnelVisionLabsReferenceAssemblyAnnotatorVersion>1.0.0-alpha.50</TunnelVisionLabsReferenceAssemblyAnnotatorVersion>
  <!-- Specifies the version of Microsoft.NETCore.App.Ref to obtain nullability information from -->
  <AnnotatedReferenceAssemblyVersion>3.0.0-preview9-19423-09</AnnotatedReferenceAssemblyVersion>
  <!-- Includes the nullable attributes from dotnet/coreclr as source code with 'internal' accessibility. Set this to
       false if the attributes are included from another source and/or are not needed. -->
  <GenerateNullableAttributes>true</GenerateNullableAttributes>
</PropertyGroup>

<ItemGroup>
  <!-- Include the necessary packages -->
  <PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="$(TunnelVisionLabsReferenceAssemblyAnnotatorVersion)" PrivateAssets="all" />
  <PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
</ItemGroup>

Configuration reference

  • MSBuild properties
    • <AnnotatedReferenceAssemblyVersion>: Specifies the version of Microsoft.NETCore.App.Ref to obtain nullability information from. There is no default value, so this must be specified by the user.
    • <GenerateNullableAttributes>: Set to True to include definitions of nullability attributes in the build; otherwise, False to exclude the definitions. The default value is True.
  • MSBuild items
    • <UnannotatedReferenceAssembly>: Specifies reference assemblies to annotate. This is only required for assemblies that are not automatically annotated by this package.

Releases

NuGet NuGet Beta

About

IL weaver to add nullability annotations to .NET reference assemblies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 91.3%
  • Visual Basic .NET 8.7%