@@ -49,12 +49,13 @@ public static Dictionary<string, WriteProviderBase> GetWriteProviders()
4949 return typeof ( Utilities ) . Assembly .
5050 GetTypes ( ) .
5151 Where ( type => type . IsSealed && type . IsClass && typeof ( WriteProviderBase ) . IsAssignableFrom ( type ) ) .
52- Select ( type => ( WriteProviderBase ) Activator . CreateInstance ( type ) ) .
53- ToDictionary ( writer => writer . Language , StringComparer . InvariantCultureIgnoreCase ) ;
52+ Select ( type => ( WriteProviderBase ? ) Activator . CreateInstance ( type ) ) .
53+ Where ( writer => writer != null ) .
54+ ToDictionary ( writer => writer ! . Language , writer => writer ! , StringComparer . InvariantCultureIgnoreCase ) ;
5455 }
5556
56- private static async Task < T > TraversePathToRootAsync < T > (
57- string candidatePath , Func < string , Task < T > > action )
57+ private static async Task < T ? > TraversePathToRootAsync < T > (
58+ string candidatePath , Func < string , Task < T ? > > action )
5859 where T : class
5960 {
6061 var path = Path . GetFullPath ( candidatePath ) .
@@ -84,7 +85,7 @@ public static string GetDirectoryNameWithoutTrailingSeparator(string path) =>
8485 public static string GetDirectoryNameWithTrailingSeparator ( string path ) =>
8586 GetDirectoryNameWithoutTrailingSeparator ( path ) + Path . DirectorySeparatorChar ;
8687
87- public static async Task < StructuredRepository > OpenRepositoryAsync (
88+ public static async Task < StructuredRepository ? > OpenRepositoryAsync (
8889 Logger logger , string candidatePath )
8990 {
9091 var repository = await TraversePathToRootAsync ( candidatePath , async path =>
@@ -117,11 +118,12 @@ public static TValue GetValue<TKey, TValue>(
117118 this Dictionary < TKey , TValue > dictionary ,
118119 TKey key ,
119120 TValue defaultValue )
121+ where TKey : notnull
120122 {
121- Debug . Assert ( dictionary != null ) ;
122- Debug . Assert ( key != null ) ;
123+ if ( dictionary == null )
124+ throw new ArgumentNullException ( nameof ( dictionary ) ) ;
123125
124- if ( dictionary . TryGetValue ( key , out TValue value ) == false )
126+ if ( dictionary . TryGetValue ( key , out TValue ? value ) == false )
125127 {
126128 value = defaultValue ;
127129 }
@@ -163,7 +165,7 @@ public static IEnumerable<XElement> LoadRuleSets(string candidatePath)
163165 var rulePath = Path . Combine ( path , "RelaxVersioner.rules" ) ;
164166 if ( File . Exists ( rulePath ) )
165167 {
166- XElement element = null ;
168+ XElement ? element = null ;
167169 try
168170 {
169171 element = XElement . Load ( rulePath ) ;
@@ -200,7 +202,7 @@ from language in rules.Elements("Language")
200202 where ! string . IsNullOrWhiteSpace ( language ? . Value )
201203 select new { language , rules } ) .
202204 GroupBy (
203- entry => entry . language . Value . Trim ( ) ,
205+ entry => entry . language . Value ! . Trim ( ) ,
204206 entry => entry . rules ,
205207 StringComparer . InvariantCultureIgnoreCase ) .
206208 ToDictionary (
@@ -221,7 +223,7 @@ public static IEnumerable<Rule> AggregateRules(XElement wrules)
221223 let name = rule . Attribute ( "name" )
222224 let key = rule . Attribute ( "key" )
223225 where ! string . IsNullOrWhiteSpace ( name ? . Value )
224- select new Rule ( name . Value . Trim ( ) , key ? . Value . Trim ( ) , rule . Value . Trim ( ) ) ) ;
226+ select new Rule ( name ! . Value . Trim ( ) , key ? . Value ? . Trim ( ) ?? "" , rule . Value . Trim ( ) ) ) ;
225227 }
226228
227229 public static XElement GetDefaultRuleSet ( )
@@ -230,7 +232,7 @@ public static XElement GetDefaultRuleSet()
230232 using ( var stream = type . Assembly . GetManifestResourceStream (
231233 type , "DefaultRuleSet.rules" ) )
232234 {
233- return XElement . Load ( stream ) ;
235+ return XElement . Load ( stream ! ) ;
234236 }
235237 }
236238
0 commit comments