Skip to content

Commit

Permalink
Merge branch 'main' into attribute_super_convert_type_mass_smash_2
Browse files Browse the repository at this point in the history
  • Loading branch information
chamons authored Mar 15, 2022
2 parents 92e446d + b859c6d commit 7c3f397
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"author": "Microsoft",
"name": "iOS Controller template",
"name": "iOS Controller template (Preview)",
"description": "An iOS Controller class",
"symbols/namespace/description": "namespace for the generated code"
}
12 changes: 11 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/Ditto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Xamarin.Messaging.Build.Client;

namespace Xamarin.MacDev.Tasks
Expand Down Expand Up @@ -29,7 +30,16 @@ public override void Cancel ()
BuildConnection.CancelAsync (SessionId, BuildEngine4).Wait ();
}

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
{
if (!Directory.Exists(Source.ItemSpec))
return Enumerable.Empty<ITaskItem> ();

// TaskRunner doesn't know how to copy directories to Mac but `ditto` can take directories (and that's why we use ditto often).
// If Source is a directory path, let's add each file within it as an TaskItem, as TaskRunner knows how to copy files to Mac.
return Directory.GetFiles (Source.ItemSpec, "*", SearchOption.AllDirectories)
.Select(f => new TaskItem(f));
}

public bool ShouldCopyToBuildServer (ITaskItem item) => true;

Expand Down
30 changes: 2 additions & 28 deletions tests/common/mac/ProjectTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,6 @@ public UnifiedTestConfig (string tmpDir)
}
}

public static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly ().CodeBase;
UriBuilder uri = new UriBuilder (codeBase);
string path = Uri.UnescapeDataString (uri.Path);
return Path.GetDirectoryName (path);
}
}

public static Version FindMonoVersion ()
{
string output = RunAndAssert ("/Library/Frameworks/Mono.framework/Commands/mono", new [] { "--version" }, "FindMonoVersion");
Expand Down Expand Up @@ -453,26 +442,11 @@ public static string GenerateSystemMonoEXEProject (UnifiedTestConfig config)
});
}

public static string TestDirectory => Path.Combine (FindRootDirectory (), "..", "tests") + "/";
public static string TestDirectory => Path.Combine (Configuration.RootPath, "tests");

public static string FindSourceDirectory ()
{
if (Configuration.IsVsts) {
// use the working directory from vsts
var vstsWorkingDirectory = Environment.GetEnvironmentVariable ("SYSTEM_DEFAULTWORKINGDIRECTORY");
var gitDirectory = Path.Combine (vstsWorkingDirectory, ".git");
if (Directory.Exists (gitDirectory)) {
return Path.Combine (vstsWorkingDirectory, TestDirectory + "common/mac");
} else {
return Path.Combine (vstsWorkingDirectory, "xamarin-macios" ,TestDirectory + "common/mac");
}
} else {
string codeBase = System.Reflection.Assembly.GetExecutingAssembly ().CodeBase;
UriBuilder uri = new UriBuilder (codeBase);
string path = Uri.UnescapeDataString (uri.Path);
string assemblyDirectory = Path.GetDirectoryName (path);
return Path.Combine(assemblyDirectory, TestDirectory + "common/mac");
}
return Path.Combine (TestDirectory, "common", "mac");
}

public static void CopyDirectory (string src, string target)
Expand Down
2 changes: 1 addition & 1 deletion tests/mmptest/src/NativeReferencesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ string CreateCopyOfSimpleClassInTestDir (string tmpDir, string fileName = "Simpl
string dylibPath = Path.Combine (tmpDir, "dll/");
string filePath = Path.Combine (dylibPath, fileName);
Directory.CreateDirectory (dylibPath);
File.Copy (Path.Combine (TI.AssemblyDirectory, TI.TestDirectory + "mac-binding-project/bin/SimpleClassDylib.dylib"), filePath);
File.Copy (Path.Combine (TI.TestDirectory, "mac-binding-project", "bin", "SimpleClassDylib.dylib"), filePath);
return filePath;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/msbuild/Xamarin.MacDev.Tests/MSBuild-Smoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void BuildUnifiedXM45_Program_SmokeTest ()

void TestBCLCore (string tmpDir, string projectName)
{
var dll = Path.GetFullPath (Path.Combine (TI.TestDirectory + "common", "mac", "System.Collections.Immutable.dll"));
var dll = Path.GetFullPath (Path.Combine (TI.TestDirectory, "common", "mac", "System.Collections.Immutable.dll"));
string reference = $"<Reference Include=\"System.Collections.Immutable\"><HintPath>{dll}</HintPath></Reference>";
string testCode = "var v = System.Collections.Immutable.ImmutableArray.CreateRange (new int [] { 42 });";
string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = projectName, References = reference, TestCode = testCode });
Expand Down

0 comments on commit 7c3f397

Please sign in to comment.