diff options
author | Marek Safar <marek.safar@gmail.com> | 2015-12-14 11:50:30 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2015-12-14 11:50:30 +0300 |
commit | 988706c4d02f7de6bd54b30dbb5bc2c3c6a3819c (patch) | |
tree | a76c09473038f52f4510b0a7e54fbe2a2b8cb026 /mcs/class/Microsoft.Build.Engine | |
parent | d93c3106c02f5bee2d01f2e34729df40da1fc7d6 (diff) | |
parent | 42c0a9444519f730479129f1dd20fac352b35b16 (diff) |
Merge pull request #2334 from iainx/handle-comma
[mcs] Handle commas inside quotes correctly
Diffstat (limited to 'mcs/class/Microsoft.Build.Engine')
-rw-r--r-- | mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs | 8 | ||||
-rw-r--r-- | mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs | 67 |
2 files changed, 50 insertions, 25 deletions
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs index ccfc0fa3a0e..ea302826b87 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs @@ -464,6 +464,7 @@ namespace Microsoft.Build.BuildEngine { List<string> args = new List<string> (); int parens = 0; bool backticks = false; + bool inquotes = false; int start = pos; for (; pos < text.Length; ++pos) { var ch = text [pos]; @@ -476,6 +477,11 @@ namespace Microsoft.Build.BuildEngine { if (backticks) continue; + if (ch == '\"') { + inquotes = !inquotes; + continue; + } + if (ch == '(') { ++parens; continue; @@ -498,7 +504,7 @@ namespace Microsoft.Build.BuildEngine { if (parens != 0) continue; - if (ch == ',') { + if (ch == ',' && !inquotes) { args.Add (text.Substring (start, pos - start)); start = pos + 1; continue; diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs index 48aba112fb9..594c0858777 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs @@ -67,7 +67,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { void Message (object sender, BuildMessageEventArgs args) { } - + void Warning (object sender, BuildWarningEventArgs args) { } @@ -97,7 +97,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Project project; string documentString = "<Project></Project>"; - + engine = new Engine (Consts.BinPath); DateTime time = DateTime.Now; @@ -127,7 +127,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Project project; string documentString = "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"></Project>"; - + engine = new Engine (Consts.BinPath); DateTime time = DateTime.Now; project = engine.CreateNewProject (); @@ -310,7 +310,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> - <Target + <Target Name='Main' Inputs='a;b;c' Outputs='d;e;f' @@ -345,7 +345,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Engine engine; Project project; IDictionary hashtable = new Hashtable (); - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <Target Name='Main'> @@ -353,7 +353,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { </Target> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -769,12 +769,12 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -787,15 +787,15 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> </Project> "; - + engine = new Engine (Consts.BinPath); engine.GlobalProperties.SetProperty ("Property", "Value"); - + project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -815,12 +815,12 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -834,7 +834,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <PropertyGroup> @@ -842,7 +842,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { </PropertyGroup> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -861,7 +861,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <PropertyGroup> @@ -869,7 +869,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { </PropertyGroup> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -914,7 +914,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { { Engine engine; Project project; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); @@ -1076,18 +1076,18 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Assert.AreEqual (3, tl.TargetStartedEvents, "A1"); Assert.AreEqual (3, tl.TargetFinishedEvents, "A1"); } - + [Test] public void TestSchemaFile () { Engine engine; Project project; - + string documentString = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> </Project> "; - + engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); project.LoadXml (documentString); @@ -2092,7 +2092,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { <MeTAdata1>md3</MeTAdata1> <Metadata2>md4</Metadata2> </Abc> - </ItemGroup> + </ItemGroup> <PropertyGroup><ProP1>ValueProp</ProP1></PropertyGroup> <Target Name=""Main""> <MesSAGE Text=""Full item: @(ABC)""/> @@ -2159,7 +2159,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Path.Combine ("fr-FR", "Lib2.resources.dll"), "Lib4.dll", "Lib4" + debug_extn }, - + // lib1 new string [] { // lib1 files @@ -2216,7 +2216,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine { Project project = engine.CreateNewProject (); project.Load (Path.Combine (basepath, "Project01.sln.proj")); - + bool result = project.Build (); if (!result) { logger.DumpMessages (); @@ -2373,5 +2373,24 @@ namespace MonoTests.Microsoft.Build.BuildEngine { return project; } + + [Test] + public void CheckCommaInQuotes () + { + string testString = "Test.string.with.Commas"; + string documentString = string.Format (@" + <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""> + <PropertyGroup> + <TestString>{0}</TestString> + <TestString2>$(TestString.Replace(".",","))</TestString2> + </PropertyGroup> + </Project>", testString); + + Project project = new Project (); + project.LoadXml (documentString); + + string result = project.EvaluatedProperties ["TestString2"].FinalValue; + Assert.AreEqual (testString.Replace (".", ","), result, "A1"); + } } } |