@@ -76,21 +76,35 @@ private static string GenerateStringInternal<TValue>(ReadOnlyMemory<string> keys
7676 if ( ! values . IsEmpty && keys . Length != values . Length )
7777 throw new InvalidOperationException ( "The number of values does not match the number of keys." ) ;
7878
79+ ReadOnlySpan < string > keySpan = keys . Span ;
80+
81+ for ( int i = 0 ; i < keySpan . Length ; i ++ )
82+ {
83+ string ? key = keySpan [ i ] ;
84+
85+ if ( key is null )
86+ throw new InvalidOperationException ( "Keys cannot contain null values." ) ;
87+
88+ if ( key . Length == 0 )
89+ throw new InvalidOperationException ( "Keys cannot contain empty strings." ) ;
90+ }
91+
7992 factory ??= NullLoggerFactory . Instance ;
8093
8194 ILogger logger = factory . CreateLogger ( typeof ( FastDataGenerator ) ) ;
8295 LogUserStructureType ( logger , fdCfg . StructureType ) ;
8396
8497 int oldCount = keys . Length ;
8598
86- DeduplicateKeys ( fdCfg , keys , values , StringComparer . Ordinal , StringComparer . Ordinal , out keys , out values , out int newCount ) ;
99+ StringComparer comparer = fdCfg . IgnoreCase ? StringComparer . OrdinalIgnoreCase : StringComparer . Ordinal ;
100+ DeduplicateKeys ( fdCfg , keys , values , comparer , comparer , out keys , out values , out int newCount ) ;
87101
88102 if ( oldCount == newCount )
89103 LogNumberOfKeys ( logger , newCount ) ;
90104 else
91105 LogNumberOfUniqueKeys ( logger , oldCount , newCount ) ;
92106
93- ReadOnlySpan < string > keySpan = keys . Span ;
107+ keySpan = keys . Span ;
94108
95109 const KeyType keyType = KeyType . String ;
96110 LogKeyType ( logger , keyType ) ;
0 commit comments