@@ -355,15 +355,34 @@ public bool AsBool(bool defaultValue, Func<bool, bool>? validator)
355
355
// ****************
356
356
// Dictionary accessors
357
357
// ****************
358
- [ return : NotNullIfNotNull ( nameof ( getDefaultValue ) ) ]
359
- public IDictionary < string , string > ? AsDictionary ( Func < DefaultResult < IDictionary < string , string > > > ? getDefaultValue = null ) => AsDictionary ( allowOptionalMappings : false , getDefaultValue : getDefaultValue ) ;
358
+ public IDictionary < string , string > ? AsDictionary ( )
359
+ => AsDictionary ( allowOptionalMappings : false , getDefaultValue : null , defaultValueForTelemetry : string . Empty ) ;
360
+
361
+ public IDictionary < string , string > ? AsDictionary ( bool allowOptionalMappings )
362
+ => AsDictionary ( allowOptionalMappings , getDefaultValue : null , defaultValueForTelemetry : string . Empty ) ;
363
+
364
+ public IDictionary < string , string > AsDictionary ( Func < IDictionary < string , string > > getDefaultValue , string defaultValueForTelemetry )
365
+ => AsDictionary ( allowOptionalMappings : false , getDefaultValue : getDefaultValue , defaultValueForTelemetry ) ;
360
366
361
367
[ return : NotNullIfNotNull ( nameof ( getDefaultValue ) ) ]
362
- public IDictionary < string , string > ? AsDictionary ( bool allowOptionalMappings , Func < DefaultResult < IDictionary < string , string > > > ? getDefaultValue = null )
368
+ public IDictionary < string , string > ? AsDictionary (
369
+ bool allowOptionalMappings ,
370
+ Func < IDictionary < string , string > > ? getDefaultValue ,
371
+ string defaultValueForTelemetry )
363
372
{
364
- // TODO: Handle/allow default values + validation?
365
373
var result = GetDictionaryResult ( allowOptionalMappings , separator : ':' ) ;
366
- return TryHandleResult ( Telemetry , Key , result , recordValue : true , getDefaultValue , out var value ) ? value : null ;
374
+ if ( result is { Result : { } ddResult , IsValid : true } )
375
+ {
376
+ return ddResult ;
377
+ }
378
+
379
+ if ( getDefaultValue ? . Invoke ( ) is not { } value )
380
+ {
381
+ return null ;
382
+ }
383
+
384
+ Telemetry . Record ( Key , defaultValueForTelemetry , recordValue : true , ConfigurationOrigins . Default ) ;
385
+ return value ;
367
386
}
368
387
369
388
// ****************
0 commit comments