BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Auto-escape MSBuild special characters in MsBuildArgument
Summary
This PR adds automatic escaping of MSBuild-reserved characters in the MsBuildArgument class (e.g., ;, %, $, @, etc.), so users no longer need to manually encode these characters when passing MSBuild parameters.
Why
Previously, developers had to encode characters like semicolons manually (; → %3B). This PR improves usability and correctness when passing multiple values to MSBuild properties such as DefineConstants.
Changes
- Updated
MsBuildArgumentconstructor to auto-escape special characters - Added a
[Theory]-based test (EscapesSpecialCharactersCorrectly) to cover:- Semicolons
- Percent
- Dollar sign
- At-symbol
- Parentheses
- Asterisk
- Normal input (no escape)
Example
new MsBuildArgument("/p:DefineConstants=DEBUG;TRACE")
// becomes:
"/p:DefineConstants=DEBUG%3BTRACE"