[release/7.0] Limit impact of global NoWarn #3123
Merged
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.
Customer Impact
This addresses a reported customer scenario where the global NoWarn breaks projects that use older tools. #3118
Testing
Local testing to confirm that this doesn't break trimmed apps. The change has also flowed to SDK in main, where all of the SDK tested scenarios have been validated.
Risk
Low risk. This doesn't change existing functionality at all - it only avoids setting an unnecessary property in scenarios where it is unused.
Fixes #3118. This limits the impact of the global
NoWarn
to scenarios wherePublishTrimmed
is true. It should help with older tools that aren't able to ignore NoWarn settings.I also looked into making the whole target file import conditional on trim scenarios, but this isn't straightforward:
linker/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets
Lines 14 to 15 in a5cd06e
PublishTrimmed
being set early for the analyzer.PublishTrimmed
,IsTrimmable
,SuppressTrimAnalysisWarnings
, and feature switches, so we would need to have a more complex condition for the import and/or move some of the logic elsewhere.If the analyzer adds support for redundant suppression detection, the condition will need to be updated. I'm not trying to make the condition future-proof here because the redundant suppression feature isn't officially supported in the first place. If we add support for it, this should come with proper SDK testing.