Added a new property on IExternalRule interface. (#2715)

As PA is moving away from rules with null binding, this PR introduces a
new property called HasValidBinding which needs to be used to check the
binding validity in future rather than Binding property itself.
Eventually we should remove the Binding property from rule to abstract
that. This change is first step towards that direction.
This commit is contained in:
Shpakh-MSFT 2024-10-23 11:03:21 -07:00 коммит произвёл GitHub
Родитель 05e865efb4
Коммит ca42fbc708
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -19,5 +19,8 @@ namespace Microsoft.PowerFx.Core.App.Controls
TexlBinding Binding { get; }
bool HasErrorsOrWarnings { get; }
// Returns true when Binding is non-null, otherwise false.
bool HasValidBinding { get; }
}
}

Просмотреть файл

@ -1002,7 +1002,7 @@ namespace Microsoft.PowerFx.Core.Binding
return Enumerable.Empty<string>();
}
var ruleQueryOptions = Rule.Binding?.QueryOptions.GetQueryOptions(ds);
var ruleQueryOptions = Rule.HasValidBinding ? Rule.Binding.QueryOptions.GetQueryOptions(ds) : null;
if (ruleQueryOptions != null)
{
foreach (var nodeQO in Rule.TexlNodeQueryOptions)
@ -3618,7 +3618,10 @@ namespace Microsoft.PowerFx.Core.Binding
// If the reference is to Control.Property and the rule for that Property is a constant,
// we need to mark the node as constant, and save the control info so we may look up the
// rule later.
if (controlInfo?.GetRule(property.InvariantName) is IExternalRule rule && rule.Binding != null && !rule.HasErrorsOrWarnings && rule.Binding.IsConstant(rule.Binding.Top))
if (controlInfo?.GetRule(property.InvariantName) is IExternalRule rule &&
rule.HasValidBinding &&
!rule.HasErrorsOrWarnings &&
rule.Binding.IsConstant(rule.Binding.Top))
{
value = controlInfo;
isConstant = true;