Small trim warning cleanup - #54876
Merged
Merged
Conversation
JeremyKuhne
approved these changes
Jun 18, 2026
baronfel
enabled auto-merge (squash)
June 18, 2026 18:38
Contributor
There was a problem hiding this comment.
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
UnconditionalSuppressMessageattributes that referenced Newtonsoft.Json trim/AOT warnings in Windows installer-related types. - Made
ParseResult.ShowHelpOrErrorIfAppropriate()available inCLI_AOTbuilds and invoked it unconditionally fromCommandBase. - Updated a command constructor to rely on the base
CommandBasebehavior 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_AOTdefined, theHandleDebugSwitchmethod is excluded, which makesusing 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 | ||
| { |
Member
Author
|
/ba-g flaky test: Microsoft.DotNet.Cli.Run.Tests.RunFileTests_BuildCommands.Build_Library_MultiTarget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@JeremyKuhne Here's a couple cleanups like we were talking about