-
Notifications
You must be signed in to change notification settings - Fork 753
Add NU1703 warning for packages using deprecated MonoAndroid framework #7229
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d9755a
Add NU1704 warning for packages using deprecated MonoAndroid framework
sbomer e4cb623
Merge remote-tracking branch 'origin/dev' into monoandroid-warning
sbomer 2995ad0
Merge remote-tracking branch 'origin/dev' into monoandroid-warning
sbomer f1ae34f
Reuse NU1703 instead of introducing NU1704 for MonoAndroid deprecatio…
sbomer a7d4667
Use resolved asset frameworks from content model instead of re-parsin…
sbomer e2c1ce2
Merge remote-tracking branch 'origin/dev' into monoandroid-warning
sbomer a553bef
Use separate dedup set for NU1703 so it is not suppressed by NU1701
sbomer 3483f40
Address PR feedback: per-framework dedup set and streamlined tests
sbomer 4520160
Update test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/…
sbomer 432c0fc
Merge remote-tracking branch 'origin/dev' into monoandroid-warning
sbomer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
src/NuGet.Core/NuGet.Commands/RestoreCommand/MonoAndroidDeprecation.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using NuGet.Frameworks; | ||
| using NuGet.ProjectModel; | ||
|
|
||
| namespace NuGet.Commands | ||
| { | ||
| /// <summary> | ||
| /// Detects when a package uses the deprecated MonoAndroid framework instead of net6.0-android or later. | ||
| /// This warning is gated on .NET 11 SDK (SdkAnalysisLevel >= 11.0.100) and targeting net11.0-android or later. | ||
| /// </summary> | ||
| internal static class MonoAndroidDeprecation | ||
| { | ||
| /// <summary> | ||
| /// Determines whether the MonoAndroid deprecation check should be performed for the given project and target framework. | ||
| /// </summary> | ||
| /// <param name="project">The package spec containing restore metadata.</param> | ||
| /// <param name="framework">The target framework of the current graph.</param> | ||
| /// <returns>True if the deprecation check should be performed.</returns> | ||
| internal static bool ShouldCheck(PackageSpec project, NuGetFramework framework) | ||
| { | ||
| if (project.RestoreMetadata == null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| // Gate on SDK analysis level >= 11.0.100 | ||
| if (!SdkAnalysisLevelMinimums.IsEnabled( | ||
| project.RestoreMetadata.SdkAnalysisLevel, | ||
| project.RestoreMetadata.UsingMicrosoftNETSdk, | ||
| SdkAnalysisLevelMinimums.V11_0_100)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| // Only check for .NETCoreApp frameworks targeting android with version >= 11.0 | ||
| return StringComparer.OrdinalIgnoreCase.Equals(framework.Framework, FrameworkConstants.FrameworkIdentifiers.NetCoreApp) | ||
| && framework.Version.Major >= 11 | ||
| && framework.HasPlatform | ||
| && framework.Platform.Equals("android", StringComparison.OrdinalIgnoreCase); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Checks whether the given framework is a MonoAndroid framework. | ||
| /// </summary> | ||
| /// <param name="framework">The framework to check, or null.</param> | ||
| /// <returns>True if the framework uses the MonoAndroid framework identifier.</returns> | ||
| internal static bool IsMonoAndroidFramework(NuGetFramework framework) | ||
| { | ||
| return framework != null | ||
| && StringComparer.OrdinalIgnoreCase.Equals( | ||
| framework.Framework, | ||
| FrameworkConstants.FrameworkIdentifiers.MonoAndroid); | ||
| } | ||
| } | ||
| } | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.