dotnet / dotnet/linker

Setting NullabilityInfoContextSupport=false prevents ILLink.Substitutions.xml from being removed from System.Runtime.InteropServices.dll

Open
#2,661 3 comments 0 reactions 0 assignees View on GitHub
area-Linker: Steps
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

Test case: [consoleapp-d3255da.zip](https://github.com/dotnet/linker/files/8152269/consoleapp-d3255da.zip)

Repro:

```shell
$ make resources-there
dotnet publish /bl /v:quiet /nologo /bl:resources-there.binlog /p:NullabilityInfoContextSupport=false
/usr/local/share/dotnet/sdk/6.0.201/MSBuild.dll /nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/6.0.201/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/6.0.201/dotnet.dll -maxcpucount -property:NullabilityInfoContextSupport=false -restore -target:Publish -verbosity:m /v:quiet /bl /bl:resources-there.binlog ./myproject.csproj

Workload updates are available. Run `dotnet workload list` for more information.
monodis --manifest ./bin/Debug/net6.0/osx-x64/publish/System.Runtime.InteropServices.dll
Manifestresource Table (1..2)
1: public 'FxResources.System.Runtime.InteropServices.SR.resources' at offset 0 in current module
2: public 'ILLink.Substitutions.xml' at offset 2505 in current module
```

Note there are two resources in the ./bin/Debug/net6.0/osx-x64/publish/System.Runtime.InteropServices.dll assembly.

Now try enabling NullabilityInfoContextSupport:

```shell
$ make resources-gone
dotnet publish /bl /v:quiet /nologo /bl:resources-gone.binlog /p:NullabilityInfoContextSupport=true
/usr/local/share/dotnet/sdk/6.0.201/MSBuild.dll /nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/6.0.201/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/6.0.201/dotnet.dll -maxcpucount -property:NullabilityInfoContextSupport=true -restore -target:Publish -verbosity:m /v:quiet /bl /bl:resources-gone.binlog ./myproject.csproj

Workload updates are available. Run `dotnet workload list` for more information.
monodis --manifest ./bin/Debug/net6.0/osx-x64/publish/System.Runtime.InteropServices.dll
Manifestresource Table (1..1)
1: public 'FxResources.System.Runtime.InteropServices.SR.resources' at offset 0 in current module
```

and `ILLink.Substitutions.xml` has been linked away.

bin logs (remove the .txt extension):

[resources-gone.binlog.txt](https://github.com/dotnet/linker/files/8152294/resources-gone.binlog.txt)
[resources-there.binlog.txt](https://github.com/dotnet/linker/files/8152295/resources-there.binlog.txt)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.