Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msbuild] Add reference to System.Drawing.Common.dll to XI projects. #6011

Merged
7 changes: 7 additions & 0 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ Copyright (C) 2014 Xamarin. All rights reserved.
<RemoveDir Directories="$(IntermediateOutputPath)" />
</Target>

<Target Name="_AddExtraReferences" BeforeTargets="ResolveAssemblyReferences" Condition="'$(DisableExtraReferences)' != 'true'">
<ItemGroup>
<!-- https://github.com/mono/mono/issues/13483 -->
<Reference Include="System.Drawing.Common.dll" />
</ItemGroup>
</Target>

<PropertyGroup>
<_CollectBundleResourcesDependsOn>
_CompileImageAssets;
Expand Down
7 changes: 7 additions & 0 deletions msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<Delete SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Files="@(_IpaPackageFile)" />
</Target>

<Target Name="_AddExtraReferences" BeforeTargets="ResolveAssemblyReferences" Condition="'$(DisableExtraReferences)' != 'true'">
<ItemGroup>
<!-- https://github.com/mono/mono/issues/13483 -->
<Reference Include="System.Drawing.Common.dll" />
</ItemGroup>
</Target>

<PropertyGroup>
<_CollectBundleResourcesDependsOn>
_CompileInterfaceDefinitions;
Expand Down
38 changes: 24 additions & 14 deletions msbuild/tests/Xamarin.iOS.Tasks.Tests/TargetTests/TargetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,38 @@ public void GetReferencedAssemblies_Executable ()
{
RunTargetOnInstance (MonoTouchProjectInstance, TargetName.ResolveReferences);
var references = MonoTouchProjectInstance.GetItems ("ReferencePath").ToArray ();
var expected_references = new string[] {
"MyLibrary.dll",
"System.dll",
"System.Xml.dll",
"System.Core.dll",
"mscorlib.dll",
"Xamarin.iOS.dll",
"System.Drawing.Common.dll",
};
Array.Sort (expected_references);

Assert.AreEqual (6, references.Length, "#1");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("MyLibrary")), "#2");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System")), "#3a");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Xml")), "#3b");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Core")), "#3c");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("mscorlib")), "#3d");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("Xamarin.iOS")), "#3e");
var actual_references = references.Select ((v) => Path.GetFileName (v.EvaluatedInclude)).OrderBy ((v) => v);
CollectionAssert.AreEquivalent (expected_references, actual_references, "References");
}

[Test]
public void GetReferencedAssemblies_Library ()
{
RunTargetOnInstance (LibraryProjectInstance, TargetName.ResolveReferences);
var references = LibraryProjectInstance.GetItems ("ReferencePath").ToArray ();

Assert.AreEqual (5, references.Length, "#1");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System")), "#2a");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Xml")), "#2b");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("System.Core")), "#2c");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("mscorlib")), "#2d");
Assert.IsTrue (references.Any (t => t.EvaluatedInclude.Contains ("Xamarin.iOS")), "#2e");
var expected_references = new string[] {
"System.dll",
"System.Xml.dll",
"System.Core.dll",
"mscorlib.dll",
"Xamarin.iOS.dll",
"System.Drawing.Common.dll",
};
Array.Sort (expected_references);

var actual_references = references.Select ((v) => Path.GetFileName (v.EvaluatedInclude)).OrderBy ((v) => v);
CollectionAssert.AreEquivalent (expected_references, actual_references, "References");
}

[Test]
Expand Down
16 changes: 13 additions & 3 deletions tests/common/mac/ProjectTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ public class UnifiedTestConfig
// Generated by TestUnifiedExecutable/TestSystemMonoExecutable and added to TestCode
public Guid guid { get; set; }

public string BundleName {
get { return AssemblyName != "" ? AssemblyName : ProjectName.Split ('.') [0]; }
}

public string BundlePath {
get { return Path.Combine (TmpDir, "bin", Release ? "Release" : "Debug", BundleName + ".app"); }
}

public string ExecutablePath {
get { return Path.Combine (BundlePath, "Contents", "MacOS", BundleName); }
}

public UnifiedTestConfig (string tmpDir)
{
TmpDir = tmpDir;
Expand Down Expand Up @@ -427,9 +439,7 @@ public static string GenerateAndBuildUnifiedExecutable (UnifiedTestConfig config

public static string RunGeneratedUnifiedExecutable (UnifiedTestConfig config)
{
string bundleName = config.AssemblyName != "" ? config.AssemblyName : config.ProjectName.Split ('.')[0];
string exePath = Path.Combine (config.TmpDir, "bin/" + (config.Release ? "Release/" : "Debug/") + bundleName + ".app/Contents/MacOS/" + bundleName);
return RunEXEAndVerifyGUID (config.TmpDir, config.guid, exePath);
return RunEXEAndVerifyGUID (config.TmpDir, config.guid, config.ExecutablePath);
}

public static OutputText TestUnifiedExecutable (UnifiedTestConfig config, bool shouldFail = false, string[] environment = null)
Expand Down
1 change: 0 additions & 1 deletion tests/introspection/iOS/introspection-ios.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing.Common" /> <!-- FIXME: https://github.com/mono/mono/issues/13483 -->
<Reference Include="Xamarin.iOS" />
<Reference Include="MonoTouch.NUnitLite" />
<Reference Include="System.Core" />
Expand Down
7 changes: 6 additions & 1 deletion tests/mmptest/src/AssemblyReferencesTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;

Expand All @@ -17,7 +18,11 @@ public void ShouldNotAllowReference_ToSystemDrawing ()
TestCode = "System.Drawing.RectangleF f = new System.Drawing.RectangleF ();",
XM45 = true
};
TI.TestUnifiedExecutable (test, shouldFail: true);
TI.TestUnifiedExecutable (test);
var allAssembliesInBundle = Directory.GetFiles (test.BundlePath, "*.dll", SearchOption.AllDirectories).Select (Path.GetFileName);
Assert.That (allAssembliesInBundle, Does.Contain ("mscorlib.dll"), "mscorlib.dll");
Assert.That (allAssembliesInBundle, Does.Contain ("System.Drawing.Common.dll"), "System.Drawing.Common.dll");
Assert.That (allAssembliesInBundle, Does.Not.Contain ("System.Drawing.dll"), "System.Drawing.dll");
});
}

Expand Down
1 change: 0 additions & 1 deletion tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
<Reference Include="MonoTouch.NUnitLite" />
<Reference Include="System.Net.Http" />
<Reference Include="OpenTK-1.0" />
<Reference Include="System.Drawing.Common" /> <!-- FIXME: https://github.com/mono/mono/issues/13483 -->
</ItemGroup>
<ItemGroup>
<None Include="Info.plist">
Expand Down
1 change: 0 additions & 1 deletion tests/xammac_tests/xammac_tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="OpenTK" />
<Reference Include="System.Drawing.Common" /> <!-- FIXME: https://github.com/mono/mono/issues/13483 -->
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
Expand Down