File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
tests/BenchmarkDotNet.IntegrationTests.ManualRunning Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Text ;
2
4
using JetBrains . Annotations ;
3
5
4
6
namespace BenchmarkDotNet . Jobs
5
7
{
6
- public abstract class Argument : IEquatable < Argument >
8
+ public abstract class Argument : IEquatable < Argument >
7
9
{
8
10
[ PublicAPI ] public string TextRepresentation { get ; }
9
11
@@ -47,6 +49,40 @@ public MonoArgument(string value) : base(value)
47
49
[ PublicAPI ]
48
50
public class MsBuildArgument : Argument
49
51
{
50
- public MsBuildArgument ( string value ) : base ( value ) { }
52
+ private static readonly Dictionary < char , string > MsBuildEscapes = new ( )
53
+ {
54
+ { '%' , "%25" } ,
55
+ { '$' , "%24" } ,
56
+ { '@' , "%40" } ,
57
+ { '\' ' , "%27" } ,
58
+ { '(' , "%28" } ,
59
+ { ')' , "%29" } ,
60
+ { ';' , "%3B" } ,
61
+ { '?' , "%3F" } ,
62
+ { '*' , "%2A" }
63
+ } ;
64
+
65
+ private static string EscapeMsBuildSpecialChars ( string value )
66
+ {
67
+ if ( string . IsNullOrEmpty ( value ) )
68
+ return value ;
69
+ var sb = new StringBuilder ( value . Length ) ;
70
+
71
+ foreach ( char c in value )
72
+ {
73
+ if ( MsBuildEscapes . TryGetValue ( c , out string escaped ) )
74
+ {
75
+ sb . Append ( escaped ) ;
76
+ }
77
+ else
78
+ {
79
+ sb . Append ( c ) ;
80
+ }
81
+ }
82
+
83
+ return sb . ToString ( ) ;
84
+ }
85
+
86
+ public MsBuildArgument ( string value ) : base ( EscapeMsBuildSpecialChars ( value ) ) { }
51
87
}
52
88
}
Original file line number Diff line number Diff line change @@ -43,6 +43,13 @@ public void MultipleProcessesAreBuiltWithCorrectProperties()
43
43
CanExecute < PropertyDefine > ( config ) ;
44
44
}
45
45
46
+ [ Fact ]
47
+ public void EscapesSemicolonInDefineConstants ( )
48
+ {
49
+ var arg = new MsBuildArgument ( "/p:DefineConstants=TEST1;TEST2" ) ;
50
+ Assert . Equal ( "/p:DefineConstants=TEST1%3BTEST2" , arg . ToString ( ) ) ;
51
+ }
52
+
46
53
public class PropertyDefine
47
54
{
48
55
private const bool customPropWasSet =
You can’t perform that action at this time.
0 commit comments