Skip to content

Commit 743b674

Browse files
author
Ujjwal Chadha
committed
Address feedback
1 parent 87d11a3 commit 743b674

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/extensions/windows/Microsoft.DotNet.UpgradeAssistant.Extensions.Windows/UWPtoWinAppSDKUpgrade/WinUIPropertiesUpdater.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class WinUIPropertiesUpdater : IUpdater<IProject>
2121
{
2222
public const string RuleID = "UA302";
2323

24-
private const string CsWinRTLogMessageFormat = "A CsWinRTIncludes property with value {0} has been added.\n" +
24+
private const string CsWinRTLogMessageFormat = "A CsWinRTIncludes property with value {0} has been added to specify the namespace of the referenced vcxproj component to project..\n" +
2525
"If your project assembly name differs from {0}, update this value with the assembly name.\n" +
26-
"Read more about CsWinRT here: https://docs.microsoft.com/en-us/windows/apps/develop/platform/csharp-winrt/";
26+
"Read more about C#/WinRT here: https://docs.microsoft.com/en-us/windows/apps/develop/platform/csharp-winrt/";
2727

2828
private const string CsWinRTIncludesProperty = "CsWinRTIncludes";
2929

@@ -85,7 +85,7 @@ public async Task<IUpdaterResult> ApplyAsync(IUpgradeContext context, ImmutableA
8585
var projectName = ParseProjectNameWithExtension(projRef, ".vcxproj");
8686
var csWinRTIncludesValue = projectFile.GetPropertyValue(CsWinRTIncludesProperty) ?? string.Empty;
8787
var delimiter = csWinRTIncludesValue.Trim().Length == 0 || csWinRTIncludesValue.EndsWith(";") ? string.Empty : ";";
88-
projectFile.SetPropertyValue("CsWinRTIncludes", $"{csWinRTIncludesValue}{delimiter}{projectName}");
88+
projectFile.SetPropertyValue(CsWinRTIncludesProperty, $"{csWinRTIncludesValue}{delimiter}{projectName}");
8989

9090
_logger.LogInformation(string.Format(CsWinRTLogMessageFormat, projectName));
9191
}
@@ -107,6 +107,11 @@ public async Task<IUpdaterResult> ApplyAsync(IUpgradeContext context, ImmutableA
107107
new List<string>());
108108
}
109109

110+
/*
111+
This function parses the project name from projectReference string which includes the file path, project id and more text.
112+
It does so by finding the position of ".vcxproj" in the string and then reading the name backwards character by character
113+
until the first non-alphanumeric character.
114+
*/
110115
private string ParseProjectNameWithExtension(string projectReference, string extension)
111116
{
112117
var index = projectReference.IndexOf(".vcxproj");

0 commit comments

Comments
 (0)