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

1556 Коммитов

Автор SHA1 Сообщение Дата
McCall Saltzman 6dcbde8f79
Expose non-source flag on IdentToken to internals (#2199)
For the Record support in PA Client for merge attributes, we're
introducing a function that is only callable from generated expressions,
not user code. This adds a flag to tell if an identifier is from source
directly, or from something we generated.
2024-02-08 22:13:04 +00:00
Luc Genetier 221923ee76
Allow LazyRecord/LazyTable in JSON function (#2190) 2024-02-08 15:18:45 +01:00
Anderson Silva 717683274e
Exclude a list of functions (#2193)
Issue https://github.com/microsoft/Power-Fx/issues/1578.
This was already available but now moving to `RecalcEngine` and no more
need to extend `Engine` class.
2024-02-07 21:19:02 +00:00
Anderson Silva 8b788da9db
Empty script when TextFirst is active (#2192)
Issue https://github.com/microsoft/Power-Fx/issues/2178.
2024-02-07 20:12:34 +00:00
Luc Genetier c7aa8063fb
Add BlobValue and BlobType (#2184) 2024-02-07 15:46:37 +00:00
toshio-msft 6f529ffceb
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240206-235243-qza721m62] (#2191)
Translation handback check-in (PR Created by automation).
2024-02-06 19:43:55 -06:00
Carlos Figueira 73f509a00b
Don't create new DType instances for primitive FormulaType classes (#2188)
Small perf improvement: we don't need to create new DType instances for primitive types.
2024-02-05 09:39:44 -08:00
McCall Saltzman 913a85e4bc
Add [Partial] combination attribute support for Named Formulas (#2181)
This is an early prototype of support for a [Partial] attribute that
enables combining named formulas.
This is done via name-mangling in the parser, renaming each NF to
foo_Guid_0, foo_guid_1, ... and then creating a new hidden nf
Foo = Op(foo_guid0, foo_guid1, ...). This allows us to update the
formulas independently in authoring, and process them without real
changes to NF handling on the PA side.

![Animation
1](https://github.com/microsoft/Power-Fx/assets/69215460/12923e11-01b0-4e71-80f5-b053dfb50fe4)
2024-02-02 13:06:00 -08:00
Anderson Silva 50ad8e949e
Intellisense tokens made public (#2180)
Complement for https://github.com/microsoft/Power-Fx/issues/2161.
2024-02-01 16:30:21 -08:00
toshio-msft 5fed7ae730
[[Power-Fx]] Localization hand-back [CTAS - RunID=20240130-181356-qt82as5705] (#2177)
Translation handback check-in (PR Created by automation).
2024-01-30 11:30:23 -08:00
Anderson Silva 67c8397552
New IsTextFirst flag to TokenTextSpan (#2176)
Complementing issue https://github.com/microsoft/Power-Fx/issues/2161
fixes.
2024-01-30 18:39:59 +00:00
Carlos Figueira 9ca25f6b0c
Fix handling of GMT time zone (#2175)
There were some parts of the code that were mistakenly treating the GMT (i.e., London) time zone as UTC. Those are the same for part of the year, but not for all of it, which was causing some issues with parsing and adding date values. This change addresses it.
2024-01-30 17:38:22 +00:00
Anderson Silva 9b9e04e7c5
New TextFirst flag for syntax highlight (#2172)
Issue https://github.com/microsoft/Power-Fx/issues/2161
2024-01-30 08:52:13 -06:00
Carlos Figueira f8c72c5174
New IRVisitor test to show how we could escape HTML (#2173)
Trying to implement a scenario using IR rewriting to handle HTML escaping automatically:

- Literal strings are not escaped
- Variables are escaped (can potentially have unsafe data)
- Data from tables are escaped (can potentially have unsafe data)
- IR tree is traversed and whenever there are unsafe string nodes being concatenated, those nodes are escaped.
2024-01-29 17:21:04 -08:00
Luc Genetier b6c7bb3a62
[Connectors] Add warnings (#2168)
When swagger file type "binary" is used, we are now generating a warning
that we might return incorrect results as we default to a string
Updated Yaml comparer accordingly
2024-01-26 07:41:40 -08:00
Anderson Silva 2dc8eeb2a5
Dont coerce Boolean to BooleanOptionSet when mutating. (#2169)
Issue https://github.com/microsoft/Power-Fx-Dataverse/issues/423.
Ideally, PFx should support this. For the time being, let's return an
error at compilation time.
2024-01-25 12:34:51 -06:00
Luc Genetier 60baad4363
Connector Yaml comparer (#2164)
Add Yaml comparer and load results in SQL
Update OpenApiReaderSettings in swagger readers to exclude
KeyMustBeRegularExpression rule
2024-01-24 18:29:50 +01:00
Adithya Selvaprithiviraj 4123e9b026
Add UniChar function (#2133)
Adds UniChar funcion to Power Fx.

**Examples** 
```
>> UniChar(Hex2Dec("1F600"))
"😀"

>> UniChar(119137)
"𝅘𝅥𝅯"
```

**User scenarios** 
* Text based custom icons within the app.
* Display multilingual texts.

**References**
[UNICHAR function - Microsoft
Support](https://support.microsoft.com/en-us/office/unichar-function-ffeb64f5-f131-44c6-b332-5cd72f0659b8)
[Char.ConvertFromUtf32(Int32) Method (System) | Microsoft
Learn](https://learn.microsoft.com/en-us/dotnet/api/system.char.convertfromutf32?view=net-8.0)
[Unicode - Surrogate pair (UTF-16)
(datacadamia.com)](https://datacadamia.com/data/type/text/surrogate)
2024-01-23 15:34:47 -08:00
McCall Saltzman ba10710081
Allow access to design properties via Gallery.Selected (#2162)
This removes a pointless restriction on property access via
Gallery.Selected.
These properties were already accessible directly on children of the
gallery, and this restriction doesn't have any runtime justification for
existing. It also blocks deprecation of primary output properties (Icon
has a design primary output prop, others might as well)
2024-01-23 14:40:11 -08:00
Carlos Figueira 8ff5972ebc
Block void values in the pattern / matches arguments in the Switch function (#2160)
With the completion of #2096 we started accepting void arguments in the pattern (first argument) and matches (even-numbered arguments) for the Switch function, so something like this would not have any compile-time errors: `Switch(If(1<0, 1, {}), 1, "ok", "not ok")`. This is an invalid expression - the first argument (a void value) cannot be compared with anything else. This fixes that, and adds some additional tests to prevent this from happening again.
2024-01-23 08:51:29 -06:00
Andrew Petrochuk 87c1ca7c4c
Added Count to ErrorContainer (#2157)
Issue: During tight loops we sometimes need only error count and at this
time we can only call GetErrors() which returns IEnumerable and the
iterate though each error using Count() extension. It would improve
performance if we can have native Count property

Co-authored-by: Andrew Petrochuk (from Dev Box) <anpetroc@microsoft.com>
2024-01-22 07:26:38 -08:00
Anderson Silva 95cd7bf5dc
Get function category names (#2154)
Addressing part 1 of https://github.com/microsoft/Power-Fx/issues/2151.
> ...extend the function info, with the localized function category
names.
2024-01-18 19:34:44 +00:00
Greg Lindhorst f7c432f1f3
Update Void accept behavior and take advantage in Repl (#2096)
Several Power Fx functions have no real return value. To date, Canvas
apps have returned Boolean values that aren't seen and likely this
behavior is not well known. With the Repl, these values are being
printed as part of the stream and it can be confusing. to see `Set( x, 3
)` and then `true`. Similarly, it is seems odd in a strongly typed
language to return a value that really has no meaning (the `true` from
Set) which could be a coding error, the kind of thing that strong typing
should catch.

Changes to be made:
1. Void will accept all types, including Void. In Power Apps, behavior
properties would be of type Void, and they work with any formula,
dropping the computed value.
2. Void will not be accepted by any other types (except Void). Trying to
use the output from Set will result in an error.
3. The following functions will return Void: Set, Clear, Remove, Notify
(Repl), Help (Repl), Exit (Repl). Future functions that have no return
value will return Void.

There is a tiny loss of functionality with this change. The result from
Remove can no longer be put in a variable. Which normally doesn't matter
as Remove returns no value. But, if Remove encounters an error, that
error can no longer be put in a variable. The error will still be
reported and can be caught and processed with IfError and App.OnError in
Power Apps. With an IfError, the error record can be extracted and that
can be put in a variable. The team discussed this and we do not believe
this is a common pattern, if used at all.

With this change, it is also not possible to use Boolean logic to short
circuit the use of these functions. For example, it used to be possible
to `Back() && Clear( table )` and the Clear would only be executed if
the Back() returned true. We don't think the intent here is very clear,
especially for a non-pro developer, and we'd prefer it be written as
`If( Back(), Clear( table )`. Usage on Canvas apps is very low for this
pattern.
2024-01-18 10:34:10 -08:00
Luc Genetier 8ea0700e9e
Log OpenApi errors in Internal testing (#2152) 2024-01-17 21:35:14 +00:00
Akshar 105fcff7d9
Refactor NL2Fx Handling in Language Server to support more dynamic NL Handler Creation based on IPowerFxScope (#2134)
This pr performs necessary wiring to enable creating NL Handler for
Nl2Fx and FX2NL based on the current IPowerFxScope language server is
operating on. This is necessary to support Nl2FX scenarios in Power Apps
and the current approach which uses Nl2FxImplementation property is not
a thread safe. With the plan to perform Nl2Fx operations in parallel and
given that we only create 1 instance of Language Server SDK, two
concurrent Nl2FX tasks can overwrite Nl2FxImplementation unexpectedly.
The new approach in this pr scopes the creation of handler to every
Nl2FX task. It allows the creation of handler based on the scope itself
which has "host" specific entities which are required to create a more
meaningful NlHandler. For Power Apps, "host" contains document, control
and property which are critical to context building for Nl2Fx model
inside NL Handler.
2024-01-17 16:16:48 -05:00
cwduncan 31ba524f64
Granting internal access for DocServer Common Tests (#2150)
Enabling DocumentServer.Common.Tests to access internal classes within
Microsoft.PowerFx.Core to enable supporting testing scenarios in
docserver
2024-01-17 12:08:43 -08:00
Akshar f75a924487
Fix Formula Bar now showing correct active parameter in Signature Help Regression (#2147)
A regression was caused during AI Disclaimer changes that resulted in
formula bar always showing first parameter in signature help as active
parameter even when a user is not typing a first parameter and is on
let's say a fourth parameter.

This happened due to the addition of "ActiveParameter" property in
SignatureInformation model. There are two "active parameter" properties
as shown below

![image](https://github.com/microsoft/Power-Fx/assets/25670945/1a9cfc68-6a95-4d16-95b4-c647ed29e15c)

On the left is active parameter for specific signature information which
we never had but was introduced with Ai disclaimer change. On the right
is a global one that we used and applied to all signatures.

Active parameter for specific signature info takes precedence over
global one so in this case since we introduced this property for each
signature info but never set it to anything, it was always being set to
"0" causing formula bar to set first parameter as an active parameter

This pr removes that active parameter property for each specific
signature info as we never had it and we always used global one

Current Regression: 

![image](https://github.com/microsoft/Power-Fx/assets/25670945/6c155495-106c-4ad2-961a-65ed993f02d8)

After this Pr:

![image](https://github.com/microsoft/Power-Fx/assets/25670945/bce3f25c-de7c-41d6-8c24-2c609277ef9e)
2024-01-17 09:22:03 -05:00
Carlos Figueira d2e61036b5
New functions to retrieve column names and values for untyped objects (#2100)
We currently have support for untyped objects, but to access their fields they need to be known at build time. This makes the support really untyped - we can access the column names of untyped records and also retrieve a column value given its name as a string.
2024-01-17 03:57:28 +00:00
Luc Genetier 8aa14b8140
Fix internal test (#2148) 2024-01-16 18:47:12 +00:00
Luc Genetier cdcef30472
Fix dynamic connector extensions & update internal testing (#2146)
Fix dynamic connector extensions management in making 'parameters'
optional despite the spec which says it's required
Update internal tests
Add Guardian files
Update .gitignore file
Fix BuildLocalPackages.cmd script
2024-01-16 10:03:56 -08:00
Mike Stall 382540a26b
Add helpers for getting function parameter names. (#2144)
Add public helpers for getting function intellisense and parameter
names.
These exist on TexlFunction, but is not exposed.
2024-01-16 08:45:30 -08:00
Mike Stall c4ed8db676
Cache Engine.AssemblyVersion call. (#2140) 2024-01-15 17:45:44 +00:00
Vamsi Modem 31b4801b34
Restrict usage of None, Decimal, DateTimeTZInd in UDFs (#2141) 2024-01-12 11:12:08 -08:00
Luc Genetier 015ef0577d
Avoid throwing exceptions when we could successfully load a swagger file and have working functions (#2143)
- Avoid throwing exceptions when we could successfully load a swagger
file and have working functions
Function where we identify issues or using unsupported features will be
marked as unsupported
- [Breaking] Separation of IsDeprecated & IsSupported flags
Before, IsDeprecated was implying IsSupported = false, this is no more
the case
  By default, deprecated functions will be marked as supported.
- ConnectorFunction.NotSupportedReason now shows the complete list of
identified failures whereever they are (parameters, return type,
dynamic-* extensions...)
- [Breaking] Calling ConnectorFunction.InvokeAsync will now fail on
unsupported functions
- Connector logger now reports all errors occurring during swagger
processing
- When an HTTP exception occurs during function invocation, add
reasonPhrase in error message for better clarity
- In FormulaValue serializer or Http function invoker, change exceptions
from NotImplementedException, ArgumentException or
InvalidOperationException to PowerFxConnectorException
- Determine function parameter default values at swagger load time, not
runtime: better error handling, faster execution
- Few code improvements reported by static code analyzers

---------

Co-authored-by: Anderson Silva <joyle@outlook.com>
2024-01-12 19:25:04 +01:00
Luc Genetier d655061890
[Connectors] Add TexlFunctionExporter project, tests and fixes (#2132)
- New Microsoft.PowerFx.TexlFunctionExporter project/nuget with
SwaggerIdentification & YamlExporter features
- Fix Intellisense issue for connector functions having optional
parameters (Intellisense wasn't reporting required parameters alongside
w/ optional params)
- Extend api-version workaround to a couple more headers (linked to
https://github.com/microsoft/Power-Fx/pull/1987 -
https://github.com/microsoft/Power-Fx/issues/1982)
Fixes 'Azure App Service', 'Azure Automation', 'Azure Container
Instance', 'Azure Data Factory', 'Azure Event Grid', 'Azure Resource
Manager', 'Azure VM' and 'GitHub Utils' connectors
- Fix an issue when a connector function contains a return type 'file'
(as described in swagger file) which was preventing the generation of
the TexlFunction
- Add ability to return unknown record fields (not described in swagger)
as UntypedObject (ReturnUnknownRecordFieldsAsUntypedObjects internal
property on ConnectorSettings, only with swagger compatibility)
- Add GenerateYamlFiles test
2024-01-11 07:50:10 -08:00
pacrozie 52e0939913
Adding a new isReactHooksSingleton argument to transport type attribute constructor (#2123)
Adding a new argument to the transport type attribute to support React
Hooks for the Power Apps Canvas client.
2024-01-10 23:46:31 +00:00
Jas Valgotar 8257c2da23
Embeds assembly Version in LSP Payload for debugging. (#2139) 2024-01-10 23:28:59 +00:00
Anderson Silva cb7667fdcd
Don't copy derived RecordValues to inmemory record values (#2131)
Issue https://github.com/microsoft/Power-Fx/issues/2127.
2024-01-10 21:21:48 +00:00
Luc Genetier c8ebad0756
User agent normalization (#2138)
Add userAgent to PowerPlatformConnectorClient to generate a User Agent
when calling APIM like below
`MyProduct/v1.2 PowerFx/1.3.0-build.20240110-1001`

Following RFC9110
2024-01-10 16:29:11 +01:00
Luc Genetier 111c2cd4de
Net analyzers update to version 8.0.0 (#2137)
Update Microsoft.CodeAnalysis.NetAnalyzers and AnalysisLevel to version
8.0.0
Fix couple of issues newly identified
2024-01-10 16:11:25 +01:00
Anderson Silva d7535f3f00
RenameDriver with TextFirst active (#2135)
Issue https://github.com/microsoft/Power-Fx/issues/2129.
2024-01-09 22:17:07 -08:00
Carlos Figueira e8fa643c11
Increase local NuGet version to a large number (#2130)
As we increase our official NuGet version, the version from a local build should have a higher version number. This increases it to a very large number, which should be enough until our major version update.
2024-01-04 17:13:37 +00:00
Mike Stall 84611839cf
Followup to PR #2117 - Fixes in MarkupContext class (#2128)
Fixes in MarkupContext class.
2024-01-02 11:05:04 -08:00
Luc Genetier 566e2199ec
Office 365 connector extensive testing and fixes (#2125)
> [!CAUTION]
> BREAKING CHANGE
> - Internal functions are no more visible externally 
Functions having _x-ms-visibility_ extension with "internal" value are
not visible in PowerApps
  We were making all these functions visible and this is now fixed
**⚠️ Some customers had access to functions they won't find them
anymore**
Tabular connectors are heavily impacted here - those connectors
shouldn't be exposed as they aren't presented like PowerApps as a table
It is possible to expose internal functions via
_ConnectorSettings.IncludeInternalFunctions_ (default value false) but
this should only be reserved for tests and never set in production
  FYI, these internal functions are heavily used in dynamic Intellisense
- Serialization of "date-time" and "date-no-tz" swagger types was
incorrect
- "date-time" fields are converted properly (wasn't the case) & sent as
UTC on the wire (`yyyy-MM-ddTHH:mm:ss.fffZ` format), precision has been
fixed (trucated to 1 ms)
    This is what PowerApps is doing
- "date-no-tz" fields are sent on the wire with
`yyyy-MM-ddTHH:mm:ss.fff` format (no Z, truncated to 1ms)
PowerApps has a bug under investigation (PA swallows seconds, ms and us,
potentially leading to incorrect results)
- Deserialization of "date-time" fields was having some timezone
conversion issues
  This is fixed
- Connector parameters are case-sensitive and we were managing them as
case-insensitive
  This is fixed
- Some parameters with identical names (which are renamed with _1, _2...
like in PA) where improperly serialized in HTTP payload
  This is fixed
- Connector parameters with array parameters in circular references
where improperly identified as strings (instead of array)
  This is fixed
- O365 Outlook _GetSensitivityLabels_ hidden function doesn't work due
to a very probable bug in its swagger definition - this is under
investigation
This impacts _SendEmail_ and _SendEmailV2_ functions where dynamic
intellisense will not work properly for _Sensitivity_ param (no
suggestion returned)
- Connector MediaKind is now identified in swagger files
(_x-ms-media-kind_ extension)
  Unused for now, but this is to properly support image params later
2023-12-27 20:50:02 +01:00
Mike Stall 3d128d60a4
Add AI disclaimer (#2117)
Fix #1202

The disclaimer is markdown (including a help link) in the resources.

1. TexlFunction gets a virtual flag noting whether the function needs a
disclaimer. Default impl is based on a whitelist of AI functions, but we
can override this flag next.
2. LSP will get flag and append , and send markdown to formula bar. 

This productizes the POC from #2099 .
2023-12-20 15:10:18 -05:00
Jas Valgotar 17da65ca2c
Fixes IR printing DV option set (#2116) 2023-12-19 19:38:44 +00:00
Luc Genetier 39456d6a38
O365 connector validation & code updates (#2112)
- Full validation of O365 Groups connector
- Full validation of O365 Users connector
- Fix in connector code around internal parameters (discovered a
variation w/ PA Client which is confirmed as a bug on their end)
- add logic in HttpFunctionInvoker to trace requests (disabled by
default)
- add support in test code for providing JPG response files as byte
array
2023-12-19 09:16:08 -08:00
Jas Valgotar 0aa6860004
Fixes Accepts() for OptionSet (#2110)
-Fixes Accepts() for option set.
Earlier OptionSet did not have equality defined, so accepts was using
reference equality which can cause issues, as an example in caching.
2023-12-18 11:52:25 -05:00
Anderson Silva 2dfc114afe
WeekNum function (#2109)
Issue https://github.com/microsoft/Power-Fx/issues/2101.
2023-12-18 10:14:37 -06:00
Mike Stall f8ed72b5f6
Add Description, HelpIink to FunctionInfo (#2108)
Partial for #2004. 

Not doing categories yet because we need to discuss how to support that
longer term. Is there a curated set? Do we expose the category enum?
2023-12-14 16:03:45 -08:00