@@ -133,14 +133,31 @@ public string ToString(string format, IFormatProvider formatProvider = null)
133
133
case "t" :
134
134
return Number . HasValue ? string . Format ( "{0}.{1}" , Name , Number ) : Name ;
135
135
case "l" :
136
- return Number . HasValue ? string . Format ( "{0}{1}" , Name , Number ) : Name ;
136
+ return Number . HasValue ? FormatLegacy ( GetLegacyName ( ) , Number . ToString ( ) ) : FormatLegacy ( GetLegacyName ( ) ) ;
137
137
case "lp" :
138
- return Number . HasValue ? string . Format ( "{0}{1}" , Name , Number . Value . ToString ( "D4" ) ) : Name ;
138
+ return Number . HasValue ? FormatLegacy ( GetLegacyName ( ) , Number . Value . ToString ( "D4" ) ) : FormatLegacy ( GetLegacyName ( ) ) ;
139
139
default :
140
140
throw new ArgumentException ( "Unknown format" , "format" ) ;
141
141
}
142
142
}
143
143
144
+ string FormatLegacy ( string tag , string number = null )
145
+ {
146
+ var tagLength = tag . Length ;
147
+ var numberLength = number == null ? 0 : number . Length ;
148
+
149
+ if ( tagLength + numberLength > 20 )
150
+ return string . Format ( "{0}{1}" , tag . Substring ( 0 , 20 - numberLength ) , number ) ;
151
+
152
+ return string . Format ( "{0}{1}" , tag , number ) ;
153
+ }
154
+
155
+ string GetLegacyName ( )
156
+ {
157
+ var firstPart = Name . Split ( '_' ) [ 0 ] ;
158
+ return firstPart . Replace ( "-" , string . Empty ) . Replace ( "." , string . Empty ) ;
159
+ }
160
+
144
161
public bool HasTag ( )
145
162
{
146
163
return ! string . IsNullOrEmpty ( Name ) ;
0 commit comments