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

Use root xmlns #297

Merged
merged 11 commits into from
Jun 19, 2024
38 changes: 18 additions & 20 deletions src/Resizetizer/src/GeneratePackageAppxManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class GeneratePackageAppxManifest_v0 : Task

const string ErrorVersionNumberCombination = "ApplicationDisplayVersion '{0}' was not a valid 3 part semver version number and/or ApplicationVersion '{1}' was not a valid integer.";

static readonly XNamespace xmlnsUap = "http://schemas.microsoft.com/appx/manifest/uap/windows10";

[Required]
public string IntermediateOutputPath { get; set; } = null!;

Expand Down Expand Up @@ -181,7 +179,7 @@ void UpdateManifest(XDocument appx)
}

// <uap:VisualElements>
var xvisual = xmlnsUap + "VisualElements";
var xvisual = xmlns + "VisualElements";
var visual = application.Element(xvisual);
if (visual == null)
dansiegel marked this conversation as resolved.
Show resolved Hide resolved
{
Expand All @@ -190,7 +188,7 @@ void UpdateManifest(XDocument appx)
}

// <uap:DefaultTile>
var xtile = xmlnsUap + "DefaultTile";
var xtile = xmlns + "DefaultTile";
var tile = visual.Element(xtile);
if (tile == null)
{
Expand All @@ -199,7 +197,7 @@ void UpdateManifest(XDocument appx)
}

// <uap:ShowNameOnTiles>
var xshowname = xmlnsUap + "ShowNameOnTiles";
var xshowname = xmlns + "ShowNameOnTiles";
var showname = tile.Element(xshowname);
if (showname == null)
{
Expand All @@ -226,7 +224,7 @@ void UpdateManifest(XDocument appx)
UpdateDefaultTileSquare310Logo(tile, appIconInfo);

// <ShowOn>
var xshowon = xmlnsUap + "ShowOn";
var xshowon = xmlns + "ShowOn";
var showons = showname.Elements(xshowon).ToArray();
if (showons.All(x => x.Attribute("Tile")?.Value != "square150x150Logo"))
{
Expand All @@ -242,7 +240,7 @@ void UpdateManifest(XDocument appx)
if (splashInfo != null)
{
// <uap:SplashScreen>
var xsplash = xmlnsUap + "SplashScreen";
var xsplash = xmlns + "SplashScreen";
var splash = visual.Element(xsplash);
if (splash == null)
{
Expand Down Expand Up @@ -523,19 +521,19 @@ private static void SetVersion(XElement target, XName attributeName, string vers
}
}

static bool IsVersionAttribute(XAttribute attribute, XName attributeName)
{
var currentAttributeName = attribute.Name.LocalName;
var expectedAttributeName = attributeName.LocalName;
var currentAttributeNamespace = attribute.Name.Namespace.NamespaceName;
var expectedAttributeNamespace = attributeName.NamespaceName;
// The Version may not have a current Namespace and should use the default namespace
if (string.IsNullOrEmpty(currentAttributeNamespace))
return currentAttributeName == expectedAttributeName;
return currentAttributeName == expectedAttributeName && currentAttributeNamespace == expectedAttributeNamespace;
static bool IsVersionAttribute(XAttribute attribute, XName attributeName)
{
var currentAttributeName = attribute.Name.LocalName;
var expectedAttributeName = attributeName.LocalName;

var currentAttributeNamespace = attribute.Name.Namespace.NamespaceName;
var expectedAttributeNamespace = attributeName.NamespaceName;

// The Version may not have a current Namespace and should use the default namespace
if (string.IsNullOrEmpty(currentAttributeNamespace))
return currentAttributeName == expectedAttributeName;

return currentAttributeName == expectedAttributeName && currentAttributeNamespace == expectedAttributeNamespace;
}

public static bool TryMergeVersionNumbers(string? displayVersion, string? version, out string? finalVersion)
Expand Down
Loading