File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Microsoft.Toolkit.Uwp.SampleApp/Models
Microsoft.Toolkit.Uwp/Helpers Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 2727using Microsoft . Toolkit . Uwp . UI . Controls ;
2828using Microsoft . Toolkit . Uwp . UI . Media ;
2929using Microsoft . UI . Xaml ;
30+ using Windows . ApplicationModel ;
3031using Windows . Foundation . Metadata ;
3132using Windows . Storage ;
3233using Windows . Storage . Streams ;
@@ -117,7 +118,7 @@ public string CodeUrl
117118#if DEBUG
118119 _codeUrl = value ;
119120#else
120- var regex = new Regex ( "^https://github.com/Microsoft /WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)" ) ;
121+ var regex = new Regex ( "^https://github.com/windows-toolkit /WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)" ) ;
121122 var docMatch = regex . Match ( value ) ;
122123
123124 var branch = string . Empty ;
@@ -134,7 +135,8 @@ public string CodeUrl
134135 }
135136 else
136137 {
137- _codeUrl = $ "https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/{ path } ";
138+ var packageVersion = Package . Current . Id . Version . ToFormattedString ( 3 ) ;
139+ _codeUrl = $ "https://github.com/Microsoft/WindowsCommunityToolkit/tree/rel/{ packageVersion } /{ path } ";
138140 }
139141#endif
140142 }
@@ -668,7 +670,7 @@ private static async Task<string> GetDocsSHA()
668670 {
669671 try
670672 {
671- var branchEndpoint = "https://api.github.com/repos/microsoftdocs/uwpcommunitytoolkitdocs /git/refs/heads/live" ;
673+ var branchEndpoint = "https://api.github.com/repos/microsoftdocs/windowscommunitytoolkitdocs /git/refs/heads/live" ;
672674
673675 var request = new HttpRequestMessage ( HttpMethod . Get , branchEndpoint ) ;
674676 request . Headers . Add ( "User-Agent" , "Windows Community Toolkit Sample App" ) ;
Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System ;
56using Windows . ApplicationModel ;
67
78namespace Microsoft . Toolkit . Uwp . Helpers
@@ -15,10 +16,28 @@ public static class PackageVersionHelper
1516 /// Returns a string representation of a version with the format 'Major.Minor.Build.Revision'.
1617 /// </summary>
1718 /// <param name="packageVersion">The <see cref="PackageVersion"/> to convert to a string</param>
19+ /// <param name="significance">The number of version numbers to return, default is 4 for the full version number.</param>
1820 /// <returns>Version string of the format 'Major.Minor.Build.Revision'</returns>
19- public static string ToFormattedString ( this PackageVersion packageVersion )
21+ /// <example>
22+ /// Package.Current.Id.Version.ToFormattedString(2); // Returns "7.0" for instance.
23+ /// </example>
24+ public static string ToFormattedString ( this PackageVersion packageVersion , int significance = 4 )
2025 {
21- return $ "{ packageVersion . Major } .{ packageVersion . Minor } .{ packageVersion . Build } .{ packageVersion . Revision } ";
26+ switch ( significance )
27+ {
28+ case 4 :
29+ return $ "{ packageVersion . Major } .{ packageVersion . Minor } .{ packageVersion . Build } .{ packageVersion . Revision } ";
30+ case 3 :
31+ return $ "{ packageVersion . Major } .{ packageVersion . Minor } .{ packageVersion . Build } ";
32+ case 2 :
33+ return $ "{ packageVersion . Major } .{ packageVersion . Minor } ";
34+ case 1 :
35+ return $ "{ packageVersion . Major } ";
36+ }
37+
38+ static string ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( significance ) , "Value must be a value 1 through 4." ) ;
39+
40+ return ThrowArgumentOutOfRangeException ( ) ;
2241 }
2342
2443 /// <summary>
You can’t perform that action at this time.
0 commit comments