Skip to content

Commit f21db05

Browse files
committed
fix(macos): Use case-insensitive API to load images from bundle
- also remove dead/unused method, unused since c0d16ea Addresses #8666
1 parent 6b8f248 commit f21db05

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ public bool HasSource()
6262
public bool HasBundle => BundlePath.HasValueTrimmed() || BundleName.HasValueTrimmed();
6363

6464
/// <summary>
65-
/// Open bundle is using either the name of the bundle (for
66-
/// android compatibility), or the path to the bundle for Windows compatibility.
65+
/// Open the image from the app's main bundle.
6766
/// </summary>
6867
internal NSImage OpenBundle()
6968
{
70-
ImageData = OpenBundleFromString(BundleName) ?? OpenResourceFromString(BundlePath);
69+
ImageData = OpenResourceFromString(BundlePath) ?? OpenResourceFromString(BundleName);
7170

7271
if (ImageData == null)
7372
{
@@ -77,28 +76,13 @@ internal NSImage OpenBundle()
7776
return ImageData;
7877
}
7978

80-
private static NSImage OpenBundleFromString(string bundle)
81-
{
82-
if (bundle.HasValueTrimmed())
83-
{
84-
return NSImage.ImageNamed(bundle);
85-
}
86-
87-
return null;
88-
}
89-
9079
private static NSImage OpenResourceFromString(string name)
9180
{
9281
if (name.HasValueTrimmed())
9382
{
94-
var extension = Path.GetExtension(name);
95-
var fileName = name.Replace(extension, string.Empty);
96-
97-
var path = NSBundle.MainBundle.PathForResource(fileName, extension);
98-
99-
return !string.IsNullOrEmpty(path)
100-
? new NSImage(path)
101-
: null;
83+
var path = Path.Combine(NSBundle.MainBundle.ResourcePath, name);
84+
if (File.Exists(path))
85+
return new NSImage(path);
10286
}
10387

10488
return null;

0 commit comments

Comments
 (0)