diff --git a/src/Uno.UI.RuntimeTests/Assets/help.svg b/src/Uno.UI.RuntimeTests/Assets/help.svg
new file mode 100644
index 000000000000..d1c1420b685b
--- /dev/null
+++ b/src/Uno.UI.RuntimeTests/Assets/help.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs
index 78598259e726..5f5f8822f242 100644
--- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs
+++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs
@@ -450,19 +450,29 @@ public async Task When_Loaded_From_AppData_LocalFolder()
[TestMethod]
[RunsOnUIThread]
- public async Task When_SVGImageSource()
+ [DataRow("ms-appx:///Assets/couch.svg")]
+ [DataRow("ms-appx:///Uno.UI.RuntimeTests/Assets/couch.svg")]
+ [DataRow("ms-appx:///Uno.UI.RuntimeTests/Assets/help.svg")]
+ public async Task When_SVGImageSource(string imagePath)
{
if (!ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap"))
{
- Assert.Inconclusive(); // System.NotImplementedException: RenderTargetBitmap is not supported on this platform.;
+ Assert.Inconclusive("RenderTargetBitmap is not supported on this platform");
}
+<<<<<<< HEAD
var svgImageSource = new SvgImageSource(new Uri("ms-appx:///Assets/couch.svg"));
+=======
+ var svgImageSource = new SvgImageSource(new Uri(imagePath));
+>>>>>>> 57a48eb8f6 (fix(assets): Adjust assets caching by including assembly and package versions)
var image = new Image() { Source = svgImageSource, Width = 100, Height = 100 };
TestServices.WindowHelper.WindowContent = image;
await WindowHelper.WaitForLoaded(image);
}
+<<<<<<< HEAD
+=======
+>>>>>>> 57a48eb8f6 (fix(assets): Adjust assets caching by including assembly and package versions)
[TestMethod]
[RunsOnUIThread]
diff --git a/src/Uno.UWP/Storage/StorageFile.Android.cs b/src/Uno.UWP/Storage/StorageFile.Android.cs
index f0660d8dad2e..9d891e29c785 100644
--- a/src/Uno.UWP/Storage/StorageFile.Android.cs
+++ b/src/Uno.UWP/Storage/StorageFile.Android.cs
@@ -1,3 +1,5 @@
+#nullable enable
+
using System;
using System.Globalization;
using System.IO;
@@ -15,12 +17,14 @@
using Windows.Storage.Streams;
using Windows.Storage.Helpers;
using Uno.Helpers;
+using Windows.ApplicationModel.Background;
namespace Windows.Storage
{
partial class StorageFile
{
private static ConcurrentEntryManager _assetGate = new ConcurrentEntryManager();
+ private static string? _currentAppID;
private static async Task GetFileFromApplicationUri(CancellationToken ct, Uri uri)
{
@@ -34,8 +38,10 @@ private static async Task GetFileFromApplicationUri(CancellationTok
var path = AndroidResourceNameEncoder.EncodeResourcePath(originalPath);
+ EnsureAppID();
+
// Read the contents of our asset
- var outputCachePath = global::System.IO.Path.Combine(Android.App.Application.Context.CacheDir.AbsolutePath, path);
+ var outputCachePath = global::System.IO.Path.Combine(Android.App.Application.Context.CacheDir!.AbsolutePath, _currentAppID, path);
if (typeof(StorageFile).Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
@@ -50,18 +56,18 @@ private static async Task GetFileFromApplicationUri(CancellationTok
if (!File.Exists(outputCachePath))
{
- Directory.CreateDirectory(global::System.IO.Path.GetDirectoryName(outputCachePath));
+ Directory.CreateDirectory(global::System.IO.Path.GetDirectoryName(outputCachePath)!);
Stream GetAsset()
{
if (DrawableHelper.FindResourceIdFromPath(path) is { } resourceId)
{
- return ContextHelper.Current.Resources.OpenRawResource(resourceId);
+ return ContextHelper.Current.Resources!.OpenRawResource(resourceId);
}
else
{
var assets = global::Android.App.Application.Context.Assets;
- return assets.Open(path);
+ return assets!.Open(path);
}
}
@@ -73,5 +79,17 @@ Stream GetAsset()
return await StorageFile.GetFileFromPathAsync(outputCachePath);
}
+
+ private static void EnsureAppID()
+ {
+ if (_currentAppID is null)
+ {
+ var packageVersion = ApplicationModel.Package.Current.Id.Version;
+
+ _currentAppID =
+ ContextHelper.Current.GetType().Assembly.GetModules().First().ModuleVersionId.ToString()
+ + $"_{packageVersion.Major}.{packageVersion.Minor}.{packageVersion.Build}.{packageVersion.Revision}";
+ }
+ }
}
}