-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathMonoAndroidDeprecation.cs
More file actions
58 lines (53 loc) · 2.52 KB
/
MonoAndroidDeprecation.cs
File metadata and controls
58 lines (53 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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);
}
}
}