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

Trimmer reports IL2122 even if trim warnings are suppressed #105044

Closed
vitek-karas opened this issue Jul 17, 2024 · 3 comments · Fixed by #105049
Closed

Trimmer reports IL2122 even if trim warnings are suppressed #105044

vitek-karas opened this issue Jul 17, 2024 · 3 comments · Fixed by #105049
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@vitek-karas
Copy link
Member

using System.Diagnostics.CodeAnalysis;

RequireAll("NonExistent");

void RequireAll([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] string typeName)
{
    Type.GetType(typeName);
}
> dotnet publish /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true
ILLink: warning IL2122: Program.<Main>$(String[]): Type 'NonExistent' is not assembly qualified. Type name strings used for dynamically accessing a type should be assembly qualified.

This is because:

>= 2109 and <= 2121 => MessageSubCategory.TrimAnalysis,

Thew newly added warning is not part of any of the recognized ranges.

@vitek-karas vitek-karas added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jul 17, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 17, 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.

@vitek-karas
Copy link
Member Author

Originally reported by @jonathanpeppers in #104060 (comment)

@vitek-karas
Copy link
Member Author

Fix note: maybe we should extend the ranges to cover the full IL2*** as trim analysis warnings. That was the original design anyway. To avoid these issues whenever we add new warnings.

@sbomer sbomer added this to the 9.0.0 milestone Jul 17, 2024
@sbomer sbomer self-assigned this Jul 17, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jul 17, 2024
jonathanpeppers added a commit to dotnet/android that referenced this issue Jul 18, 2024
jonathanpeppers added a commit to dotnet/android that referenced this issue Jul 18, 2024
Changes: dotnet/sdk@5e03abb...2f14fea
Changes: dotnet/runtime@1d16fd1...1f70f0c
Changes: dotnet/emsdk@ffe9afd...99ea0c0

Updates:

* VS.Tools.Net.Core.SDK.Resolver: from 9.0.100-preview.7.24358.3 to 9.0.100-preview.7.24367.21
* Microsoft.NETCore.App.Ref: from 9.0.0-preview.7.24352.15 to 9.0.0-preview.7.24366.18
* Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport: from 9.0.0-preview.7.24319.4 to 9.0.0-preview.7.24365.1
* Microsoft.NET.ILLink.Tasks: from 9.0.0-preview.7.24352.15 to 9.0.0-preview.7.24366.18

~~ Other changes ~~

* Workload manifests, require versioned folder now.

Any build would fail with:

    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.SDK.WorkloadAutoImportPropsLocator". Exception: "System.IO.FileNotFoundException: Workload manifest microsoft.net.workload.mono.toolchain.current: 9.0.0-preview.7.24365.1/9.0.100-preview.7 from workload version 9.0.100-preview.7.24366.2 was not installed. Running "dotnet workload repair" may resolve this.
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.GetManifests()
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.LoadManifestsFromProvider(IWorkloadManifestProvider manifestProvider)
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.InitializeManifests()
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind kind)+MoveNext()
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, IWorkloadManifestProvider manifestProvider, IWorkloadResolver workloadResolver)
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath)
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
    Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props(14,38): error MSB4242:    at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IReadOnlyList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable`1& errors, IEnumerable`1& warnings)"

So, we now need manifests in:

    dotnet/sdk-manifests/9.0.100-preview.x/microsoft.net.sdk.android/35.x.x-preview.x/

* Delete "workloadset" folder

Now that the .NET SDK has a newer "baseline manifest":

dotnet/sdk@0667d47

The .NET SDK contains a "baseline workload set". In order for us to
install a newer/local `android` workload, we should simply delete the
`workloadset` folder.

* Workaround MSBuild issue

Set `MSBUILDDISABLEFEATURESFROMVERSION=17.12` to workaround:

dotnet/msbuild#10378

* Update `.apkdesc` files, there are some minor file size changes.

* [Mono.Android] use `HttpClientHandler._nativeUnderlyingHandler`

Context: dotnet/runtime@8b9ea5e

This private field was renamed.

* Ignore warnings for `IL2122` in tests

`IL2122` currently appears even if trimmer warnings are disabled.

See: dotnet/runtime#105044

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants