Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Conditionaly typo #8087

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public enum PrecedenceDefinition
/// <summary>
/// Set if and only if only the IsRequiredCondition is set.
/// </summary>
ConditionalyRequired,
ConditionallyRequired,

/// <summary>
/// Parameter value is not required from user.
Expand All @@ -34,7 +34,7 @@ public enum PrecedenceDefinition
/// <summary>
/// Parameter might become disabled - value would not be needed nor used in such case.
/// </summary>
ConditionalyDisabled,
ConditionallyDisabled,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could avoid the breaking change by adding the corrected enum value and hiding the existing one

[EditorBrowsable(EditorBrowsableState.Never)]
ConditionalyDisabled

and

ConditionallyDisabled = ConditionalyDisabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or mark ConditionalyDisabled as obsolete

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or both :)


/// <summary>
/// Parameter is disabled - it's value is not required and will not be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ Microsoft.TemplateEngine.Abstractions.ITemplate.Generator.get -> Microsoft.Templ
Microsoft.TemplateEngine.Abstractions.ITemplate.LocaleConfiguration.get -> Microsoft.TemplateEngine.Abstractions.Mount.IFileSystemInfo?
Microsoft.TemplateEngine.Abstractions.ITemplateParameter.AllowMultipleValues.get -> bool
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.ConditionalyDisabled = 4 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.ConditionalyRequired = 1 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.ConditionallyDisabled = 4 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.ConditionallyRequired = 1 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.Disabled = 5 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.Implicit = 3 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition.Optional = 2 -> Microsoft.TemplateEngine.Abstractions.PrecedenceDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ private void VerifyConditions()
// If enable condition is set - parameter is conditionally disabled (regardless if require condition is set or not)
// Conditionally required is if and only if the only require condition is set

if (!(string.IsNullOrEmpty(IsRequiredCondition) ^ PrecedenceDefinition == PrecedenceDefinition.ConditionalyRequired
if (!(string.IsNullOrEmpty(IsRequiredCondition) ^ PrecedenceDefinition == PrecedenceDefinition.ConditionallyRequired
||
!string.IsNullOrEmpty(IsEnabledCondition) ^ PrecedenceDefinition == PrecedenceDefinition.ConditionalyDisabled)
!string.IsNullOrEmpty(IsEnabledCondition) ^ PrecedenceDefinition == PrecedenceDefinition.ConditionallyDisabled)
&&
!(!string.IsNullOrEmpty(IsRequiredCondition) && !string.IsNullOrEmpty(IsEnabledCondition) && PrecedenceDefinition == PrecedenceDefinition.ConditionalyDisabled))
!(!string.IsNullOrEmpty(IsRequiredCondition) && !string.IsNullOrEmpty(IsEnabledCondition) && PrecedenceDefinition == PrecedenceDefinition.ConditionallyDisabled))
{
// TODO: localize
throw new ArgumentException("Mismatched precedence definition");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public static EvaluatedPrecedence GetEvaluatedPrecedence(this InputParameterData
{
PrecedenceDefinition.Required => EvaluatedPrecedence.Required,
// Conditionally required state is only set if enabled condition is not present
PrecedenceDefinition.ConditionalyRequired => dt!.IsRequiredConditionResult!.Value ? EvaluatedPrecedence.Required : EvaluatedPrecedence.Optional,
PrecedenceDefinition.ConditionallyRequired => dt!.IsRequiredConditionResult!.Value ? EvaluatedPrecedence.Required : EvaluatedPrecedence.Optional,
PrecedenceDefinition.Optional => EvaluatedPrecedence.Optional,
PrecedenceDefinition.Implicit => EvaluatedPrecedence.Implicit,
PrecedenceDefinition.ConditionalyDisabled => !dt!.IsEnabledConditionResult!.Value
PrecedenceDefinition.ConditionallyDisabled => !dt!.IsEnabledConditionResult!.Value
? EvaluatedPrecedence.Disabled
:
(dt.IsRequiredConditionResult.HasValue && dt.IsRequiredConditionResult.Value) || dt.ParameterDefinition.Precedence.IsRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static TemplateParameterPrecedence GetPrecedence(bool isRequired, bool i

if (!string.IsNullOrEmpty(isEnabledCondition))
{
return new TemplateParameterPrecedence(PrecedenceDefinition.ConditionalyDisabled, isRequiredCondition, isEnabledCondition, isRequired);
return new TemplateParameterPrecedence(PrecedenceDefinition.ConditionallyDisabled, isRequiredCondition, isEnabledCondition, isRequired);
}

if (isTag)
Expand All @@ -231,7 +231,7 @@ private static TemplateParameterPrecedence GetPrecedence(bool isRequired, bool i

if (!string.IsNullOrEmpty(isRequiredCondition))
{
return new TemplateParameterPrecedence(PrecedenceDefinition.ConditionalyRequired, isRequiredCondition, null);
return new TemplateParameterPrecedence(PrecedenceDefinition.ConditionallyRequired, isRequiredCondition, null);
}

if (isRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void CanHandleParameters()
SettingsFilePaths paths = new SettingsFilePaths(environmentSettings);

ITemplateParameter param1 = new TemplateParameter("param1", "parameter", "string");
ITemplateParameter param2 = new TemplateParameter("param2", "parameter", "string", new TemplateParameterPrecedence(PrecedenceDefinition.ConditionalyRequired, isRequiredCondition: "param1 == \"foo\""));
ITemplateParameter param2 = new TemplateParameter("param2", "parameter", "string", new TemplateParameterPrecedence(PrecedenceDefinition.ConditionallyRequired, isRequiredCondition: "param1 == \"foo\""));
ITemplateParameter param3 = new TemplateParameter(
"param3",
"parameter",
Expand Down