@@ -32,18 +32,20 @@ public static string GetColumnTitle(this IColumn column, SummaryStyle style)
3232 }
3333 }
3434
35- public static bool IsNullOrEmpty < T > ( this IReadOnlyCollection < T > value ) => value == null || value . Count == 0 ;
35+ public static bool IsNullOrEmpty < T > ( this IReadOnlyCollection < T > ? value ) => value == null || value . Count == 0 ;
3636 public static bool IsEmpty < T > ( this IReadOnlyCollection < T > value ) => value . Count == 0 ;
3737 public static bool IsEmpty < T > ( this IEnumerable < T > value ) => ! value . Any ( ) ;
3838
39+ public static IEnumerable < T > WhereNotNull < T > ( this IEnumerable < T ? > values ) => values . Where ( value => value != null ) . Cast < T > ( ) ;
40+
3941 public static void AddRange < T > ( this HashSet < T > hashSet , IEnumerable < T > collection )
4042 {
4143 foreach ( var item in collection )
4244 hashSet . Add ( item ) ;
4345 }
4446
4547#if NETSTANDARD2_0
46- public static TValue GetValueOrDefault < TKey , TValue > ( this IDictionary < TKey , TValue > dictionary , TKey key )
48+ public static TValue ? GetValueOrDefault < TKey , TValue > ( this IDictionary < TKey , TValue > dictionary , TKey key )
4749 => dictionary . TryGetValue ( key , out var value ) ? value : default ;
4850#endif
4951
@@ -97,15 +99,17 @@ internal static string DeleteFileIfExists(this string filePath)
9799
98100 internal static string EnsureFolderExists ( this string filePath )
99101 {
100- string directoryPath = Path . GetDirectoryName ( filePath ) ;
102+ string ? directoryPath = Path . GetDirectoryName ( filePath ) ;
103+ if ( directoryPath == null )
104+ throw new ArgumentException ( $ "Can't get directory path from '{ filePath } '") ;
101105
102106 if ( ! Directory . Exists ( directoryPath ) )
103107 Directory . CreateDirectory ( directoryPath ) ;
104108
105109 return filePath ;
106110 }
107111
108- internal static bool IsNotNullButDoesNotExist ( this FileSystemInfo fileInfo )
112+ internal static bool IsNotNullButDoesNotExist ( this FileSystemInfo ? fileInfo )
109113 => fileInfo != null && ! fileInfo . Exists ;
110114 }
111115}
0 commit comments