@@ -8,42 +8,46 @@ namespace Microsoft.DotNet.Workloads.Workload
88{
99 static class WorkloadSetVersion
1010 {
11- public static string ToWorkloadSetPackageVersion ( string workloadSetVersion , out SdkFeatureBand sdkFeatureBand )
11+ private static string [ ] SeparateCoreComponents ( string workloadSetVersion , out string [ ] sections )
12+ {
13+ sections = workloadSetVersion . Split ( [ '-' , '+' ] , 2 ) ;
14+ return sections [ 0 ] . Split ( '.' ) ;
15+ }
16+
17+ public static bool IsWorkloadSetPackageVersion ( string workloadSetVersion )
1218 {
13- string [ ] sections = workloadSetVersion . Split ( new char [ ] { '-' , '+' } , 2 ) ;
14- string versionCore = sections [ 0 ] ;
15- string ? preReleaseOrBuild = sections . Length > 1 ? sections [ 1 ] : null ;
19+ int coreComponentsLength = SeparateCoreComponents ( workloadSetVersion , out _ ) . Length ;
20+ return coreComponentsLength >= 3 && coreComponentsLength <= 4 ;
21+ }
1622
17- string [ ] coreComponents = versionCore . Split ( '.' ) ;
23+ public static string ToWorkloadSetPackageVersion ( string workloadSetVersion , out SdkFeatureBand sdkFeatureBand )
24+ {
25+ string [ ] coreComponents = SeparateCoreComponents ( workloadSetVersion , out string [ ] sections ) ;
1826 string major = coreComponents [ 0 ] ;
1927 string minor = coreComponents [ 1 ] ;
2028 string patch = coreComponents [ 2 ] ;
21-
2229 string packageVersion = $ "{ major } .{ patch } .";
2330 if ( coreComponents . Length == 3 )
2431 {
2532 // No workload set patch version
2633 packageVersion += "0" ;
27-
2834 // Use preview specifier (if any) from workload set version as part of SDK feature band
2935 sdkFeatureBand = new SdkFeatureBand ( workloadSetVersion ) ;
3036 }
3137 else
3238 {
3339 // Workload set version has workload patch version (ie 4 components)
3440 packageVersion += coreComponents [ 3 ] ;
35-
3641 // Don't include any preview specifiers in SDK feature band
3742 sdkFeatureBand = new SdkFeatureBand ( $ "{ major } .{ minor } .{ patch } ") ;
3843 }
3944
40- if ( preReleaseOrBuild != null )
45+ if ( sections . Length > 1 )
4146 {
4247 // Figure out if we split on a '-' or '+'
4348 char separator = workloadSetVersion [ sections [ 0 ] . Length ] ;
44- packageVersion += separator + preReleaseOrBuild ;
49+ packageVersion += separator + sections [ 1 ] ;
4550 }
46-
4751 return packageVersion ;
4852 }
4953
0 commit comments