Skip to content

Setting NullabilityInfoContextSupport=false in NativeAOT doesn't remove NullableAttribute/NullableContextAttribute ctors #77753

Closed
@eerhardt

Description

@eerhardt

dotnet publish -c Release -r win-x64 -p:PublishAot=true -p:NullabilityInfoContextSupport=false -p:IlcGenerateMstatFile=true the following app:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0-*" />
  </ItemGroup>
</Project>
Console.WriteLine(new Microsoft.Extensions.DependencyInjection.ServiceCollection());

Inspect the .\obj\Release\net7.0\win-x64\native\HelloWorld.mstat using ildasm and open the Methods() method, which lists all the methods left in the app.

Expected results

The System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) and System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) methods should be trimmed from the app, so they should not be in the mstat file.

Actual results

These attributes are left in the app.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions