Reverted change to enum parse from string configuration value, as we can't avoid the property being evaluated before the validation has occurred.
This commit is contained in:
@@ -17,11 +17,15 @@ namespace Umbraco.Core.Configuration.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return Enum.TryParse<LocalTempStorage>(LocalTempStorageLocation, true, out var value)
|
||||
? value
|
||||
: throw new InvalidOperationException(
|
||||
$"Parsing of {nameof(LocalTempStorageLocation)} field value of {LocalTempStorageLocation} was not recognised as a valid value of the enum {nameof(LocalTempStorage)}. " +
|
||||
$"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(HostingSettingsValidator)}.");
|
||||
if (Enum.TryParse<LocalTempStorage>(LocalTempStorageLocation, true, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
// We need to return somethhing valid here as this property is evalulated during start-up, and if there's an error
|
||||
// in the configured value it won't be parsed to the enum.
|
||||
// At run-time though this default won't be used, as an invalid value will be picked up by HostingSettingsValidator.
|
||||
return LocalTempStorage.Default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user