Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eerhardt opened this issue Nov 1, 2022 · 1 comment · Fixed by #81407

Comments

@eerhardt
Copy link
Member

eerhardt commented Nov 1, 2022

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.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 1, 2022
@MichalStrehovsky
Copy link
Member

This is because of dotnet/runtimelab#1381.

We need to add support for assembly fullname="*". Can be done, just wasn't completely straightforward and I don't expect this to have meaningful savings. Custom attributes are a lot less costly in NativeAOT metadata format than in IL.

@MichalStrehovsky MichalStrehovsky added this to the 8.0.0 milestone Nov 2, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Nov 2, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 1, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 10, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants