@@ -13,7 +13,8 @@ public static class Channels
1313{
1414 public static string GetDesc ( this Channel c ) => c switch
1515 {
16- Channel . Versioned v => $ "The latest version in the { v } support channel",
16+ Channel . VersionedMajorMinor v => $ "The latest version in the { v } support channel",
17+ Channel . VersionedFeature v => $ "The latest version in the { v } support channel",
1718 Channel . Lts => "The latest version in Long-Term support" ,
1819 Channel . Sts => "The latest version in Short-Term support" ,
1920 Channel . Latest => "The latest supported version from either the LTS or STS support channels." ,
@@ -30,7 +31,12 @@ private Channel() { }
3031 /// <summary>
3132 /// A major-minor versioned channel.
3233 /// </summary>
33- public sealed partial record Versioned ( int Major , int Minor ) : Channel ;
34+ public sealed partial record VersionedMajorMinor ( int Major , int Minor ) : Channel ;
35+ /// <summary>
36+ /// A major-minor-patch versioned channel.
37+ /// </summary>
38+ /// <param name="FeatureLevel"> The feature level of the version, e.g. 1 in 9.0.100</param>
39+ public sealed partial record VersionedFeature ( int Major , int Minor , int FeatureLevel ) : Channel ;
3440 /// <summary>
3541 /// Newest Long Term Support release.
3642 /// </summary>
@@ -67,10 +73,14 @@ void ISerialize<Channel>.Serialize(Channel channel, ISerializer serializer)
6773 => serializer . SerializeString ( channel . GetLowerName ( ) ) ;
6874 }
6975
70- partial record Versioned
76+ partial record VersionedMajorMinor
7177 {
7278 public override string GetDisplayName ( ) => $ "{ Major } .{ Minor } ";
7379 }
80+ partial record VersionedFeature
81+ {
82+ public override string GetDisplayName ( ) => $ "{ Major } .{ Minor } .{ FeatureLevel } xx";
83+ }
7484 partial record Lts : Channel
7585 {
7686 public override string GetDisplayName ( ) => "LTS" ;
@@ -103,13 +113,24 @@ public static Channel FromString(string str)
103113 case "preview" : return new Preview ( ) ;
104114 default :
105115 var components = str . Split ( '.' ) ;
106- if ( components . Length != 2 )
116+ switch ( components )
107117 {
108- throw new DeserializeException ( $ "Invalid channel version: { str } ") ;
118+ case [ _, _] :
119+ var major = int . Parse ( components [ 0 ] ) ;
120+ var minor = int . Parse ( components [ 1 ] ) ;
121+ return new VersionedMajorMinor ( major , minor ) ;
122+ case [ _, _, _] :
123+ if ( components [ 2 ] is not [ <= '9' and >= '0' , 'x' , 'x' ] )
124+ {
125+ throw new DeserializeException ( $ "Feature band must be 3 characters and end in 'xx': { str } ") ;
126+ }
127+ major = int . Parse ( components [ 0 ] ) ;
128+ minor = int . Parse ( components [ 1 ] ) ;
129+ var featureLevel = components [ 2 ] [ 0 ] - '0' ;
130+ return new VersionedFeature ( major , minor , featureLevel ) ;
131+ default :
132+ throw new DeserializeException ( $ "Invalid channel version: { str } ") ;
109133 }
110- var major = int . Parse ( components [ 0 ] ) ;
111- var minor = int . Parse ( components [ 1 ] ) ;
112- return new Versioned ( major , minor ) ;
113134 }
114135 }
115136
0 commit comments