forked from fluentassertions/fluentassertions
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intercept Reflection exceptions from
AppSettingsConfigurationStore
Some platforms throws reflection exceptions when trying to use `ConfigurationManager`. This does not fix the underlying problem of not being unable to use `ConfigurationManager`, but returns `null` instead of an exception. Relates to fluentassertions#1207 and fluentassertions#1151
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Src/FluentAssertions/Common/ConfigurationStoreExceptionInterceptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#if !NETSTANDARD1_3 && !NETSTANDARD1_6 | ||
|
||
namespace FluentAssertions.Common | ||
{ | ||
internal class ConfigurationStoreExceptionInterceptor : IConfigurationStore | ||
{ | ||
private readonly IConfigurationStore configurationStore; | ||
|
||
public ConfigurationStoreExceptionInterceptor(IConfigurationStore configurationStore) | ||
{ | ||
this.configurationStore = configurationStore; | ||
} | ||
|
||
public string GetSetting(string name) | ||
{ | ||
try | ||
{ | ||
return configurationStore.GetSetting(name); | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters