Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addformat() experimental function#779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SteveL-MSFT merged 5 commits intoPowerShell:mainfromSteveL-MSFT:format-function
May 6, 2025

Conversation

SteveL-MSFT
Copy link
Member

PR Summary

Add experimentalformat() function. Use of this function will emit a warning as it doesn't currently support all the same format options as dotnet which is what ARM is based on.

Also updated versions of some crates.

PR Context

Fix#767

Gijsreyn reacted with heart emoji
@Gijsreyn
Copy link
Contributor

Just a question aside Steve, if this is experimental, should users toggle it on or off in thedsc.settings.json?

@SteveL-MSFT
Copy link
MemberAuthor

Just a question aside Steve, if this is experimental, should users toggle it on or off in thedsc.settings.json?

Good question. I don't think we need that since it's something you have to explicitly use.

Gijsreyn and andyleejordan reacted with thumbs up emoji

Copy link
Member

@andyleejordanandyleejordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

First basic round of testing is successful:

Logs:

2025-05-05T22:58:42.459120Z DEBUG dsc_lib::configure: 773: Invoke property expressions2025-05-05T22:58:42.460693Z DEBUG dsc_lib::parser: 48: Parsing statement: [format('{0}\Themes\Personalize', variables('keyPathPrefix'))]2025-05-05T22:58:42.470561Z DEBUG dsc_lib::parser: 84: Parsing expression2025-05-05T22:58:42.471435Z DEBUG dsc_lib::parser::expressions: 43: Parsing function '{Node function (0, 1) - (0, 61)}'2025-05-05T22:58:42.472362Z DEBUG dsc_lib::parser::expressions: 43: Parsing function '{Node function (0, 34) - (0, 60)}'2025-05-05T22:58:42.473285Z DEBUG dsc_lib::parser::functions: 57: Function name: 'variables'2025-05-05T22:58:42.474161Z DEBUG dsc_lib::parser::functions: 57: Function name: 'format'2025-05-05T22:58:42.475071Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("{0}\\Themes\\Personalize")'2025-05-05T22:58:42.477017Z DEBUG dsc_lib::parser::functions: 75: Argument is an expression2025-05-05T22:58:42.478129Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("keyPathPrefix")'2025-05-05T22:58:42.479103Z DEBUG dsc_lib::functions::variables: 28: variables function2025-05-05T22:58:42.480001Z  WARN dsc_lib::functions::format: 99: `format()` function is experimental2

Bicep:

varkeyPathPrefix ='HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion'resourcesystemUsesLightTheme'Microsoft.Windows/Registry@2025-04-07' = {name:'SystemUsesLightTheme'properties: {keyPath:'${keyPathPrefix}\\Themes\\Personalize'valueName:'SystemUsesLightTheme'valueData: {DWord:valueData        }    }}

ARM:

"variables": {"valueData":"[if(equals(parameters('colorMode'), 'light'), 1, 0)]","keyPathPrefix":"HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion"  },"resources": [    {"type":"Microsoft.Windows/Registry","apiVersion":"2025-04-07","name":"SystemUsesLightTheme","properties": {"keyPath":"[format('{0}\\Themes\\Personalize', variables('keyPathPrefix'))]","valueName":"SystemUsesLightTheme","valueData": {"DWord":"[variables('valueData')]"        }      }    },

And this worked such that I didn't have to use Bicep'sconcat() any more (which throws a warning to use string interpolation). Would be happy to test some more, at least before release, but I liked the ample unit tests. Thing we'll have to worry about in general is bug-for-bug compatibility between Bicep (implemented in C#) and DSC (in Rust).

linked-hash-map = "0.5"
num-traits = "0.2"
regex = "1.11"
rt-format = "0.3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This package seems reasonable enough, but I'll point out that it's last release was 3 years ago, and it has this note:

Is stable API a must-have? If so, you might consider the alternatives. This crate is still not at version 1.0, which means that the API is still not completely stable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just something to consider,dyn-fmt appears more recently updated than the other two contenders (rt-format as above and the similarly named dynfmt last published 4 years ago).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(I'm not saying it's better, I'm just looking into it.)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I was looking at the variety of options listed in the rt-format repository. Maybe will switch to dyn-fmt in the future. Since this is experimental, we can leave it as-is for now.

andyleejordan reacted with thumbs up emoji
@SteveL-MSFTSteveL-MSFT merged commita83c425 intoPowerShell:mainMay 6, 2025
4 checks passed
@SteveL-MSFTSteveL-MSFT deleted the format-function branchMay 6, 2025 02:17
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@andyleejordanandyleejordanandyleejordan approved these changes

@tgauthtgauthAwaiting requested review from tgauth

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bicep compat functions
3 participants
@SteveL-MSFT@Gijsreyn@andyleejordan

[8]ページ先頭

©2009-2025 Movatter.jp