Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 8298c31

Browse files
Merge pull request #383 from microsoft/staging
Release - 4/23/24
2 parents ad208ab + d73afd7 commit 8298c31

116 files changed

Lines changed: 999 additions & 2274 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GitHubExtension.sln

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{A371
4040
EndProject
4141
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitHubExtension.Test", "test\GitHubExtension\GitHubExtension.Test.csproj", "{D8EFDB34-7019-4807-AE97-1B50891F345D}"
4242
EndProject
43-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Logging", "src\Logging\DevHome.Logging.csproj", "{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}"
44-
EndProject
4543
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E4D6AB24-08F6-4352-9BB8-8E92148DA618}"
4644
ProjectSection(SolutionItems) = preProject
4745
test\scripts\CleanDevHome.ps1 = test\scripts\CleanDevHome.ps1
@@ -195,26 +193,6 @@ Global
195193
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x64.Build.0 = Release|x64
196194
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x86.ActiveCfg = Release|x86
197195
{D8EFDB34-7019-4807-AE97-1B50891F345D}.Release|x86.Build.0 = Release|x86
198-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|Any CPU.ActiveCfg = Debug|x64
199-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|Any CPU.Build.0 = Debug|x64
200-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|ARM.ActiveCfg = Debug|x64
201-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|ARM.Build.0 = Debug|x64
202-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|arm64.ActiveCfg = Debug|arm64
203-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|arm64.Build.0 = Debug|arm64
204-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x64.ActiveCfg = Debug|x64
205-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x64.Build.0 = Debug|x64
206-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x86.ActiveCfg = Debug|x86
207-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Debug|x86.Build.0 = Debug|x86
208-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|Any CPU.ActiveCfg = Release|x64
209-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|Any CPU.Build.0 = Release|x64
210-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|ARM.ActiveCfg = Release|x64
211-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|ARM.Build.0 = Release|x64
212-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|arm64.ActiveCfg = Release|arm64
213-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|arm64.Build.0 = Release|arm64
214-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x64.ActiveCfg = Release|x64
215-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x64.Build.0 = Release|x64
216-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x86.ActiveCfg = Release|x86
217-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB}.Release|x86.Build.0 = Release|x86
218196
EndGlobalSection
219197
GlobalSection(SolutionProperties) = preSolution
220198
HideSolutionNode = FALSE
@@ -227,7 +205,6 @@ Global
227205
{8E1764CB-2FFC-4F23-9FC0-BDE84E519319} = {5BDF2709-4299-49C3-B971-B10747F2925D}
228206
{A371A158-E88C-48D1-9397-22844DDC2EF4} = {10E87373-ADA7-408F-9879-0F6BF101BE87}
229207
{D8EFDB34-7019-4807-AE97-1B50891F345D} = {429CEDBA-88C4-4315-9EA1-50AB6DF8855C}
230-
{FEEEDA62-F746-4160-A3A8-1EE74137F8AB} = {5BDF2709-4299-49C3-B971-B10747F2925D}
231208
{E4D6AB24-08F6-4352-9BB8-8E92148DA618} = {429CEDBA-88C4-4315-9EA1-50AB6DF8855C}
232209
EndGlobalSection
233210
GlobalSection(ExtensibilityGlobals) = postSolution

build/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ parameters:
2020
- release
2121

2222
variables:
23-
MSIXVersion: '0.1200'
23+
MSIXVersion: '0.1300'
2424
solution: '**/GitHubExtension.sln'
2525
appxPackageDir: 'AppxPackages'
2626
testOutputArtifactDir: 'TestResults'

build/scripts/CreateBuildInfo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Param(
55
)
66

77
$Major = "0"
8-
$Minor = "12"
8+
$Minor = "13"
99
$Patch = "99" # default to 99 for local builds
1010

1111
$versionSplit = $Version.Split(".");

src/GitHubExtension/Client/GithubClientProvider.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using DevHome.Logging.Helpers;
54
using GitHubExtension.DeveloperId;
65
using Microsoft.Windows.DevHome.SDK;
76
using Octokit;
7+
using Serilog;
88

99
namespace GitHubExtension.Client;
1010

1111
public class GitHubClientProvider
1212
{
13+
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubClientProvider)));
14+
15+
private static readonly ILogger Log = _log.Value;
16+
1317
private readonly GitHubClient publicRepoClient;
1418

1519
private static readonly object InstanceLock = new();
@@ -66,18 +70,18 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
6670
GitHubClient client;
6771
if (devIds == null || !devIds.Any())
6872
{
69-
Log.Logger()?.ReportInfo($"No logged in developer, using public GitHub client.");
73+
Log.Information($"No logged in developer, using public GitHub client.");
7074
client = Instance.GetClient();
7175
}
7276
else
7377
{
74-
Log.Logger()?.ReportInfo($"Using authenticated user: {devIds.First().LoginId}");
78+
Log.Information($"Using authenticated user: {devIds.First().LoginId}");
7579
client = devIds.First().GitHubClient;
7680
}
7781

7882
if (client == null)
7983
{
80-
Log.Logger()?.ReportError($"Failed creating GitHubClient.");
84+
Log.Error($"Failed creating GitHubClient.");
8185
return client!;
8286
}
8387

@@ -86,11 +90,11 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
8690
try
8791
{
8892
var miscRateLimit = await client.RateLimit.GetRateLimits();
89-
Log.Logger()?.ReportInfo($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset.ToStringInvariant()}");
93+
Log.Information($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset}");
9094
}
9195
catch (Exception ex)
9296
{
93-
Log.Logger()?.ReportError($"Rate limiting not enabled for server.", ex);
97+
Log.Error(ex, $"Rate limiting not enabled for server.");
9498
}
9599
}
96100

src/GitHubExtension/Client/Validation.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33

44
using GitHubExtension.DataModel;
55
using Octokit;
6+
using Serilog;
67

78
namespace GitHubExtension.Client;
89

910
// Validation layer to help parsing GitHub URL.
1011
public static class Validation
1112
{
13+
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(Validation)));
14+
15+
private static readonly ILogger Log = _log.Value;
16+
1217
private static bool IsValidHttpUri(string uriString, out Uri? uri)
1318
{
1419
return Uri.TryCreate(uriString, UriKind.Absolute, out uri) &&
@@ -17,15 +22,15 @@ private static bool IsValidHttpUri(string uriString, out Uri? uri)
1722

1823
public static bool IsValidGitHubURL(Uri uri)
1924
{
20-
return IsValidGitHubComURL(uri) || IsValidGitHubEnterpriseServerURL(uri);
25+
return IsValidGitHubComURL(uri) || (IsValidGitHubEnterpriseServerURL(uri) && IsReachableGitHubEnterpriseServerURL(uri).Result);
2126
}
2227

2328
public static bool IsValidGitHubComURL(Uri uri)
2429
{
2530
// Valid GitHub URL has three segments. The first is '/'.
2631
if (uri.Segments.Length < 3 || (!uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase) && !uri.Host.Equals("www.github.com", StringComparison.OrdinalIgnoreCase)))
2732
{
28-
Log.Logger()?.ReportDebug($"{uri.OriginalString} is not a valid GitHub uri");
33+
Log.Debug($"{uri.OriginalString} is not a valid GitHub uri");
2934
return false;
3035
}
3136

@@ -39,7 +44,7 @@ public static bool IsValidGitHubEnterpriseServerURL(Uri server)
3944
// https://docs.github.com/en/enterprise-server@3.10/admin/configuration/configuring-network-settings/configuring-the-hostname-for-your-instance
4045
if (server.Segments.Length < 3)
4146
{
42-
Log.Logger()?.ReportDebug($"{server.OriginalString} is not a valid GHES repo uri");
47+
Log.Debug($"{server.OriginalString} is not a valid GHES repo uri");
4348
return false;
4449
}
4550

@@ -56,7 +61,7 @@ public static bool IsValidGitHubURL(string url)
5661
// Above link shows a work around.
5762
if (!IsValidHttpUri(url, out parsedUri) || url == null || parsedUri == null)
5863
{
59-
Log.Logger()?.ReportDebug($"{url} is not a valid http uri");
64+
Log.Debug($"{url} is not a valid http uri");
6065
return false;
6166
}
6267

@@ -227,13 +232,13 @@ public static async Task<bool> IsReachableGitHubEnterpriseServerURL(Uri server)
227232
var probeResult = await new EnterpriseProbe(new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME)).Probe(server);
228233
if (probeResult != EnterpriseProbeResult.Ok)
229234
{
230-
Log.Logger()?.ReportError($"EnterpriseServer {server.AbsoluteUri} is not reachable");
235+
Log.Error($"EnterpriseServer {server.AbsoluteUri} is not reachable");
231236
return false;
232237
}
233238
}
234239
catch (Exception ex)
235240
{
236-
Log.Logger()?.ReportError($"EnterpriseServer {server.AbsoluteUri} could not be probed.", ex);
241+
Log.Error(ex, $"EnterpriseServer {server.AbsoluteUri} could not be probed.");
237242
return false;
238243
}
239244

src/GitHubExtension/DataManager/DataUpdater.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using Serilog;
5+
46
namespace GitHubExtension.DataManager;
57

68
public class DataUpdater : IDisposable
79
{
810
// This is the default interval the timer will run. It is not the interval that we necessarily do work.
911
private static readonly TimeSpan TimerUpdateInterval = TimeSpan.FromSeconds(5);
1012

13+
private readonly ILogger _logger;
1114
private readonly PeriodicTimer _timer;
1215
private readonly Func<Task> _action;
1316
private CancellationTokenSource _cancelSource;
@@ -17,6 +20,7 @@ public class DataUpdater : IDisposable
1720

1821
public DataUpdater(TimeSpan interval, Func<Task> action)
1922
{
23+
_logger = Log.Logger.ForContext("SourceContext", nameof(DataUpdater));
2024
_timer = new PeriodicTimer(interval);
2125
_cancelSource = new CancellationTokenSource();
2226
_started = false;
@@ -64,7 +68,7 @@ protected virtual void Dispose(bool disposing)
6468
{
6569
if (!disposed)
6670
{
67-
DataModel.Log.Logger()?.ReportDebug(ToString(), "Disposing of all Disposable resources.");
71+
_logger.Debug("Disposing of all updater resources.");
6872

6973
if (disposing)
7074
{

0 commit comments

Comments
 (0)