.NET string formatting in bicep is not supported (only rust style is)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 523
- Forks
- 75
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 24
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
As a user coming from the Bicep world, I would expect the following .NET notation to work (but it doesn't):
output: format('Hex formats: lowercase {0:x2}, uppercase {1:X2}, decimal {2:N0}', hexNumber, hexNumber, hexNumber)
Instead, we have to use:
output: format('Hex formats: lowercase {0:x}, uppercase {1:X}, decimal {2}', hexNumber, hexNumber, hexNumber)
For a full example, see:
targetScope = 'desiredStateConfiguration'
// Parameters for customizing the configuration
@description('Hexadecimal number for precision example')
param hexNumber int = 255
// Echo resource demonstrating precision with .NET-style formatting
resource precisionEcho 'Microsoft.DSC.Debug/Echo@2025-08-27' = {
name: 'precisionExample'
properties: {
output: format('Hex formats: lowercase {0:x2}, uppercase {1:X2}, decimal {2:N0}', hexNumber, hexNumber, hexNumber)
}
}
Versus:
targetScope = 'desiredStateConfiguration'
// Parameters for customizing the configuration
@description('Hexadecimal number for precision example')
param hexNumber int = 255
// Echo resource demonstrating precision with hexadecimal formatting
resource precisionEcho 'Microsoft.DSC.Debug/Echo@2025-08-27' = {
name: 'precisionExample'
properties: {
output: format('Hex formats: lowercase {0:x}, uppercase {1:X}, decimal {2}', hexNumber, hexNumber, hexNumber)
}
}
I wasn't sure if this was an issue or a feature request. But if it is possible, I prefer to align with the .NET style or document it somewhere.
Steps to reproduce
N/A.
Expected behavior
N/A.
Actual behavior
N/A.
Error details
Environment data
Name Value
---- -----
PSVersion 7.5.3
PSEdition Core
GitCommitId 7.5.3
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
dsc 3.2.0-preview.5
Visuals
No response
Contributor guide
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 by locating the implementation of the format() function and any existing tests for its Rust-style formatting behavior. Compare those results with the Bicep examples in the issue, then determine whether .NET precision specifiers should be supported or documented. Done means the requested behavior is implemented and tested, or its supported syntax is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100