Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust reading package to return null if Logo not specified #12753

Merged
merged 3 commits into from
Jul 4, 2023
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
22 changes: 10 additions & 12 deletions src/Uno.UWP/ApplicationModel/Package.Other.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class Package
private static Assembly? _entryAssembly;
private string _displayName = "";
private string _logo = "ms-appx://logo";
private bool _manifestParsed;
private bool? _manifestParsed;

private bool GetInnerIsDevelopmentMode() => false;

Expand Down Expand Up @@ -49,23 +49,18 @@ public string DisplayName
}
}

public Uri Logo
{
get
{
TryParsePackageManifest();
return new Uri(_logo, UriKind.RelativeOrAbsolute);
}
}
public Uri? Logo =>
TryParsePackageManifest() && !string.IsNullOrWhiteSpace(_logo) ? new Uri(_logo, UriKind.RelativeOrAbsolute) : default;
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved

internal static void SetEntryAssembly(Assembly entryAssembly)
{
_entryAssembly = entryAssembly;
}

private void TryParsePackageManifest()
private bool TryParsePackageManifest()
{
if (_entryAssembly != null && !_manifestParsed)
if (_entryAssembly != null &&
!_manifestParsed.HasValue)
{
var manifest = _entryAssembly.GetManifestResourceStream(PackageManifestName);

Expand All @@ -81,11 +76,11 @@ private void TryParsePackageManifest()

_displayName = doc.SelectSingleNode("/d:Package/d:Properties/d:DisplayName", nsmgr)?.InnerText ?? "";
_logo = doc.SelectSingleNode("/d:Package/d:Properties/d:Logo", nsmgr)?.InnerText ?? "";

_manifestParsed = true;
}
catch (Exception ex)
{
_manifestParsed = false;
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Error))
{
this.Log().Error($"Failed to read manifest [{PackageManifestName}]", ex);
Expand All @@ -94,12 +89,15 @@ private void TryParsePackageManifest()
}
else
{
_manifestParsed = false;
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"Skipping manifest reading, unable to find [{PackageManifestName}]");
}
}
}

return _manifestParsed ?? false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/ApplicationModel/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal Package()

#if (__IOS__ || __ANDROID__ || __MACOS__)
[global::Uno.NotImplemented]
public global::System.Uri Logo => new Uri("http://example.com");
public global::System.Uri Logo => default;
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
#endif

[Uno.NotImplemented]
Expand Down