Граф коммитов

915 Коммитов

Автор SHA1 Сообщение Дата
Akshar V Patel 6c4014b371
Adding ability to supply custom binding config to Engine.ComputeBinding() & Fixing Dup String Interp Tokens bug (#1531)
This pr handles few things that are mentioned below:
1) It adds a new virtual overload of `GetDefaultBindingConfig` in
Engine.cs that takes in ParserOptions and optional rule scope and
returns a binding config that is used by `Engine.ComputeBinding()`. This
is done so that Power Apps can supply custom binding config for semantic
tokenization. Power Apps never set
`BindingConfig.UseThisRecordForRuleScope` to true but changes before
this pr calculated the value of
`BindingConfig.UseThisRecordForRuleScope` based on the value returned
from `Engine.GetRuleScope()`. It would be true when GetRuleScope()
returns a non null value. There are properties such as `OnErrors `on
AppInfo control in PowerApps that returns a non null value for
`GetRuleScope()`. In this case,` useThisRecordForRuleScope `would be
true in` Engine.ComputeBinding() `but it should never be true when
`Engine.ComputeBinding() `is run from PowerApps.

2) This pr fixes a bug where duplicate string interpolation and island
tokens were added when expression has nested string interpolation to the
list of tokens returned from Tokenization.Tokenize. This pr fixes that
logic and adds tests to validate it. A good example of this bug is an
expression like `$"{$"{$"{$"{.12e4}"}"}"}"`. The number of tokens should
be 17 but it is 41. Many of them are duplicate with same spans and token
types.

3) This pr also fixes one test that happened due to Visual Studio
picking up a different line feed for C# multiline strings `@""` .
Updates the test to avoid using multiline string. @gregli-msft is the
only and first one so far to face this problem. Tests were failing for
him. Confirmed with him that avoiding multiline string fixes the test.
2023-05-31 22:12:52 -04:00
Mike Stall 5bd41ba5f3
Fix flaky threading test (#1542)
Fix #1541

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2023-05-31 08:40:02 -07:00
toshio-msft a3385280a9
[[Power-Fx]] Localization hand-back [CTAS - RunID=20230530-235707-5y8x0bvy57] (#1539)
Translation handback check-in (PR Created by automation).
2023-05-31 08:08:48 -07:00
Mike Stall 410d7de689
add thread safety guard (#1523)
add guard to catch bugs in host where it calls a single-threaded region
on multiple threads.

---------

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2023-05-30 15:57:44 -07:00
toshio-msft 19e611f0cb
[[Power-Fx]] Localization hand-back [CTAS - RunID=20230523-161854-qsjwm932b4] (#1524)
Translation handback check-in (PR Created by automation).

Co-authored-by: Luc Genetier <69138830+LucGenetier@users.noreply.github.com>
Co-authored-by: Mike Stall <mikestall@hotmail.com>
2023-05-26 10:46:59 -07:00
Hoa Nguyen 16b4135262
Add allow input types for specific expected return type (#1500)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1356
2023-05-25 11:22:53 -07:00
Carlos Figueira 9c632010a4
Make the Switch/IfError functions follow the first-type rule (#1521)
Currently the Switch and IfError functions use an intersection rule for the arguments - Switch(var, 1, {a:1}, {b:2}) returns an empty record since there are no common properties in the two records. With the PowerFxV1 rules, we are changing it to follow the "union with first-type rule" that is used in other functions, so the type of that expression would be ![a:n] with the new feature.

This is similar to #1507 which did the change for the If function.
2023-05-25 09:46:12 -07:00
Hoa Nguyen a8805417aa
Fix overflow of Mod_Float for large number (#1522)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1367

Problem this PR fix:
Start from 1e+16 to 1e+20, current mod_float return 0 for most of the
case (mostly wrong value). And overflow from 1e+21 or higher.
This PR use C# % function to do mod for the wrong/overflow issues.

Note on PA (Need to fix as well): mod result is always 0 from 1e18 (mod
123). So, it shared the same problem. mod result is wrong for > 1e17. It
did not return overflow error for 1e306 but return 0 (wrong value).

---------

Co-authored-by: Carlos Figueira <carlosff@microsoft.com>
2023-05-25 08:08:49 -07:00
Anderson Silva ed759c95ad
Patch and Remove that do not find the record should error (#1528)
Issue #1517
2023-05-25 09:44:22 -05:00
Carlos Figueira dec124ed86
Allow Void expressions to be used within ForAll (#1527)
If a ForAll expression is used within a context where its result is not needed, then it should be able to use void expressions, like in the example below. This change allows it, making the entire result of the ForAll expression a void result.

    ForAll(
        Sequence(4),
        If(
            Mod(Value, 2) = 1,
Patch( table, Index(table, Value), { IsOdd: true } ), // this returns a
record, incompatible with tables
Collect( table, { Value: Value, IsOdd: false }, { Value: Value + 1,
IsOdd: true } // this returns a table
        )
    )
2023-05-24 15:22:20 -07:00
Luc Genetier 5de68e10d2
Fix Refresh function (#1526) 2023-05-24 14:47:55 +02:00
Carlos Figueira 7c3765320f
Make data source FirstNameNodes also mutable (#1525)
A previous change to tag nodes for mutability didn't take account of connected data source nodes. This updates it.
2023-05-23 15:48:50 -07:00
Luc Genetier 8d663df4b3
Add refresh function (#1504) 2023-05-23 17:25:57 +02:00
Mike Stall 024e6bcc36
Threading tests (#1520)
Threading tests to help enforce #1519 .
Includes a bunch of little fixes and reducing failure list.

Tests don't aggressively assert yes, too many failures. But we can at
least run and drive to 0.

---------

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2023-05-19 16:48:21 -07:00
Mike Stall e405f64a8e
Jmstall/fix1511 (#1516)
Fix for race condition in #1511

---------

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2023-05-19 12:59:33 -07:00
Carlos Figueira 2e441654bc
Prevent mutation functions from updating immutable values (#1499)
Currently the Patch/Collect functions can update values that should be immutable (like scope variables defined in a With record). This change defines a "mutable" concept in the binder, which can be checked by mutation functions so that they won't update those values.
2023-05-19 07:48:26 -07:00
Mike Stall a8f8579b0c
More flexible User object. (#1506)
1. Allow pattern for adding new user properties. So switch to a class
instead of interface so it's non-breaking. List is still curated by Fx
team, so we want a class (with well defined property names) and not a
property bag.
2. Allow static enforcement for the subset of properties a host
provides.
3. Dynamic population - some properties require a network call, and this
needs to be lazily done.

Achieve these via a custom derived RecordValue that wraps a UserInfo
provided by the serviceProvider.

Include a helper, BasicUserInfo, for implementing the common paths.

---------

Co-authored-by: Mike Stall <jmstall@microsoft.com>
2023-05-17 11:59:25 -07:00
Akshar V Patel 0b5c49ca3e
Fxing expression formatting/pretty print bug with reserved keywords (#1509)
Earlier this week, Customer reached out to us about a bug when trying to
format the expression like "Set(Children; true)" in the formula bar.
"Children" is not a reserved keyword and unless the disabled reserved
keyword flag is not set when invoking Lexer, "Children" gets identified
as an ErrorToken. This causes errors in the AST and we don't format when
there are errors and just return the same expression.

To solve this, we need to pass in a Flags.DisabledReservedKeyword flag
to the parser and ultimately lexer when invoking them before the pretty
printing. There was no ability to pass in custom flags so I extended the
"Format" function (which is an entry point for pretty printing) with an
optional argument to allow passing custom flags. These changes would be
later consumed in Canvas Apps Backend (Would be passing in
Flags.DisabledReservedKeyword | Flags.EnableExpressionChaining to Format
in Canvas Apps Backend)

@gregli-msft Could you take a look at this and see if this is the right
way to solve it
2023-05-17 14:34:11 -04:00
Carlos Figueira 58376e5243
Make the If function follow the first-type rule (#1507)
Currently the If function uses an intersection rule for the arguments - `If(varBool, {a:1}, {b:2})` returns an empty record since there are no common properties in the two records. With the PowerFxV1 rules, we are changing it to follow a union rule, with "first-type preference" that is used in other functions like Table, so the type of that expression would be `![a:n,b:n]` with the new feature.

Addresses #1497
2023-05-17 09:52:08 -07:00
Akshar V Patel f760245abd
Adding the very small part of logic behind hiding tokens I forgot to migrate in PR #1420 (#1510)
The support for semantic tokenization was added in PR
https://github.com/microsoft/Power-Fx/pull/1420. I migrated the logic
behind tokenization in old formula bar from Canvas App backend to
PowerFx. In doing so, i forgot to bring over a very tiny part but
important for old formula bar of the logic that computes whether first
name tokens can be hidden or not.
2023-05-17 09:24:50 -04:00
toshio-msft 5c440e6f45
[[Power-Fx]] Localization hand-back [CTAS - RunID=20230516-200659-en70cep1j6] (#1508)
Translation handback check-in (PR Created by automation).
2023-05-16 14:25:53 -07:00
Hoa Nguyen 0348788b32
Add PlainText Function (#1454)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1429
2023-05-16 10:36:13 -07:00
Hoa Nguyen 991788bb43
Add tests for With function (#1505)
Fix https://github.com/microsoft/Power-Fx/issues/1503
2023-05-15 22:38:49 -07:00
Carlos Figueira 813e341e39
Use 'prefer left type' if PFx v1 is enabled as well (#1502)
Follow-up to #1489 - using the 'only coerce to left type' on the Table function either if StronglyTypedEnums is enabled (the root cause of the bug it fixed), or if we are using the Power Fx V1 compat rules (since it moved to a "first-type" rule)
2023-05-12 15:04:11 -07:00
Jas Valgotar 2d7a74f6d1
Fixes FromJson issue with single column table (#1501) 2023-05-11 19:52:40 -04:00
Carlos Figueira 33bde0b583
Only allows coercion to first argument type on tables (#1489)
We have update the Table function (and the `[...]` syntax) to favor the first type. But the current union logic would allow coercion from the first value into subsequent ones, which would cause issues like in the example `[ErrorKind.Div0, 12]` - the resulting type is `![Value:ErrorKindOptionSet], but the IR would try to coerce the data to number (since numeric option set can be coerced to number, but not the other way around). This change forces, within those contexts, that the union should only happen to the left type, not the right one.

Fixes #1477
2023-05-11 15:43:03 -07:00
Anderson Silva be6fbb6ba6
Better warning message for delegation (#1496)
To support DV issue
https://github.com/microsoft/Power-Fx-Dataverse/issues/183.
2023-05-11 17:19:39 -05:00
Akshar V Patel 6feb26b880
Fixing small null ref errors that i found from the changes in Pr #1420 (#1494)
Forgot to handle few cases where null ref could be thrown in this pr
https://github.com/microsoft/Power-Fx/pull/1420. This pr handles those
null ref scenarios. It is a small pr.
2023-05-09 19:17:23 -04:00
Luc Genetier 00685893e0
Implement IsMatch, Match, MatchAll functions (#1442)
Co-authored-by: Carlos Figueira <carlosff@microsoft.com>
Co-authored-by: Carlos Figueira <carlosfigueirafilho@hotmail.com>
Co-authored-by: Mike Stall <mikestall@hotmail.com>
2023-05-08 23:17:51 -07:00
Anderson Silva 05c23afba0
PowerFxV1 as default (#1476)
Issue https://github.com/microsoft/Power-Fx/issues/1472.
2023-05-08 15:43:05 -05:00
Anderson Silva 8aad45cfb4
ODataVisitor to support other UnaryOpKind kinds (#1492)
Issue https://github.com/microsoft/Power-Fx/issues/1491.
2023-05-08 15:23:12 -05:00
Vamsi Modem 214a82455b
UDF Cleanup (#1487) 2023-05-08 10:27:38 -07:00
Akshar V Patel bd0dda9a65
Extending Language Server to support Semantic Tokenization and Migrating Tokenization Logic from Canvas App Source to PowerFx (#1420)
This pr extends language server to handle two kinds of semantic tokens
request (Full and Range Semantic Tokens). This pr also migrates the core
tokenization logic from Canvas App backend to the PowerFx. In doing so,
i had to update an interface which might break PowerFx.DataVerse but the
Canvas App backend would not have any breaking changes after these
changes are merged in and consumed there. Due to little to no experience
in working with PowerFx, i may have done few things against the
established norms around PowerFx so i'd greatly appreciate any feedback
and more than happy to reconsider things. The semantic tokenization
implemented in this PR follows the LSP specification around semantic
tokenization and encoding as described here
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens.
Language Server also supports multi line tokens such as multi line
comments, multi line strings.

Some results from the end to end prototype created based on these
changes in PowerFx

Before:
<img width="116" alt="image"
src="https://user-images.githubusercontent.com/25670945/234274876-c32d5dbd-772c-44b4-b122-c8fd9c128049.png">

After  (Ignore the Colors which would be refined later):
<img width="110" alt="image"
src="https://user-images.githubusercontent.com/25670945/234274988-013c5428-fbf7-4670-8fac-f1e083b2af10.png">

Before:
<img width="199" alt="image"
src="https://user-images.githubusercontent.com/25670945/234275226-f77ba805-e8fc-4fb6-a2b8-a822afe1ad9f.png">

After  (Ignore the Colors which would be refined later):
<img width="169" alt="image"
src="https://user-images.githubusercontent.com/25670945/234275335-f7912481-2ca4-4b54-974e-d1aa48be5505.png">

Before:
<img width="135" alt="image"
src="https://user-images.githubusercontent.com/25670945/234275433-c16e8dbd-ca11-4a7f-b00f-ea6059269c87.png">

After  (Ignore the Colors which would be refined later):
<img width="132" alt="image"
src="https://user-images.githubusercontent.com/25670945/234275537-1d12ada1-2ea0-47fa-bebc-212f8b69d88f.png">

---------

Co-authored-by: jas-valgotar <jasvalgotar@microsoft.com>
2023-05-08 13:09:53 -04:00
Hoa Nguyen f007a2fa4b
Return Blank for blank input of Text (#1478)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1458

---------

Co-authored-by: Carlos Figueira <carlosff@microsoft.com>
2023-05-06 09:21:16 -07:00
Carlos Figueira 2c2a80a79e
Add default messages for errors (#1483)
Error values should have a default message if one is not provided. See #1482 for an example.
2023-05-05 16:06:40 -07:00
Carlos Figueira be2cc2a6c7
Allow coercion from numeric option set to decimal (#1486)
We have an unary coercion from numeric option set to decimal, but this isn't allowed today. This change fixes it.
2023-05-05 15:18:28 -07:00
Hoa Nguyen c3329640b2
Add decimal/number return type to checkresult (#1453)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1356
2023-05-05 11:05:26 -07:00
Hoa Nguyen ec078fc29c
Decimal RandBetween return a full 28 digits (#1460)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1402
2023-05-05 10:44:25 -07:00
Jas Valgotar 619706b687
Enables overload signatures for Custom Function. (#1395)
Fixes #1304 
Fixes #1226
2023-05-05 11:29:05 -04:00
toshio-msft 1672871c1f
[[Power-Fx]] Localization hand-back [CTAS - RunID=20230504-205400-pyq2pj4407] (#1485)
Translation handback check-in (PR Created by automation).
2023-05-05 07:59:32 -07:00
Hoa Nguyen 8aca4c1d2a
Handle empty expression for return type (#1475)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1425
2023-05-04 11:31:52 -07:00
Hoa Nguyen d539205fe0
Use epoch for DateTimeValue and DateValue without date (#1481)
Fix issue: https://github.com/microsoft/Power-Fx/issues/1441
2023-05-04 10:11:20 -07:00
Luc Genetier 18e97ca764
Add management of x-ms-require-user-confirmation, x-ms-explicit-input… (#1480)
… and x-ms-enum-display-name connector extensions
2023-05-04 18:14:46 +02:00
Luc Genetier 3762ebf9d7
Add management of x-ms-require-user-confirmation, x-ms-explicit-input… (#1480)
… and x-ms-enum-display-name connector extensions
2023-05-04 18:14:05 +02:00
Jas Valgotar f2e7b40f50
Adds null handling in Power operator. (^) (#1462)
-Fixes #1297
2023-05-03 19:59:24 -04:00
Vamsi Modem 639e74aa6e
Added argument index to UDF params (#1439)
Added arg index to udf params, we need this during code gen on the host.
Created a new info type for UDF parameters.
Modified UserDefinitionsNameResolver to not use record type, since I
didn't find a way to get the index of a pram.
2023-05-03 12:59:04 -07:00
Anderson Silva e6804aa013
Error(Table) to support coercion (#1467)
Issue https://github.com/microsoft/Power-Fx/issues/1250.
2023-05-03 14:41:51 -05:00
Shpakh-MSFT 61baa783e4
Fix to add delegation warning for named formula if it's part of dotted name node and async predicate support is off (#1469)
This change brings the named formula to the same consistency for
delegation warnings and marks the expression as non-delegable if it's a
part of non-delegable expression.
2023-05-02 12:17:48 -07:00
Kartik K R aebf349080
Updating Filter delegation logic for views using variables. (#1471)
Co-authored-by: Kartik K R <karr@microsoft.com>
2023-05-02 09:48:24 -07:00
Luc Genetier 2e7d19d93e
Add CodeOwners files (#1468) 2023-05-02 14:39:04 +02:00