Skip to content

Commit

Permalink
Merge pull request #12753 from unoplatform/dev/nr/logonotnull
Browse files Browse the repository at this point in the history
fix: Adjust reading package to return null if Logo not specified
  • Loading branch information
nickrandolph authored Jul 4, 2023
2 parents b2c41ff + 340af1a commit dd37d25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
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;

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;
#endif

[Uno.NotImplemented]
Expand Down

0 comments on commit dd37d25

Please sign in to comment.