Remove binding reference for component function props (#2664)

This commit is contained in:
McCall Saltzman 2024-10-11 09:11:27 -07:00 коммит произвёл GitHub
Родитель 13fa198864
Коммит d3c93a3869
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 10 добавлений и 11 удалений

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

@ -1002,7 +1002,7 @@ namespace Microsoft.PowerFx.Core.Binding
return Enumerable.Empty<string>();
}
var ruleQueryOptions = Rule.Binding.QueryOptions.GetQueryOptions(ds);
var ruleQueryOptions = Rule.Binding?.QueryOptions.GetQueryOptions(ds);
if (ruleQueryOptions != null)
{
foreach (var nodeQO in Rule.TexlNodeQueryOptions)
@ -3612,7 +3612,7 @@ 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 { HasErrorsOrWarnings: false } rule && rule.Binding.IsConstant(rule.Binding.Top))
if (controlInfo?.GetRule(property.InvariantName) is { HasErrorsOrWarnings: false } rule && rule.Binding != null && rule.Binding.IsConstant(rule.Binding.Top))
{
value = controlInfo;
isConstant = true;
@ -4157,15 +4157,14 @@ namespace Microsoft.PowerFx.Core.Binding
var infoTexlFunction = info.Function;
if (_txb._glue.IsComponentScopedPropertyFunction(infoTexlFunction))
{
// We only have to check the property's rule and the calling arguments for purity as scoped variables
// (default values) are by definition data rules and therefore always pure.
if (_txb.Document != null && _txb.Document.TryGetControlByUniqueId(infoTexlFunction.Namespace.Name.Value, out var ctrl) &&
ctrl.TryGetRule(new DName(infoTexlFunction.Name), out var rule))
{
hasSideEffects |= rule.Binding.HasSideEffects(rule.Binding.Top);
isStateFul |= rule.Binding.IsStateful(rule.Binding.Top);
}
{
// Behavior only component properties should be treated as stateful.
hasSideEffects |= infoTexlFunction.IsBehaviorOnly;
// At the moment, we're going to treat all invocations of component scoped property functions as stateful.
// This ensures that we don't lift these function invocations in loops, and that they are re-evaluated every time they are called,
// which is always correct, although less efficient in some cases.
isStateFul |= true;
}
else
{