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 27
27
using Microsoft . Toolkit . Uwp . UI . Controls ;
28
28
using Microsoft . Toolkit . Uwp . UI . Media ;
29
29
using Microsoft . UI . Xaml ;
30
+ using Windows . ApplicationModel ;
30
31
using Windows . Foundation . Metadata ;
31
32
using Windows . Storage ;
32
33
using Windows . Storage . Streams ;
@@ -117,7 +118,7 @@ public string CodeUrl
117
118
#if DEBUG
118
119
_codeUrl = value ;
119
120
#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>.*)" ) ;
121
122
var docMatch = regex . Match ( value ) ;
122
123
123
124
var branch = string . Empty ;
@@ -134,7 +135,8 @@ public string CodeUrl
134
135
}
135
136
else
136
137
{
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 } ";
138
140
}
139
141
#endif
140
142
}
@@ -668,7 +670,7 @@ private static async Task<string> GetDocsSHA()
668
670
{
669
671
try
670
672
{
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" ;
672
674
673
675
var request = new HttpRequestMessage ( HttpMethod . Get , branchEndpoint ) ;
674
676
request . Headers . Add ( "User-Agent" , "Windows Community Toolkit Sample App" ) ;
Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System ;
5
6
using Windows . ApplicationModel ;
6
7
7
8
namespace Microsoft . Toolkit . Uwp . Helpers
@@ -15,10 +16,28 @@ public static class PackageVersionHelper
15
16
/// Returns a string representation of a version with the format 'Major.Minor.Build.Revision'.
16
17
/// </summary>
17
18
/// <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>
18
20
/// <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 )
20
25
{
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 ( ) ;
22
41
}
23
42
24
43
/// <summary>
You can’t perform that action at this time.
0 commit comments