Skip to content

Conversation

@BCSharp
Copy link
Contributor

@BCSharp BCSharp commented Dec 15, 2025

Description

Implement proper handling of format specifers "D" and "B".

Related Issue

Resolves #4788

Motivation and Context

I want to be able to format Major, Minor, Patch into one integer so it can be used as Android versionCode.

Format specifier "D" does the job. Format specifier "B" is added, because, why not, it comes for free.

How Has This Been Tested?

Tests have been added to this PR by expanding existing test group GitVersion.Tests.Formatting.NumericFormatterTests.TryFormat_ValidFormats_ReturnsExpectedResult.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation. — Format "D" is already documented, albeit for GitVersion v5.x. Format "B" is undocumented (documented only on Microsoft page)
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed. — some existing unrelated test fail

Copilot AI review requested due to automatic review settings December 15, 2025 04:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for Binary (B) and Decimal (D) format specifiers for integer formatting in GitVersion's custom formatting system. The change allows version components to be formatted as binary or zero-padded decimal numbers, complementing the existing Hexadecimal (X) support.

Key changes:

  • Extended NumericFormatter to handle "B" and "D" format specifiers alongside the existing "X" format
  • Added test cases to verify formatting behavior with precision specifiers (b8, d8, x8)
  • Updated documentation to include the new Binary format specifier

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/GitVersion.Core/Formatting/NumericFormatter.cs Extended integer formatting logic to handle B (binary), D (decimal), and X (hexadecimal) format specifiers with a unified code path
src/GitVersion.Core.Tests/Formatting/NumericFormatterTests.cs Added test cases for binary, decimal, and hexadecimal formatting with precision specifiers; also removed BOM character from file
docs/input/docs/reference/custom-formatting.md Added documentation for the B (binary) format specifier

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arturcic
Copy link
Member

@BCSharp please rebase your branch onto main and then we can get it merged

@arturcic arturcic added this to the 6.x milestone Dec 15, 2025
@BCSharp BCSharp force-pushed the pr/decimal_formatting branch from a5010f9 to 616c552 Compare December 15, 2025 21:26
@sonarqubecloud
Copy link

Copy link
Member

@arturcic arturcic left a comment

Choose a reason for hiding this comment

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

LGTM!

@arturcic
Copy link
Member

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2025

refresh

✅ Pull request refreshed

@arturcic arturcic merged commit 7323e92 into GitTools:main Dec 15, 2025
122 checks passed
@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2025

Thank you @BCSharp for your contribution!

@BCSharp BCSharp deleted the pr/decimal_formatting branch December 15, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE]: Formatting does not support format specifier "D"

2 participants