Skip to content
New issue

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

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

Already on GitHub? # to your account

Several IL20XX trim warnings missed by analyzers, only show up with ILC #109270

Closed
Sergio0694 opened this issue Oct 28, 2024 · 3 comments · Fixed by #109392
Closed

Several IL20XX trim warnings missed by analyzers, only show up with ILC #109270

Sergio0694 opened this issue Oct 28, 2024 · 3 comments · Fixed by #109392
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers in-pr There is an active PR which will close this issue when it is merged partner-impact This issue impacts a partner who needs to be kept updated
Milestone

Comments

@Sergio0694
Copy link
Contributor

Sergio0694 commented Oct 28, 2024

Description

I've noticed several IL20XX trim warnings when publishing the Microsoft Store with NAOT, that only show up via ILC:

Image

Reproduction Steps

Can't share repro steps here (since the code is not open source).
I can however share:

  • binlog (MSFT only): link
  • repo link and instructions to build locally (ping me on Teams)

Expected behavior

Ideally, all those warnings should also show up in the IDE.

Actual behavior

Several warnings only show up via ILC at publish time.

@Sergio0694 Sergio0694 added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Oct 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 28, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@Sergio0694 Sergio0694 added the partner-impact This issue impacts a partner who needs to be kept updated label Oct 28, 2024
@sbomer sbomer self-assigned this Oct 29, 2024
@sbomer sbomer added this to the 10.0.0 milestone Oct 29, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Oct 29, 2024
@sbomer
Copy link
Member

sbomer commented Oct 29, 2024

Simplified repro for the IL2091 warnings:

using System.Diagnostics.CodeAnalysis;

new C<string>().M();

class C<T> {
    public T M() {
        return G<T>.Factory.Create();
    }
}

class G<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> {
    public static class Factory {
        public static T? Create() => default;
    }
}

The presence of the nested class is relevant.

@sbomer
Copy link
Member

sbomer commented Oct 31, 2024

From what I can tell, all of the remaining extra warnings are expected:

  • Some of the IL2026 warnings are for calls to RunClassConstructor of a type with RequiresUnreferencedCode. The class constructor is defined in a referenced assembly, so isn't visible to the analyzer. It's basically private reflection which the analyzer can't detect with the current semantics (though I would be interested in discussing different semantics).
  • IL2087 was caught by the analyzer (in a different Csc invocation)
  • IL2050 was produced for an assembly that wasn't built as part of this project

However, I noticed in the local repro that the analyzer was producing extra IL2059 warnings compared to ILC for RunClassConstructor of an enum: #109429

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Oct 31, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers in-pr There is an active PR which will close this issue when it is merged partner-impact This issue impacts a partner who needs to be kept updated
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants