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:
@@ -30,11 +30,15 @@ namespace Umbraco.Core.Configuration.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return Enum.TryParse<ModelsMode>(ModelsMode, true, out var value)
|
||||
? value
|
||||
: throw new InvalidOperationException(
|
||||
$"Parsing of {nameof(ModelsMode)} field value of {ModelsMode} was not recognised as a valid value of the enum {nameof(ModelsMode)}. " +
|
||||
$"This state shouldn't have been reached as if the configuration contains an invalid valie it should be caught by {nameof(ModelsBuilderSettingsValidator)}.");
|
||||
if (Enum.TryParse<ModelsMode>(ModelsMode, 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 ModelsBuilderSettingsValidator.
|
||||
return Configuration.ModelsMode.Nothing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user