diff --git a/src/libraries/Microsoft.PowerFx.Core/App/IECSFlags.cs b/src/libraries/Microsoft.PowerFx.Core/App/IECSFlags.cs new file mode 100644 index 0000000000..80b0fb96ae --- /dev/null +++ b/src/libraries/Microsoft.PowerFx.Core/App/IECSFlags.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.PowerFx.Core.App +{ + internal interface IECSFlags + { + internal bool IsNewEnhancedComponentPropertiesFlightEnabled { get; } + + internal bool IsComponentFunctionPropertyDataflowEnabled { get; } + + internal bool IsCommentingImportExportEnabled { get; } + + internal bool ShowPowerFxV1FeatureECSFlag { get; } + + internal bool IsUpdateIfDelegationEnabled { get; } + + internal bool EnableSecureSharedConnectionsByDefault { get; } + + internal bool IsComponentResetBehaviorUpdated { get; } + + internal bool IsPostCompLibImportAnalysisEnabled { get; } + + internal bool IsLazyRecordLoadingEnabled { get; } + + internal bool IsAsyncNodeDelegationEnabled { get; } + + internal bool IsImpureNodeDelegationEnabled { get; } + + internal bool IsDataflowAnalysisVisible { get; } + + internal bool IsDataflowAnalysisEnabledForNewApps { get; } + + internal bool IsDataflowAnalysisEnabledForAllApps { get; } + + internal bool IsAsyncOnComponentFunctionProperties { get; } + + internal bool IsCanvasComponentBehaviorPropertyCoercion { get; } + + internal bool IsModernControlsOnByDefault { get; } + + internal bool IsPowerFxFormulaBarCommentsToFxEnabledV2 { get; } + + internal bool IsPowerFxFormulaBarCommentsToFxEnabledForNewApps { get; } + + internal bool IsRemoveAllDelegationEnabled { get; } + + internal bool IsEditInMCSECSEnabled { get; } + + internal bool IsImperativeUdfEnabled { get; } + + internal bool IsNL2FxReducedContextEnabled { get; } + + internal bool IsProactiveControlRenameEnabled { get; } + } +} diff --git a/src/libraries/Microsoft.PowerFx.Core/App/IExternalDocumentProperties.cs b/src/libraries/Microsoft.PowerFx.Core/App/IExternalDocumentProperties.cs index f7aecee0e4..2b3efc4a94 100644 --- a/src/libraries/Microsoft.PowerFx.Core/App/IExternalDocumentProperties.cs +++ b/src/libraries/Microsoft.PowerFx.Core/App/IExternalDocumentProperties.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using System.Collections.Generic; - namespace Microsoft.PowerFx.Core.App { internal interface IExternalDocumentProperties diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Values/CollectionTableValue.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Values/CollectionTableValue.cs index 6f9387fd8a..5b967c555e 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Values/CollectionTableValue.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Values/CollectionTableValue.cs @@ -263,7 +263,7 @@ protected override async Task> PatchCoreAsync(RecordValue ba /// Should we make a copy of the found record, ahead of mutation./// /// A record instance within the current table. This record can then be updated. /// A derived class may override if there's a more efficient way to find the match than by linear scan. - internal virtual async Task FindAsync(RecordValue baseRecord, CancellationToken cancellationToken, bool mutationCopy = false) + protected virtual async Task FindAsync(RecordValue baseRecord, CancellationToken cancellationToken, bool mutationCopy = false) { cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Remove.cs b/src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Remove.cs index f8e214295e..a01b91b035 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Remove.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Texl/Builtins/Remove.cs @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.Linq; +using Microsoft.PowerFx.Core.App; using Microsoft.PowerFx.Core.App.ErrorContainers; using Microsoft.PowerFx.Core.Binding; using Microsoft.PowerFx.Core.Entities; @@ -21,9 +21,6 @@ namespace Microsoft.PowerFx.Core.Texl.Builtins { // Remove(collection:*[], item1:![], item2:![], ..., ["All"]) - - // !!!TODO MOVE THIS TO src/Cloud/DocumentServer.Core/Document/Texl/Functions/Libraries/BuiltinFunctions.cs - //[RequiresErrorContext] internal class RemoveFunction : BuiltinFunction, ISuggestionAwareFunction { public override bool ManipulatesCollections => true; @@ -328,22 +325,6 @@ public override bool IsAsyncInvocation(CallNode callNode, TexlBinding binding) return Arg0RequiresAsync(callNode, binding); } - // !!!TODO MOVE THIS TO - // src/Cloud/DocumentServer.Core/Document/Texl/Functions/Libraries/BuiltinFunctions.cs and - // src/Cloud/DocumentServer.Core/Document/Publish/TryPushCustomJsExpressionHandlers.cs - //public static void PushCustomJsArgs(TexlFunction func, JsTranslator translator, TexlBinding binding, CallNode node, List argFragments) - //{ - // Contracts.Assert(argFragments.Count >= 1); - - // // If the "ALL" arg was not specified, inject an empty string arg instead. - // var args = node.Args.Children; - - // if (argFragments.Count < 3 || !DType.String.Accepts(binding.GetType(args[argFragments.Count - 1]), exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: binding.Features.PowerFxV1CompatibilityRules)) - // { - // argFragments.Add(translator.CreateFragment(PAStringBuilderConst.EmptyQuotes)); - // } - //} - protected override bool RequiresPagedDataForParamCore(TexlNode[] args, int paramIndex, TexlBinding binding) { Contracts.AssertValue(args); @@ -358,9 +339,6 @@ protected override bool RequiresPagedDataForParamCore(TexlNode[] args, int param } // Remove(collection:*[], source:*[], ["All"]) - // !!!TODO MOVE THIS TO src/Cloud/DocumentServer.Core/Document/Texl/Functions/Libraries/BuiltinFunctions.cs - //[RequiresErrorContext] - //[TexlRuntimeNameOverride(Suffix = "All")] internal class RemoveAllFunction : BuiltinFunction { public override bool ManipulatesCollections => true; @@ -538,27 +516,6 @@ public override bool IsAsyncInvocation(CallNode callNode, TexlBinding binding) return Arg0RequiresAsync(callNode, binding); } - // !!!TODO MOVE THIS TO - // src/Cloud/DocumentServer.Core/Document/Texl/Functions/Libraries/BuiltinFunctions.cs and - // src/Cloud/DocumentServer.Core/Document/Publish/TryPushCustomJsExpressionHandlers.cs - //public static void PushCustomJsArgs(TexlFunction func, JsTranslator translator, TexlBinding binding, CallNode node, List argFragments) - //{ - // Contracts.Assert(argFragments.Count >= 1); - - // if (func.IsServerDelegatable(node, binding)) - // { - // // If remove all is delegatable && the "ALL" arg was not specified, the translator handles it - // return; - // } - - // // If the "ALL" arg was not specified, inject an empty string arg instead. - // var args = node.Args.Children; - // if (argFragments.Count < 3 || !DType.String.Accepts(binding.GetType(args[argFragments.Count - 1]), exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: binding.Features.PowerFxV1CompatibilityRules)) - // { - // argFragments.Add(translator.CreateFragment(PAStringBuilderConst.EmptyQuotes)); - // } - //} - public override bool IsServerDelegatable(CallNode callNode, TexlBinding binding) { Contracts.AssertValue(callNode); @@ -569,18 +526,17 @@ public override bool IsServerDelegatable(CallNode callNode, TexlBinding binding) return false; } - // !!!TODO Check with PA team // Use ECS flag as a guard. - //if (binding.Document != null) - //{ - // if (binding.Document.Properties is DocumentProperties documentProperties) - // { - // if (!documentProperties.IsRemoveAllDelegationEnabled) - // { - // return false; - // } - // } - //} + if (binding.Document != null) + { + if (binding.Document.Properties is IECSFlags flags) + { + if (!flags.IsRemoveAllDelegationEnabled) + { + return false; + } + } + } if (!binding.TryGetDataSourceInfo(callNode.Args.Children[0], out IExternalDataSource dataSource)) { diff --git a/src/libraries/Microsoft.PowerFx.Interpreter/Functions/Mutation/MutationUtils.cs b/src/libraries/Microsoft.PowerFx.Interpreter/Functions/Mutation/MutationUtils.cs index 57dab31ff0..8ef3965e63 100644 --- a/src/libraries/Microsoft.PowerFx.Interpreter/Functions/Mutation/MutationUtils.cs +++ b/src/libraries/Microsoft.PowerFx.Interpreter/Functions/Mutation/MutationUtils.cs @@ -1,21 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.PowerFx.Core.App.ErrorContainers; -using Microsoft.PowerFx.Core.Entities; -using Microsoft.PowerFx.Core.Errors; using Microsoft.PowerFx.Core.IR; -using Microsoft.PowerFx.Core.Localization; -using Microsoft.PowerFx.Core.Types; -using Microsoft.PowerFx.Core.Types.Enums; -using Microsoft.PowerFx.Functions; using Microsoft.PowerFx.Interpreter.Localization; -using Microsoft.PowerFx.Syntax; using Microsoft.PowerFx.Types; namespace Microsoft.PowerFx.Interpreter @@ -75,7 +66,7 @@ public static async Task RemoveCore(FormulaType irContext, Formula return arg0; } - // If any of the argN (N>0) are an error, return the error. + // If any of the argN (N>0) is error, return the error. foreach (var arg in args.Skip(1)) { cancellationToken.ThrowIfCancellationRequested(); @@ -87,7 +78,7 @@ public static async Task RemoveCore(FormulaType irContext, Formula if (arg is TableValue tableValue) { - var errorRecord = tableValue.Rows.FirstOrDefault(row => row.IsError); + var errorRecord = tableValue.Rows.First(row => row.IsError); if (errorRecord != null) { return errorRecord.Error;