Skip to content

Small trim warning cleanup - #54876

Merged
baronfel merged 2 commits into
mainfrom
small-trim-warning-cleanup
Jun 22, 2026
Merged

baronfel merged 2 commits into
mainfrom
small-trim-warning-cleanup

Conversation

@baronfel

Copy link
Copy Markdown
Member

@JeremyKuhne Here's a couple cleanups like we were talking about

Copilot AI review requested due to automatic review settings June 18, 2026 18:35
@baronfel
baronfel enabled auto-merge (squash) June 18, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes now-unnecessary AOT/trimming suppression attributes and simplifies CLI help/error handling so it’s consistently invoked from CommandBase (including the NativeAOT-bridged build).

Changes:

  • Removed UnconditionalSuppressMessage attributes that referenced Newtonsoft.Json trim/AOT warnings in Windows installer-related types.
  • Made ParseResult.ShowHelpOrErrorIfAppropriate() available in CLI_AOT builds and invoked it unconditionally from CommandBase.
  • Updated a command constructor to rely on the base CommandBase behavior instead of calling help/error handling directly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Cli/dotnet/Installer/Windows/MsiPayload.cs Removes trim/AOT suppression attributes from the manifest property.
src/Cli/dotnet/Installer/Windows/MsiPackageCache.cs Removes trim/AOT suppression attributes from JSON-manifest related methods.
src/Cli/dotnet/Installer/Windows/InstallRequestMessage.cs Removes trim/AOT suppression attributes from the JSON deserialization entry point.
src/Cli/dotnet/Extensions/ParseResultExtensions.cs Adjusts CLI_AOT conditional compilation so help/error logic is available in AOT, while keeping debug-switch code excluded.
src/Cli/dotnet/Commands/Reference/List/ReferenceListCommand.cs Drops redundant help/error invocation now handled by CommandBase.
src/Cli/dotnet/CommandBase.cs Centralizes help/error handling by calling the extension method unconditionally from the base constructor.
src/Cli/dotnet-aot/dotnet-aot.csproj Adds a commented toggle for AOT reference compatibility verification.
Comments suppressed due to low confidence (2)

src/Cli/dotnet/Installer/Windows/InstallRequestMessage.cs:158

  • After removing the UnconditionalSuppressMessage attributes, this file no longer uses anything from System.Diagnostics.CodeAnalysis. With TreatWarningsAsErrors enabled, the now-unused using System.Diagnostics.CodeAnalysis; will trigger IDE0005 and break the build; please remove it from the file header.
    /// <summary>
    /// Converts a deserialized array of bytes into an <see cref="InstallRequestMessage"/>.
    /// </summary>
    /// <param name="bytes">The array of bytes to convert.</param>
    /// <returns>An <see cref="InstallRequestMessage"/>.</returns>
    public static InstallRequestMessage Create(byte[] bytes)
    {
        string json = Encoding.UTF8.GetString(bytes);
        return JsonSerializer.Deserialize(json, InstallerJsonSerializerContext.Default.InstallRequestMessage)

src/Cli/dotnet/Extensions/ParseResultExtensions.cs:238

  • With CLI_AOT defined, the HandleDebugSwitch method is excluded, which makes using System.Diagnostics; at the top of this file unused in the AOT build. Since the repo sets TreatWarningsAsErrors=true, this will surface as IDE0005 and break the dotnet-aot build; please wrap that using in #if !CLI_AOT (or otherwise ensure it remains used under CLI_AOT).
#if !CLI_AOT
    [Conditional("DEBUG")]
    public static void HandleDebugSwitch(this ParseResult parseResult)
    {
        if (parseResult.HasOption(CommonOptions.DebugOption))

Comment on lines 65 to 69
/// <summary>
/// The manifest data describing the associated MSI.
/// </summary>
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Newtonsoft.Json is not used in AOT scenarios.")]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Newtonsoft.Json is not used in trimmed scenarios.")]
public MsiManifest Manifest
{
@baronfel

Copy link
Copy Markdown
Member Author

/ba-g flaky test: Microsoft.DotNet.Cli.Run.Tests.RunFileTests_BuildCommands.Build_Library_MultiTarget

@baronfel
baronfel merged commit 23a9153 into main Jun 22, 2026
25 of 27 checks passed
@baronfel
baronfel deleted the small-trim-warning-cleanup branch June 22, 2026 19:24
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants