Mark rule as async, if async NamedFormulas are used. (#233)

* initial commit

* added IsAsync to IExternalRule

* Added IsAsync property in NameLookupInfo

* NameLookupInfo changes

* PR Feedback

* PR Feedback
This commit is contained in:
Vamsi Modem 2022-03-22 16:42:27 -07:00 коммит произвёл GitHub
Родитель bdef5ff5be
Коммит ad24027103
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 8 добавлений и 4 удалений

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

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using Microsoft.PowerFx.Core.Entities;
using Microsoft.PowerFx.Core.Types;
using Microsoft.PowerFx.Core.Utils;
@ -21,11 +22,12 @@ namespace Microsoft.PowerFx.Core.Binding.BindInfo
/// it has the display name of the object in Data.
/// </summary>
public readonly DName DisplayName;
public readonly bool IsAsync;
// Optional data associated with a name. May be null.
public readonly object Data;
public NameLookupInfo(BindKind kind, DType type, DPath path, int upCount, object data = null, DName displayName = default)
public NameLookupInfo(BindKind kind, DType type, DPath path, int upCount, object data = null, DName displayName = default, bool isAsync = false)
{
Contracts.Assert(kind >= BindKind.Min && kind < BindKind.Lim);
Contracts.Assert(upCount >= 0);
@ -37,6 +39,9 @@ namespace Microsoft.PowerFx.Core.Binding.BindInfo
UpCount = upCount;
Data = data;
DisplayName = displayName;
// Any connectedDataSourceInfo or option set or view needs to be accessed asynchronously to allow data to be loaded.
IsAsync = Data is IExternalTabularDataSource || Kind == BindKind.OptionSet || Kind == BindKind.View || isAsync;
}
}
}

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

@ -3057,8 +3057,7 @@ namespace Microsoft.PowerFx.Core.Binding
_txb.ErrorContainer.EnsureError(node, TexlStrings.ErrValueMustBeFullyQualified);
}
// Any connectedDataSourceInfo or option set or view needs to be accessed asynchronously to allow data to be loaded.
if (lookupInfo.Data is IExternalTabularDataSource || lookupInfo.Kind == BindKind.OptionSet || lookupInfo.Kind == BindKind.View)
if (lookupInfo.IsAsync)
{
_txb.FlagPathAsAsync(node);
}