Skip to content

Commit

Permalink
chore: Adjust for macOS build for android
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Oct 20, 2022
1 parent 165f214 commit 1519562
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/SourceGenerators/Uno.UI.Tasks/Assets/RetargetAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ private TaskItem ProcessContentItem(ITaskItem asset, Func<ResourceCandidate, str
relativePath = fullPath.Replace(asset.GetMetadata("DefiningProjectDirectory"), "");
}

relativePath = AlignPath(relativePath);

if (IsImageAsset(asset.ItemSpec))
{
var resourceCandidate = ResourceCandidate.Parse(fullPath, relativePath);
Expand Down Expand Up @@ -141,5 +143,10 @@ private static bool IsImageAsset(string path)
|| extension == ".jpeg"
|| extension == ".gif";
}

private static string AlignPath(string path)
=> path
.Replace('/', Path.DirectorySeparatorChar)
.Replace('\\', Path.DirectorySeparatorChar);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public async Task When_Project_Transitive_Asset()
}
catch (Exception ex)
{
Assert.Fail("Transitive asset could not be found " + ex.Message);
Assert.Fail("Transitive asset could not be found: " + ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/StorageFile.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static async Task<StorageFile> GetFileFromApplicationUri(CancellationTok

if (uri.Host is { Length: > 0 } host)
{
originalPath = host + "/" + originalPath.TrimStart('/');
originalPath = host.ToLowerInvariant() + "/" + originalPath.TrimStart('/');
}

var path = AndroidResourceNameEncoder.EncodeResourcePath(originalPath);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/StorageFile.iOSmacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static async Task<StorageFile> GetFileFromApplicationUri(CancellationTok
{
if (uri.Host is { Length: > 0 } host)
{
directoryName = host + "/" + directoryName.TrimStart('/');
directoryName = host.ToLowerInvariant() + "/" + directoryName.TrimStart('/');
}

var resourcePathname = NSBundle.MainBundle.PathForResource(global::System.IO.Path.Combine(directoryName, fileName), fileExtension.Substring(1));
Expand Down

0 comments on commit 1519562

Please sign in to comment.