Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMatt Ward <matt.ward@microsoft.com>2019-10-28 17:00:06 +0300
committerMatt Ward <ward.matt@gmail.com>2019-10-28 18:53:15 +0300
commit169c3b65313707f4529a6bc0e426e1dad7781512 (patch)
treeeeac543d0ef2a9b3ddc3f2f7adcb572fa69df11f /main
parent445d705919aff3639bd8e95a208f99bdbf122ecd (diff)
[Core] Fix MSBuild functions not being evaluated
Defining a property that used an MSBuild instrinsic function would not evaluate if the case did not match. For example: <PropertyGroup> <IsMac>$([MSBuild]::IsOsPlatform('OSX'))</IsMac> </PropertyGroup> This would not evaluate to true since the instrinsic function's case is IsOSPlatform. However MSBuild on the command line would evaluate this correctly. Fixed this by making the method cache lookup case insensitive so it matches MSBuild's behaviour. Fixes VSTS #1008396 - DefineConstants not working right if they are set in imported projects
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs2
-rw-r--r--main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs14
-rwxr-xr-xmain/tests/test-projects/msbuild-tests/osplatform.csproj12
3 files changed, 27 insertions, 1 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
index 7dc989ec86..b03abb534d 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs
@@ -1017,7 +1017,7 @@ namespace MonoDevelop.Projects.MSBuild
static readonly Dictionary<string, MethodInfo[]> cachedIntrinsicFunctions = typeof (IntrinsicFunctions)
.GetMethods (BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.Static)
.ToLookup (x => x.Name)
- .ToDictionary(x => x.Key, x => x.ToArray ());
+ .ToDictionary(x => x.Key, x => x.ToArray (), StringComparer.OrdinalIgnoreCase);
MemberInfo[] ResolveMember (Type type, string memberName, bool isStatic, MemberTypes memberTypes)
{
diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs
index 45b419e8f9..05320587bf 100644
--- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs
+++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs
@@ -572,6 +572,20 @@ namespace MonoDevelop.Projects
}
[Test]
+ public void InstrinsicProperties_IsOSPlatform_IsCaseInsensitive ()
+ {
+ if (!Platform.IsMac)
+ Assert.Ignore ();
+
+ using (var p = LoadAndEvaluate ("msbuild-tests", "osplatform.csproj")) {
+ Assert.IsTrue (p.EvaluatedProperties.GetValue<bool> ("IsMac"));
+ Assert.IsTrue (p.EvaluatedProperties.GetValue<bool> ("IsMac2"));
+ Assert.IsTrue (p.EvaluatedProperties.GetValue<bool> ("IsMac3"));
+ Assert.AreEqual ("MAC", p.EvaluatedProperties.GetValue ("DefineConstants"));
+ }
+ }
+
+ [Test]
public void ItemDefinitionGroup ()
{
using (var p = LoadAndEvaluate ("project-with-item-def-group", "item-definition-group.csproj")) {
diff --git a/main/tests/test-projects/msbuild-tests/osplatform.csproj b/main/tests/test-projects/msbuild-tests/osplatform.csproj
new file mode 100755
index 0000000000..df6949340a
--- /dev/null
+++ b/main/tests/test-projects/msbuild-tests/osplatform.csproj
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <IsMac>$([MSBuild]::IsOsPlatform('OSX'))</IsMac>
+ <IsMac2>$([MSBuild]::IsOSPlatform('OSX'))</IsMac2>
+ <IsMac3>$([MSBuild]::isosplatform('OSX'))</IsMac3>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <DefineConstants Condition="$(IsMac)">MAC</DefineConstants>
+ </PropertyGroup>
+</Project>