-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathSdkAnalysisLevelMinimums.cs
More file actions
68 lines (62 loc) · 3.03 KB
/
SdkAnalysisLevelMinimums.cs
File metadata and controls
68 lines (62 loc) · 3.03 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
59
60
61
62
63
64
65
66
67
68
// 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 NuGet.Versioning;
namespace NuGet.Commands
{
/// <summary>
/// Defines constants that specify the minimum SDK analysis level required to enable new features.
/// </summary>
internal static class SdkAnalysisLevelMinimums
{
/// <summary>
/// Minimum SDK Analysis Level required to enable HTTP Errors is 9.0.100.
/// </summary>
internal static readonly NuGetVersion V9_0_100 = new("9.0.100");
/// <summary>
/// Minimum SDK Analysis Level required for:
/// <list type="bullet">
/// <item>warning for packages and projects that cannot be pruned</item>
/// <item>enabling the new restore algorithm for lock files</item>
/// <item>error when CPM not used and PackageReference does not have version</item>
/// </list>
/// </summary>
internal static readonly NuGetVersion V10_0_100 = new("10.0.100");
/// <summary>
/// Minimum SDK Analysis Level required for:
/// <list type="bullet">
/// <item>.NET SDK version that supports aliased assets files.</item>
/// <item>error when TargetFramework alias contains path separators characters</item>
/// </list>
/// </summary>
internal static readonly NuGetVersion V10_0_300 = new("10.0.300");
/// <summary>
/// Minimum SDK Analysis Level required for:
/// <list type="bullet">
/// <item>warning when packages use the deprecated MonoAndroid framework</item>
/// <item>error when TargetFramework alias contains non-ASCII characters</item>
/// </list>
/// </summary>
internal static readonly NuGetVersion V11_0_100 = new("11.0.100");
/// <summary>
/// Determines whether the feature is enabled based on the SDK analysis level.
/// </summary>
/// <param name="sdkAnalysisLevel">The project SdkAnalysisLevel value </param>
/// <param name="usingMicrosoftNetSdk">Is it SDK project or not</param>
/// <param name="minSdkVersion">The minimum version of the SDK required for the feature to be enabled.</param>
/// <returns>Returns true if the feature should be enabled based on the given parameters; otherwise, false.</returns>
internal static bool IsEnabled(NuGetVersion sdkAnalysisLevel, bool usingMicrosoftNetSdk, NuGetVersion minSdkVersion)
{
if (sdkAnalysisLevel != null && sdkAnalysisLevel >= minSdkVersion ||
sdkAnalysisLevel == null && usingMicrosoftNetSdk == false)
{
// SdkAnalysisLevel >= minSdkVersion or SdkAnalysisLevel is null and not using Microsoft NET Sdk
return true;
}
else
{
// SdkAnalysisLevel < minSdkVersion or SdkAnalysisLevel is null and using Microsoft NET Sdk
return false;
}
}
}
}