Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/introspection/iOS/introspection-ios-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>

<ItemGroup>
Expand All @@ -33,6 +34,18 @@
</ItemGroup>

<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="iOSApiCtorInitTest.cs" />
<Compile Include="iOSApiFieldTest.cs" />
<Compile Include="iOSApiSelectorTest.cs" />
<Compile Include="iOSApiSignatureTest.cs" />
<Compile Include="iOSApiProtocolTest.cs" />
<Compile Include="iOSApiWeakPropertyTest.cs" />
<Compile Include="iOSApiPInvokeTest.cs" />
<Compile Include="iOSApiClassPtrTest.cs" />
<Compile Include="iOSApiTypoTest.cs" />
<Compile Include="iOSCoreImageFiltersTest.cs" />
<Compile Include="..\ApiBaseTest.cs">
<Link>ApiBaseTest.cs</Link>
</Compile>
Expand Down Expand Up @@ -103,6 +116,26 @@
<Link>ApiTypeTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist">
<LogicalName>Info.plist</LogicalName>
</None>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="LaunchScreen.storyboard" Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" />
</ItemGroup>
<ItemGroup>
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\Contents.json" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\Icon-app-60%403x.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-57.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-57%402x.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-60%402x.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-72.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-72%402x.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-76.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="..\xamarin1.png">
<Link>xamarin1.png</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,50 +95,52 @@ public async Task CreateCopyAsync (ILog log, IProcessManager processManager, ITe
doc.ResolveAllPaths (original_path);

if (doc.IsDotNetProject ()) {
// Many types of files below the csproj directory are included by default,
// which means that we have to include them manually in the cloned csproj,
// because the cloned project is stored in a very different directory.
var test_dir = System.IO.Path.GetDirectoryName (original_path);

// Get all the files in the project directory from git
using var process = new Process ();
process.StartInfo.FileName = "git";
process.StartInfo.Arguments = "ls-files";
process.StartInfo.WorkingDirectory = test_dir;
var stdout = new MemoryLog () { Timestamp = false };
var result = await processManager.RunAsync (process, log, stdout, stdout, timeout: TimeSpan.FromSeconds (15));
if (!result.Succeeded)
throw new Exception ($"Failed to list the files in the directory {test_dir} (TimedOut: {result.TimedOut} ExitCode: {result.ExitCode}):\n{stdout}");

var files = stdout.ToString ().Split ('\n');
foreach (var file in files) {
var ext = System.IO.Path.GetExtension (file);
var full_path = System.IO.Path.Combine (test_dir, file);
var windows_file = full_path.Replace ('/', '\\');

if (file.Contains (".xcasset")) {
doc.AddInclude ("ImageAsset", file, windows_file, true);
continue;
}

switch (ext.ToLowerInvariant ()) {
case ".cs":
doc.AddInclude ("Compile", file, windows_file, true);
break;
case ".plist":
doc.AddInclude ("None", file, windows_file, true);
break;
case ".storyboard":
doc.AddInclude ("InterfaceDefinition", file, windows_file, true);
break;
case ".gitignore":
case ".csproj":
case ".props": // Directory.Build.props
case "": // Makefile
break; // ignore these files
default:
Console.WriteLine ($"Unknown file: {file} (extension: {ext}). There might be a default inclusion behavior for this file.");
break;
if (doc.GetEnableDefaultItems () != false) {
// Many types of files below the csproj directory are included by default,
// which means that we have to include them manually in the cloned csproj,
// because the cloned project is stored in a very different directory.
var test_dir = System.IO.Path.GetDirectoryName (original_path);

// Get all the files in the project directory from git
using var process = new Process ();
process.StartInfo.FileName = "git";
process.StartInfo.Arguments = "ls-files";
process.StartInfo.WorkingDirectory = test_dir;
var stdout = new MemoryLog () { Timestamp = false };
var result = await processManager.RunAsync (process, log, stdout, stdout, timeout: TimeSpan.FromSeconds (15));
if (!result.Succeeded)
throw new Exception ($"Failed to list the files in the directory {test_dir} (TimedOut: {result.TimedOut} ExitCode: {result.ExitCode}):\n{stdout}");

var files = stdout.ToString ().Split ('\n');
foreach (var file in files) {
var ext = System.IO.Path.GetExtension (file);
var full_path = System.IO.Path.Combine (test_dir, file);
var windows_file = full_path.Replace ('/', '\\');

if (file.Contains (".xcasset")) {
doc.AddInclude ("ImageAsset", file, windows_file, true);
continue;
}

switch (ext.ToLowerInvariant ()) {
case ".cs":
doc.AddInclude ("Compile", file, windows_file, true);
break;
case ".plist":
doc.AddInclude ("None", file, windows_file, true);
break;
case ".storyboard":
doc.AddInclude ("InterfaceDefinition", file, windows_file, true);
break;
case ".gitignore":
case ".csproj":
case ".props": // Directory.Build.props
case "": // Makefile
break; // ignore these files
default:
Console.WriteLine ($"Unknown file: {file} (extension: {ext}). There might be a default inclusion behavior for this file.");
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ public static bool IsDotNetProject (this XmlDocument csproj)
return attrib != null;
}

public static bool? GetEnableDefaultItems (this XmlDocument csproj)
{
var node = csproj.SelectSingleNode ($"/*/*/*[local-name() = 'EnableDefaultItems']");
if (node == null)
return null;
return string.Equals (node.InnerText, "true", StringComparison.OrdinalIgnoreCase);
}

static XmlNode GetInfoPListNode (this XmlDocument csproj, bool throw_if_not_found = false)
{
var logicalNames = csproj.SelectNodes ("//*[local-name() = 'LogicalName']");
Expand Down