- Notifications
You must be signed in to change notification settings - Fork45
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Just a question aside Steve, if this is experimental, should users toggle it on or off in the |
Good question. I don't think we need that since it's something you have to explicitly use. |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
a83c425
intoPowerShell:mainUh oh!
There was an error while loading.Please reload this page.
PR Summary
Add experimental
format()
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