Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

UWP support #434

Merged
merged 5 commits into from
May 20, 2022
Merged

UWP support #434

merged 5 commits into from
May 20, 2022

Conversation

ujjwalchadha
Copy link
Contributor

This PR adds support to convert the UWP app style project files to WinUI (and in effect be able to use the new Windows App SDK).
This PR is an effort to add the UWP - Windows App SDK migration tooling to the existing .net upgrade-assistant tool that uses the try-convert tool as a submodule.

@dnfadmin
Copy link

dnfadmin commented Mar 28, 2022

CLA assistant check
All CLA requirements met.

@@ -60,8 +60,9 @@ private static string GetCurrentTFM(ImmutableArray<string> globalProperties, Unc
$"{MSBuildFacts.TargetFrameworkNodeName} is not set in {nameof(project.FirstConfiguredProject)}");
}

// This is pretty much never gonna happen, but it was cheap to write the code
return MSBuildHelpers.IsNotNetFramework(rawTFM) ? StripDecimals(rawTFM) : rawTFM;
// MSBuildHelpers.IsNotNetFramework is pretty much never gonna happen...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to just say MSBuildHelpers.IsWindows(rawTFM) can happen when coverting a UWP

@@ -374,6 +411,13 @@ private static bool UnquoteString(ref string s)
}

s = s[1..^1];

// Make sure there wasn't another string in there
if (s.Contains('\''))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sotteson1 Can you explain your rationale behind this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sotteson1 Can you explain your rationale behind this change?

It's been months since I added that, but it seems like there was a case where there was another string in the text after the first quotes were removed. I was returning false to indicate the function failed, but then it's probably not good that it's already modified the ref'ed parameter. Sorry I don't have more information than that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why this is needed.
We have a property Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' "
When we split this by == in the method ConditionToDimensionValues, the right side of the string becomes '' or '$(VisualStudioVersion)' &lt; '14.0'
The Unquote function ends up returning ' or '$(VisualStudioVersion)' &lt; '14.0 which is an invalid unquoted string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A correct fix is checking whether the string s[1..^1] contains ` before we convert to unquoted string and not after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal scenario, the ConditionToDimensionValues method (on line 78 in the same file) should first split by the or and and conditions and then split by ==
Do you think this might be a bug? @jmarolf what do you think is the expected behavior here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change the behavior in a followup PR to have ConditionToDimensionValues work as you describe.

Copy link
Contributor

@jmarolf jmarolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just a few questions

@jmarolf jmarolf merged commit 3799b68 into dotnet:main May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants