microsoft / microsoft/Power-Fx
FileInfo functions
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 358
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 3
Description
Add 2 new functions that work with files (https://github.com/microsoft/Power-Fx/blob/main/src/libraries/Microsoft.PowerFx.Core/Public/Values/BlobValue.cs)
These don't need to be included by default yet. But can be pulled in via:
Config.EnableFileFunctions()
FileInfo
New function, called "FileInfo", which takes a blob and returns a record of file information:
FileInfo(Blob): FileInfo
Where:
FileInfo = Type(
{
Name: Text,
Size: Decimal, // 53 bits is large enough
MIMEType: Text,
URL: Text
});
Blob is a File type in Power Fx (Dtype.Blob)
Note: Power Fx only has Floating point /Decimal numberic types (no integer types).
Text(Blob) // should return appres URL, not impl in C# interpreter yet.
// semantically same as:
FileInfo(Blob).URL
PatchFileInfo
PatchFileInfo( File: Blob, UpdatedInfo: FileInfo ): Blob
For changing the file name, it would be PatchFileInfo( MyFile, { Name: "My new file name" } ).
Won't allow updating Size/Url. Runtime error.
So this would be an error:
PatchFileInfo(Blob, FileInfo(blob))
Open Issues:
- Size is Number of Decimal?
- Final name of PatchFileInfo
Implementation plan
- In C# side, we define new virtuals on BlobValue for GetFileInfo, SetFileInfo.
- Power Fx side defines the two functions above
- Their impl will call the new virtuals on BlobValue
Hosts are already derive from BlobValue, and so you would just implement those virtuals as you see fit.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/libraries/Microsoft.PowerFx.Core/Public/Values/BlobValue.cs and review the proposed GetFileInfo and SetFileInfo virtuals. Trace how Config.EnableFileFunctions() exposes functions and how BlobValue hosts are implemented. Done means FileInfo and PatchFileInfo are defined with the specified Blob and record behavior, including runtime errors for unsupported Size and URL updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100