Skip to content

Commit

Permalink
WIP Remove function
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-joyle committed Sep 10, 2024
1 parent 923f501 commit bf65e7d
Show file tree
Hide file tree
Showing 18 changed files with 883 additions and 275 deletions.
10 changes: 8 additions & 2 deletions src/libraries/Microsoft.PowerFx.Core/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ internal static class TexlStrings
public static StringGetter AboutClearCollect = (b) => StringResources.Get("AboutClearCollect", b);

public static StringGetter AboutRemove = (b) => StringResources.Get("AboutRemove", b);
public static StringGetter RemoveDataSourceArg = (b) => StringResources.Get("RemoveDataSourceArg", b);
public static StringGetter RemoveRecordsArg = (b) => StringResources.Get("RemoveRecordsArg", b);
public static StringGetter RemoveArg1 = (b) => StringResources.Get("RemoveArg1", b);
public static StringGetter RemoveArg2 = (b) => StringResources.Get("RemoveArg2", b);
public static StringGetter RemoveArg3 = (b) => StringResources.Get("RemoveArg3", b);
public static StringGetter RemoveAllArg2 = (b) => StringResources.Get("RemoveAllArg2", b);

public static StringGetter AboutDec2Hex = (b) => StringResources.Get("AboutDec2Hex", b);
public static StringGetter Dec2HexArg1 = (b) => StringResources.Get("Dec2HexArg1", b);
Expand Down Expand Up @@ -649,6 +651,7 @@ internal static class TexlStrings
public static ErrorResourceKey ErrBadSchema_ExpectedType = new ErrorResourceKey("ErrBadSchema_ExpectedType");
public static ErrorResourceKey ErrInvalidArgs_Func = new ErrorResourceKey("ErrInvalidArgs_Func");
public static ErrorResourceKey ErrNeedTable_Func = new ErrorResourceKey("ErrNeedTable_Func");
public static ErrorResourceKey ErrNeedTable_Arg = new ErrorResourceKey("ErrNeedTable_Arg");
public static ErrorResourceKey ErrNeedTableCol_Func = new ErrorResourceKey("ErrNeedTableCol_Func");
public static ErrorResourceKey ErrNotAccessibleInCurrentContext = new ErrorResourceKey("ErrNotAccessibleInCurrentContext");
public static ErrorResourceKey ErrInternalControlInInputProperty = new ErrorResourceKey("ErrInternalControlInInputProperty");
Expand Down Expand Up @@ -843,5 +846,8 @@ internal static class TexlStrings
public static ErrorResourceKey ErrInvalidDataSourceForFunction = new ErrorResourceKey("ErrInvalidDataSourceForFunction");
public static ErrorResourceKey ErrInvalidArgumentExpectedType = new ErrorResourceKey("ErrInvalidArgumentExpectedType");
public static ErrorResourceKey ErrUnsupportedTypeInTypeArgument = new ErrorResourceKey("ErrUnsupportedTypeInTypeArgument");
public static ErrorResourceKey ErrCollectionDoesNotAcceptThisType = new ErrorResourceKey("ErrCollectionDoesNotAcceptThisType");
public static ErrorResourceKey ErrNeedAll = new ErrorResourceKey("ErrNeedAll");
public static ErrorResourceKey ErrNeedCollection_Func = new ErrorResourceKey("ErrNeedCollection_Func");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,15 @@ internal void AddFunction(TexlFunction function)
{
using var guard = _guard.Enter(); // Region is single threaded.
Inc();
_functions.Add(function);
_functions.Add(function);

if (EnumStoreBuilder == null)
{
_enumStoreBuilder = new EnumStoreBuilder();
}

// Add any associated enums
EnumStoreBuilder?.WithRequiredEnums(new TexlFunctionSet(function));
EnumStoreBuilder.WithRequiredEnums(new TexlFunctionSet(function));
}

internal EnumStoreBuilder EnumStoreBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public override async Task<DValue<BooleanValue>> RemoveAsync(IEnumerable<Formula
if (!found)
{
// https://github.com/microsoft/Power-Fx/issues/2618
errors.Add(new ExpressionError() { Message = "The specified record was not found.", Kind = ErrorKind.NotFound });
errors.Add(new ExpressionError() { Kind = ErrorKind.NotFound });
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ protected override async Task<DValue<RecordValue>> PatchCoreAsync(RecordValue ba
/// <param name="mutationCopy">Should we make a copy of the found record, ahead of mutation.</param>///
/// <returns>A record instance within the current table. This record can then be updated.</returns>
/// <remarks>A derived class may override if there's a more efficient way to find the match than by linear scan.</remarks>
protected virtual async Task<RecordValue> FindAsync(RecordValue baseRecord, CancellationToken cancellationToken, bool mutationCopy = false)
internal virtual async Task<RecordValue> FindAsync(RecordValue baseRecord, CancellationToken cancellationToken, bool mutationCopy = false)
{
cancellationToken.ThrowIfCancellationRequested();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public virtual async Task<DValue<BooleanValue>> ClearAsync(CancellationToken can
{
return DValue<BooleanValue>.Of(NotImplementedError(IRContext));
}


/// <summary>
/// Patch implementation for derived classes.
/// </summary>
Expand Down
Loading

0 comments on commit bf65e7d

Please sign in to comment.