@@ -14,21 +14,21 @@ internal static class VisualStudioSafeVersionsExtractor
14
14
15
15
// Must keep one of each of these divisions to ensure Visual Studio works.
16
16
// Pairs are [inclusive, exclusive)
17
- private static readonly Dictionary < ( SemanticVersion , SemanticVersion ) , string > VersionDivisionsToExplaination = new Dictionary < ( SemanticVersion , SemanticVersion ) , string >
17
+ private static readonly Dictionary < ( SemanticVersion , SemanticVersion ) , string > WindowsVersionDivisionsToExplaination = new Dictionary < ( SemanticVersion , SemanticVersion ) , string >
18
18
{
19
- { ( new SemanticVersion ( 1 , 0 , 0 ) , new SemanticVersion ( 2 , 0 , 0 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , "" ) } ,
20
- { ( new SemanticVersion ( 2 , 0 , 0 ) , new SemanticVersion ( 2 , 1 , 300 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , "" ) } ,
21
- { ( new SemanticVersion ( 2 , 1 , 300 ) , new SemanticVersion ( 2 , 1 , 600 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , " 2017" ) } ,
22
- { ( new SemanticVersion ( 2 , 1 , 600 ) , new SemanticVersion ( 2 , 1 , 900 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , " 2019" ) } ,
23
- { ( new SemanticVersion ( 2 , 2 , 100 ) , new SemanticVersion ( 2 , 2 , 200 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , " 2017" ) } ,
24
- { ( new SemanticVersion ( 2 , 2 , 200 ) , new SemanticVersion ( 2 , 2 , 500 ) ) , string . Format ( LocalizableStrings . RequirementExplainationString , " 2019" ) } ,
25
- { ( new SemanticVersion ( 2 , 2 , 500 ) , UpperLimit ) , string . Format ( LocalizableStrings . RequirementExplainationString , "" ) }
19
+ { ( new SemanticVersion ( 1 , 0 , 0 ) , new SemanticVersion ( 2 , 0 , 0 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , "" ) } ,
20
+ { ( new SemanticVersion ( 2 , 0 , 0 ) , new SemanticVersion ( 2 , 1 , 300 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , "" ) } ,
21
+ { ( new SemanticVersion ( 2 , 1 , 300 ) , new SemanticVersion ( 2 , 1 , 600 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , " 2017" ) } ,
22
+ { ( new SemanticVersion ( 2 , 1 , 600 ) , new SemanticVersion ( 2 , 1 , 900 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , " 2019" ) } ,
23
+ { ( new SemanticVersion ( 2 , 2 , 100 ) , new SemanticVersion ( 2 , 2 , 200 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , " 2017" ) } ,
24
+ { ( new SemanticVersion ( 2 , 2 , 200 ) , new SemanticVersion ( 2 , 2 , 500 ) ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , " 2019" ) } ,
25
+ { ( new SemanticVersion ( 2 , 2 , 500 ) , UpperLimit ) , string . Format ( LocalizableStrings . WindowsRequirementExplainationString , "" ) }
26
26
} ;
27
27
28
- private static ( IDictionary < IEnumerable < Bundle > , string > , IEnumerable < Bundle > ) ApplyVersionDivisions ( IEnumerable < Bundle > bundleList )
28
+ private static ( IDictionary < IEnumerable < Bundle > , string > , IEnumerable < Bundle > ) ApplyWindowsVersionDivisions ( IEnumerable < Bundle > bundleList )
29
29
{
30
30
var dividedBundles = new Dictionary < IEnumerable < Bundle > , string > ( ) ;
31
- foreach ( var ( division , explaination ) in VersionDivisionsToExplaination )
31
+ foreach ( var ( division , explaination ) in WindowsVersionDivisionsToExplaination )
32
32
{
33
33
var bundlesInRange = bundleList . Where ( bundle => bundle . Version is SdkVersion && division . Item1 <= bundle . Version . SemVer && bundle . Version . SemVer < division . Item2 ) ;
34
34
bundleList = bundleList . Except ( bundlesInRange ) ;
@@ -41,13 +41,43 @@ private static (IDictionary<IEnumerable<Bundle>, string>, IEnumerable<Bundle>) A
41
41
return ( dividedBundles , bundleList ) ;
42
42
}
43
43
44
- public static IEnumerable < Bundle > GetUninstallableBundles ( IEnumerable < Bundle > bundles )
44
+ private static ( IDictionary < IEnumerable < Bundle > , string > , IEnumerable < Bundle > ) ApplyMacVersionDivisions ( IEnumerable < Bundle > bundleList )
45
45
{
46
- if ( ! RuntimeInfo . RunningOnWindows )
46
+ var bundlesAboveLimit = bundleList . Where ( bundle => bundle . Version . SemVer >= UpperLimit ) ;
47
+ bundleList = bundleList . Except ( bundlesAboveLimit ) ;
48
+
49
+ var dividedBundles = bundleList
50
+ . Where ( bundle => bundle . Version is RuntimeVersion )
51
+ . GroupBy ( bundle => bundle . Version . MajorMinor )
52
+ . Select ( pair => ( pair as IEnumerable < Bundle > , LocalizableStrings . MacRuntimeRequirementExplainationString ) )
53
+ . ToDictionary ( key => key . Item1 , value => value . Item2 ) ;
54
+
55
+ var sdks = bundleList . Where ( bundle => bundle . Version is SdkVersion ) ;
56
+ if ( sdks != null && sdks . Count ( ) > 0 )
47
57
{
48
- return bundles ;
58
+ dividedBundles . Add ( sdks , LocalizableStrings . MacSDKRequirementExplainationString ) ;
49
59
}
50
60
61
+ var remainingBundles = bundleList
62
+ . Where ( bundle => ! ( bundle . Version is RuntimeVersion || bundle . Version is SdkVersion ) )
63
+ . Concat ( bundlesAboveLimit ) ;
64
+ return ( dividedBundles , remainingBundles ) ;
65
+ }
66
+
67
+ private static ( IDictionary < IEnumerable < Bundle > , string > , IEnumerable < Bundle > ) ApplyVersionDivisions ( IEnumerable < Bundle > bundles )
68
+ {
69
+ if ( RuntimeInfo . RunningOnWindows )
70
+ {
71
+ return ApplyWindowsVersionDivisions ( bundles ) ;
72
+ }
73
+ else
74
+ {
75
+ return ApplyMacVersionDivisions ( bundles ) ;
76
+ }
77
+ }
78
+
79
+ public static IEnumerable < Bundle > GetUninstallableBundles ( IEnumerable < Bundle > bundles )
80
+ {
51
81
var required = new List < Bundle > ( ) ;
52
82
var ( bundlesByDivisions , remainingBundles ) = ApplyVersionDivisions ( bundles ) ;
53
83
@@ -63,12 +93,6 @@ public static IEnumerable<Bundle> GetUninstallableBundles(IEnumerable<Bundle> bu
63
93
64
94
public static Dictionary < Bundle , string > GetReasonRequiredStrings ( IEnumerable < Bundle > allBundles )
65
95
{
66
- if ( ! RuntimeInfo . RunningOnWindows )
67
- {
68
- return allBundles . Select ( bundle => ( bundle , string . Empty ) )
69
- . ToDictionary ( i => i . bundle , i => i . Item2 ) ;
70
- }
71
-
72
96
var ( bundlesByDivisions , remainingBundles ) = ApplyVersionDivisions ( allBundles ) ;
73
97
74
98
var bundlesAboveUpperLimit = remainingBundles . Where ( bundle => bundle . Version . SemVer >= UpperLimit ) ;
0 commit comments