From d4bf58c93593683ddffa05fbca8e3fc43f932140 Mon Sep 17 00:00:00 2001 From: Kristen Schau <47155823+krschau@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:41:17 -0400 Subject: [PATCH 1/9] Upgrading to .NET 8 (#411) * Add to solution items * Specify .net8 * Changes to comply with .net8 rules --- .github/workflows/GitHubExt-CI.yml | 2 +- Directory.Build.props | 10 ++++++ GitHubExtension.sln | 2 ++ ToolingVersions.props | 2 +- src/GitHubExtension/Client/Validation.cs | 2 +- src/GitHubExtension/Constants.cs | 2 +- .../DataManager/GitHubDataManager.cs | 10 +++--- .../DataModel/DataObjects/Repository.cs | 2 +- .../DeveloperId/LoginUI/EndPage.cs | 2 +- .../LoginUI/EnterpriseServerPATPage.cs | 8 ++--- .../LoginUI/EnterpriseServerPage.cs | 8 ++--- .../DeveloperId/LoginUI/LoginFailedPage.cs | 4 +-- .../DeveloperId/LoginUI/LoginPage.cs | 6 ++-- .../DeveloperId/LoginUI/LoginSucceededPage.cs | 4 +-- .../DeveloperId/LoginUI/LoginUIPage.cs | 5 +-- .../DeveloperId/LoginUI/WaitingPage.cs | 4 +-- .../DeveloperId/OAuthRequest.cs | 4 +-- src/GitHubExtension/Helpers/IconData.cs | 2 +- src/GitHubExtension/Helpers/IconLoader.cs | 3 +- src/GitHubExtension/Helpers/Json.cs | 23 ++++++------- src/GitHubExtension/Helpers/LocalSettings.cs | 4 +-- src/GitHubExtension/Helpers/TimeSpanHelper.cs | 2 +- .../Notifications/NotificationHandler.cs | 6 ++-- .../Providers/SettingsUIController.cs | 4 +-- .../Widgets/GitHubAssignedWidget.cs | 4 +-- .../Widgets/GitHubIssuesWidget.cs | 2 +- .../Widgets/GitHubMentionedInWidget.cs | 2 +- .../Widgets/GitHubPullsWidget.cs | 2 +- .../Widgets/GitHubReleasesWidget.cs | 4 +-- .../Widgets/GitHubReviewWidget.cs | 2 +- src/GitHubExtension/Widgets/GitHubWidget.cs | 8 ++--- .../Widgets/WidgetImplFactory.cs | 2 +- src/GitHubExtension/Widgets/WidgetProvider.cs | 32 +++++++++---------- src/GitHubExtension/Widgets/WidgetServer.cs | 2 +- src/Telemetry/Logger.cs | 2 +- 35 files changed, 92 insertions(+), 91 deletions(-) diff --git a/.github/workflows/GitHubExt-CI.yml b/.github/workflows/GitHubExt-CI.yml index a4420bf6..2c4b2c42 100644 --- a/.github/workflows/GitHubExt-CI.yml +++ b/.github/workflows/GitHubExt-CI.yml @@ -15,7 +15,7 @@ jobs: configuration: [Release, Debug] platform: [x64, x86, arm64] os: [windows-latest] - dotnet-version: ['6.0.x'] + dotnet-version: ['8.0.x'] exclude: - configuration: Debug platform: x64 diff --git a/Directory.Build.props b/Directory.Build.props index e293c534..c6c3307e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,4 +45,14 @@ + + + + true + + + + \ No newline at end of file diff --git a/GitHubExtension.sln b/GitHubExtension.sln index 77241d75..d7be8017 100644 --- a/GitHubExtension.sln +++ b/GitHubExtension.sln @@ -49,7 +49,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{864DD9CD-9F45-47E8-847F-B72ED182626B}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + Directory.Build.props = Directory.Build.props exclusion.dic = exclusion.dic + ToolingVersions.props = ToolingVersions.props EndProjectSection EndProject Global diff --git a/ToolingVersions.props b/ToolingVersions.props index b6c8d340..f4a87568 100644 --- a/ToolingVersions.props +++ b/ToolingVersions.props @@ -2,7 +2,7 @@ - net6.0-windows10.0.22000.0 + net8.0-windows10.0.22000.0 10.0.19041.0 10.0.19041.0 diff --git a/src/GitHubExtension/Client/Validation.cs b/src/GitHubExtension/Client/Validation.cs index b57963f6..fcb4ef5b 100644 --- a/src/GitHubExtension/Client/Validation.cs +++ b/src/GitHubExtension/Client/Validation.cs @@ -213,7 +213,7 @@ private static string AddProtocolToString(string s) private static string[]? GetNameAndRepoFromFullName(string s) { - var n = s.Split(new[] { '/' }); + var n = s.Split(['/']); // This should be exactly two results with no empty strings. if (n.Length != 2 || string.IsNullOrEmpty(n[0]) || string.IsNullOrEmpty(n[1])) diff --git a/src/GitHubExtension/Constants.cs b/src/GitHubExtension/Constants.cs index 3728442f..579cb7c3 100644 --- a/src/GitHubExtension/Constants.cs +++ b/src/GitHubExtension/Constants.cs @@ -3,7 +3,7 @@ namespace GitHubExtension; -internal class Constants +internal sealed class Constants { #pragma warning disable SA1310 // Field names should not contain underscore public const string DEV_HOME_APPLICATION_NAME = "DevHome"; diff --git a/src/GitHubExtension/DataManager/GitHubDataManager.cs b/src/GitHubExtension/DataManager/GitHubDataManager.cs index 5562a1c1..170e42af 100644 --- a/src/GitHubExtension/DataManager/GitHubDataManager.cs +++ b/src/GitHubExtension/DataManager/GitHubDataManager.cs @@ -104,7 +104,7 @@ await UpdateDataForRepositoryAsync( await UpdatePullRequestsAsync(repository, devId.GitHubClient, parameters.RequestOptions); }); - SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), new string[] { "Issues", "PullRequests" }); + SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), ["Issues", "PullRequests"]); } public async Task UpdateAllDataForRepositoryAsync(string fullName, RequestOptions? options = null) @@ -133,7 +133,7 @@ await UpdateDataForRepositoryAsync( await UpdatePullRequestsAsync(repository, devId.GitHubClient, parameters.RequestOptions); }); - SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), new string[] { "PullRequests" }); + SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), ["PullRequests"]); } public async Task UpdatePullRequestsForRepositoryAsync(string fullName, RequestOptions? options = null) @@ -162,7 +162,7 @@ await UpdateDataForRepositoryAsync( await UpdateIssuesAsync(repository, devId.GitHubClient, parameters.RequestOptions); }); - SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), new string[] { "Issues" }); + SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), ["Issues"]); } public async Task UpdateIssuesForRepositoryAsync(string fullName, RequestOptions? options = null) @@ -202,7 +202,7 @@ await UpdateDataForRepositoryAsync( await UpdateReleasesAsync(repository, devId.GitHubClient, parameters.RequestOptions); }); - SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), new string[] { "Releases" }); + SendRepositoryUpdateEvent(this, GetFullNameFromOwnerAndRepository(owner, name), ["Releases"]); } public IEnumerable GetRepositories() @@ -788,7 +788,7 @@ private void SetLastUpdatedInMetaData() // Converts fullName -> owner, name. private string[] GetOwnerAndRepositoryNameFromFullName(string fullName) { - var nameSplit = fullName.Split(new[] { '/' }); + var nameSplit = fullName.Split(['/']); if (nameSplit.Length != 2 || string.IsNullOrEmpty(nameSplit[0]) || string.IsNullOrEmpty(nameSplit[1])) { _log.Error($"Invalid repository full name: {fullName}"); diff --git a/src/GitHubExtension/DataModel/DataObjects/Repository.cs b/src/GitHubExtension/DataModel/DataObjects/Repository.cs index 46b6d9fa..e7cf0fae 100644 --- a/src/GitHubExtension/DataModel/DataObjects/Repository.cs +++ b/src/GitHubExtension/DataModel/DataObjects/Repository.cs @@ -274,7 +274,7 @@ public static IEnumerable GetAll(DataStore dataStore) public static Repository? Get(DataStore dataStore, string fullName) { - var nameSplit = fullName.Split(new[] { '/' }, 2); + var nameSplit = fullName.Split(['/'], 2); if (nameSplit.Length != 2) { _log.Warning($"Invalid fullName input into Repository.Get: {fullName}"); diff --git a/src/GitHubExtension/DeveloperId/LoginUI/EndPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/EndPage.cs index 51234cc6..8a3cb35d 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/EndPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/EndPage.cs @@ -3,7 +3,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class EndPage : LoginUIPage +internal sealed class EndPage : LoginUIPage { public EndPage() : base(LoginUIState.End) diff --git a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs index df6f4da0..8c80e28b 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs @@ -6,7 +6,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class EnterpriseServerPATPage : LoginUIPage +internal sealed class EnterpriseServerPATPage : LoginUIPage { public EnterpriseServerPATPage(Uri hostAddress, string errorText, SecureString inputPAT) : base(LoginUIState.EnterpriseServerPATPage) @@ -22,7 +22,7 @@ public EnterpriseServerPATPage(Uri hostAddress, string errorText, SecureString i }; } - internal class PageData : ILoginUIPageData + internal sealed class PageData : ILoginUIPageData { public string EnterpriseServerPATPageInputValue { get; set; } = string.Empty; @@ -40,7 +40,7 @@ public string GetJson() } } - internal class ActionPayload : SubmitActionPayload + internal sealed class ActionPayload : SubmitActionPayload { public string? URL { @@ -48,7 +48,7 @@ public string? URL } } - internal class InputPayload + internal sealed class InputPayload { public string? PAT { diff --git a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs index bc6842b2..b5e09908 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs @@ -5,7 +5,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class EnterpriseServerPage : LoginUIPage +internal sealed class EnterpriseServerPage : LoginUIPage { public EnterpriseServerPage(Uri? hostAddress, string errorText) : base(LoginUIState.EnterpriseServerPage) @@ -29,7 +29,7 @@ public EnterpriseServerPage(string hostAddress, string errorText) }; } - internal class PageData : ILoginUIPageData + internal sealed class PageData : ILoginUIPageData { public string EnterpriseServerInputValue { get; set; } = string.Empty; @@ -44,11 +44,11 @@ public string GetJson() } } - internal class ActionPayload : SubmitActionPayload + internal sealed class ActionPayload : SubmitActionPayload { } - internal class InputPayload + internal sealed class InputPayload { public string? EnterpriseServer { diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs index a8144102..cda9985b 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs @@ -5,7 +5,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class LoginFailedPage : LoginUIPage +internal sealed class LoginFailedPage : LoginUIPage { public LoginFailedPage() : base(LoginUIState.LoginFailedPage) @@ -13,7 +13,7 @@ public LoginFailedPage() Data = new LoginFailedPageData(); } - internal class LoginFailedPageData : ILoginUIPageData + internal sealed class LoginFailedPageData : ILoginUIPageData { public string GetJson() { diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs index 688ec225..53b542a0 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs @@ -5,7 +5,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class LoginPage : LoginUIPage +internal sealed class LoginPage : LoginUIPage { public LoginPage() : base(LoginUIState.LoginPage) @@ -13,7 +13,7 @@ public LoginPage() Data = new PageData(); } - internal class PageData : ILoginUIPageData + internal sealed class PageData : ILoginUIPageData { public string GetJson() { @@ -21,7 +21,7 @@ public string GetJson() } } - internal class ActionPayload : SubmitActionPayload + internal sealed class ActionPayload : SubmitActionPayload { public bool IsEnterprise() { diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs index 5ef03649..511c1789 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs @@ -6,7 +6,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class LoginSucceededPage : LoginUIPage +internal sealed class LoginSucceededPage : LoginUIPage { public LoginSucceededPage(IDeveloperId developerId) : base(LoginUIState.LoginSucceededPage) @@ -17,7 +17,7 @@ public LoginSucceededPage(IDeveloperId developerId) }; } - internal class LoginSucceededPageData : ILoginUIPageData + internal sealed class LoginSucceededPageData : ILoginUIPageData { public string? Message { get; set; } = string.Empty; diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs index d6fe7453..063cee7d 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs @@ -31,10 +31,7 @@ public LoginUIPage(LoginUIState state) public ProviderOperationResult UpdateExtensionAdaptiveCard(IExtensionAdaptiveCard adaptiveCard) { - if (adaptiveCard == null) - { - throw new ArgumentNullException(nameof(adaptiveCard)); - } + ArgumentNullException.ThrowIfNull(adaptiveCard); return adaptiveCard.Update(_template, _data?.GetJson(), Enum.GetName(typeof(LoginUIState), _state)); } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs index 19739c8b..d03a5925 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs @@ -5,7 +5,7 @@ namespace GitHubExtension.DeveloperId.LoginUI; -internal class WaitingPage : LoginUIPage +internal sealed class WaitingPage : LoginUIPage { public WaitingPage() : base(LoginUIState.WaitingPage) @@ -13,7 +13,7 @@ public WaitingPage() Data = new WaitingPageData(); } - internal class WaitingPageData : ILoginUIPageData + internal sealed class WaitingPageData : ILoginUIPageData { public string GetJson() { diff --git a/src/GitHubExtension/DeveloperId/OAuthRequest.cs b/src/GitHubExtension/DeveloperId/OAuthRequest.cs index 4f1351e1..4c757af8 100644 --- a/src/GitHubExtension/DeveloperId/OAuthRequest.cs +++ b/src/GitHubExtension/DeveloperId/OAuthRequest.cs @@ -11,7 +11,7 @@ namespace GitHubExtension.DeveloperId; -internal class OAuthRequest : IDisposable +internal sealed class OAuthRequest : IDisposable { private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(OAuthRequest))); @@ -33,7 +33,7 @@ internal OAuthRequest() State = string.Empty; } - protected virtual void Dispose(bool disposing) + private void Dispose(bool disposing) { if (disposing) { diff --git a/src/GitHubExtension/Helpers/IconData.cs b/src/GitHubExtension/Helpers/IconData.cs index 011fa1cc..0249dd1a 100644 --- a/src/GitHubExtension/Helpers/IconData.cs +++ b/src/GitHubExtension/Helpers/IconData.cs @@ -3,7 +3,7 @@ namespace GitHubExtension.Helpers; -internal class IconData +internal sealed class IconData { public const string AssignedWidgetTitleIconData = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwS" + diff --git a/src/GitHubExtension/Helpers/IconLoader.cs b/src/GitHubExtension/Helpers/IconLoader.cs index d98014b5..a032b023 100644 --- a/src/GitHubExtension/Helpers/IconLoader.cs +++ b/src/GitHubExtension/Helpers/IconLoader.cs @@ -13,9 +13,8 @@ public static string GetIconAsBase64(string filename) { var log = Log.ForContext("SourceContext", nameof(IconLoader)); log.Verbose($"Asking for icon: {filename}"); - if (!_base64ImageRegistry.ContainsKey(filename)) + if (!_base64ImageRegistry.TryAdd(filename, ConvertIconToDataString(filename))) { - _base64ImageRegistry.Add(filename, ConvertIconToDataString(filename)); log.Verbose($"The icon {filename} was converted and is now stored."); } diff --git a/src/GitHubExtension/Helpers/Json.cs b/src/GitHubExtension/Helpers/Json.cs index 314d3a9a..eff1433e 100644 --- a/src/GitHubExtension/Helpers/Json.cs +++ b/src/GitHubExtension/Helpers/Json.cs @@ -9,6 +9,13 @@ namespace GitHubExtension.Helpers; public static class Json { + private static readonly JsonSerializerOptions _options = new() + { + PropertyNameCaseInsensitive = true, + DefaultIgnoreCondition = JsonIgnoreCondition.Never, + IncludeFields = true, + }; + public static async Task ToObjectAsync(string value) { if (typeof(T) == typeof(bool)) @@ -42,14 +49,7 @@ public static string Stringify(T value) return value!.ToString()!.ToLowerInvariant(); } - return System.Text.Json.JsonSerializer.Serialize( - value, - new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true, - DefaultIgnoreCondition = JsonIgnoreCondition.Never, - IncludeFields = true, - }); + return System.Text.Json.JsonSerializer.Serialize(value, _options); } public static T? ToObject(string json) @@ -59,11 +59,6 @@ public static string Stringify(T value) return (T)(object)bool.Parse(json); } - return System.Text.Json.JsonSerializer.Deserialize(json, new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true, - DefaultIgnoreCondition = JsonIgnoreCondition.Never, - IncludeFields = true, - }); + return System.Text.Json.JsonSerializer.Deserialize(json, _options); } } diff --git a/src/GitHubExtension/Helpers/LocalSettings.cs b/src/GitHubExtension/Helpers/LocalSettings.cs index 76563412..542f0252 100644 --- a/src/GitHubExtension/Helpers/LocalSettings.cs +++ b/src/GitHubExtension/Helpers/LocalSettings.cs @@ -11,7 +11,7 @@ public static class LocalSettings private static readonly string _applicationDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DevHome/ApplicationData"); private static readonly string _localSettingsFile = "LocalSettings.json"; - private static IDictionary? _settings; + private static Dictionary? _settings; private static async Task InitializeAsync() { @@ -23,7 +23,7 @@ private static async Task InitializeAsync() } else { - _settings = await Task.Run(() => FileHelper.Read>(_applicationDataFolder, _localSettingsFile)) ?? new Dictionary(); + _settings = await Task.Run(() => FileHelper.Read>(_applicationDataFolder, _localSettingsFile)) ?? new Dictionary(); } } } diff --git a/src/GitHubExtension/Helpers/TimeSpanHelper.cs b/src/GitHubExtension/Helpers/TimeSpanHelper.cs index 2bd628be..4498ef30 100644 --- a/src/GitHubExtension/Helpers/TimeSpanHelper.cs +++ b/src/GitHubExtension/Helpers/TimeSpanHelper.cs @@ -6,7 +6,7 @@ namespace GitHubExtension.Helpers; -internal class TimeSpanHelper +internal sealed class TimeSpanHelper { public static string TimeSpanToDisplayString(TimeSpan timeSpan, ILogger? log = null) { diff --git a/src/GitHubExtension/Notifications/NotificationHandler.cs b/src/GitHubExtension/Notifications/NotificationHandler.cs index a233bf6d..a646195f 100644 --- a/src/GitHubExtension/Notifications/NotificationHandler.cs +++ b/src/GitHubExtension/Notifications/NotificationHandler.cs @@ -24,13 +24,13 @@ public static void NotificationActivation(AppNotificationActivatedEventArgs args { _log.Information($"Notification Activated with args: {NotificationArgsToString(args)}"); - if (args.Arguments.ContainsKey("htmlurl")) + if (args.Arguments.TryGetValue("htmlurl", out var htmlUrl)) { try { // Do not assume this string is a safe URL and blindly execute it; verify that it is // in fact a valid GitHub URL. - var urlString = args.Arguments["htmlurl"]; + var urlString = htmlUrl; if (!Validation.IsValidGitHubURL(urlString)) { throw new InvalidGitHubUrlException($"{urlString} is invalid."); @@ -47,7 +47,7 @@ public static void NotificationActivation(AppNotificationActivatedEventArgs args } catch (Exception ex) { - _log.Error(ex, $"Failed launching Uri for {args.Arguments["htmlurl"]}"); + _log.Error(ex, $"Failed launching Uri for {htmlUrl}"); } return; diff --git a/src/GitHubExtension/Providers/SettingsUIController.cs b/src/GitHubExtension/Providers/SettingsUIController.cs index e27ea9b7..dc222576 100644 --- a/src/GitHubExtension/Providers/SettingsUIController.cs +++ b/src/GitHubExtension/Providers/SettingsUIController.cs @@ -9,7 +9,7 @@ namespace GitHubExtension.Providers; -internal class SettingsUIController : IExtensionAdaptiveCardSession +internal sealed class SettingsUIController : IExtensionAdaptiveCardSession { private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(RepositoryProvider))); @@ -68,7 +68,7 @@ public IAsyncOperation OnAction(string action, string i } // Adaptive Card Templates for SettingsUI. - private class SettingsUITemplate + private sealed class SettingsUITemplate { internal string GetSettingsUITemplate() { diff --git a/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs b/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs index 95b45e5f..bec74d91 100644 --- a/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubAssignedWidget.cs @@ -6,10 +6,8 @@ namespace GitHubExtension.Widgets; -internal class GitHubAssignedWidget : GitHubUserWidget +internal sealed class GitHubAssignedWidget : GitHubUserWidget { - protected static readonly new string Name = nameof(GitHubAssignedWidget); - protected override string GetTitleIconData() { return IconData.AssignedWidgetTitleIconData; diff --git a/src/GitHubExtension/Widgets/GitHubIssuesWidget.cs b/src/GitHubExtension/Widgets/GitHubIssuesWidget.cs index 551bb11b..7d895e6b 100644 --- a/src/GitHubExtension/Widgets/GitHubIssuesWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubIssuesWidget.cs @@ -10,7 +10,7 @@ namespace GitHubExtension.Widgets; -internal class GitHubIssuesWidget : GitHubRepositoryWidget +internal sealed class GitHubIssuesWidget : GitHubRepositoryWidget { private readonly string _issuesIconData = IconLoader.GetIconAsBase64("issues.png"); diff --git a/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs b/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs index a1ab5ec9..087ef8c9 100644 --- a/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs @@ -6,7 +6,7 @@ namespace GitHubExtension.Widgets; -internal class GitHubMentionedInWidget : GitHubUserWidget +internal sealed class GitHubMentionedInWidget : GitHubUserWidget { protected override string GetTitleIconData() { diff --git a/src/GitHubExtension/Widgets/GitHubPullsWidget.cs b/src/GitHubExtension/Widgets/GitHubPullsWidget.cs index e6794555..fad9d23e 100644 --- a/src/GitHubExtension/Widgets/GitHubPullsWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubPullsWidget.cs @@ -10,7 +10,7 @@ namespace GitHubExtension.Widgets; -internal class GitHubPullsWidget : GitHubRepositoryWidget +internal sealed class GitHubPullsWidget : GitHubRepositoryWidget { private readonly string _pullsIconData = IconLoader.GetIconAsBase64("pulls.png"); diff --git a/src/GitHubExtension/Widgets/GitHubReleasesWidget.cs b/src/GitHubExtension/Widgets/GitHubReleasesWidget.cs index 6d061d2c..5b3d708e 100644 --- a/src/GitHubExtension/Widgets/GitHubReleasesWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubReleasesWidget.cs @@ -9,7 +9,7 @@ namespace GitHubExtension.Widgets; -internal class GitHubReleasesWidget : GitHubRepositoryWidget +internal sealed class GitHubReleasesWidget : GitHubRepositoryWidget { private readonly string _releasesIconData = IconLoader.GetIconAsBase64("releases.png"); @@ -121,7 +121,7 @@ public override void LoadContentData() releasesData.Add("releases", releasesArray); releasesData.Add("selected_repo", repository?.FullName ?? string.Empty); - releasesData.Add("widgetTitle", WidgetTitle); + releasesData.Add("widgetTitle", WidgetTitle); releasesData.Add("is_loading_data", DataState == WidgetDataState.Unknown); releasesData.Add("releases_icon_data", _releasesIconData); diff --git a/src/GitHubExtension/Widgets/GitHubReviewWidget.cs b/src/GitHubExtension/Widgets/GitHubReviewWidget.cs index bc96b303..7a5c00aa 100644 --- a/src/GitHubExtension/Widgets/GitHubReviewWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubReviewWidget.cs @@ -9,7 +9,7 @@ namespace GitHubExtension.Widgets; -internal class GitHubReviewWidget : GitHubUserWidget +internal sealed class GitHubReviewWidget : GitHubUserWidget { public GitHubReviewWidget() : base() diff --git a/src/GitHubExtension/Widgets/GitHubWidget.cs b/src/GitHubExtension/Widgets/GitHubWidget.cs index 12344089..09dba00d 100644 --- a/src/GitHubExtension/Widgets/GitHubWidget.cs +++ b/src/GitHubExtension/Widgets/GitHubWidget.cs @@ -79,7 +79,7 @@ public override void CreateWidget(WidgetContext widgetContext, string state) // If there is a state, it is being retrieved from the widget service, so // this widget was pinned before. - if (state.Any()) + if (state.Length != 0) { ResetWidgetInfoFromState(); Saved = true; @@ -207,7 +207,7 @@ public string GetSignIn() public bool IsUserLoggedIn() { - IDeveloperIdProvider authProvider = DeveloperIdProvider.GetInstance(); + var authProvider = DeveloperIdProvider.GetInstance(); return authProvider.GetLoggedInDeveloperIds().DeveloperIds.Any(); } @@ -261,10 +261,10 @@ public virtual string GetData(WidgetPageState page) protected string GetTemplateForPage(WidgetPageState page) { - if (Template.ContainsKey(page)) + if (Template.TryGetValue(page, out var pageTemplate)) { Log.Debug($"Using cached template for {page}"); - return Template[page]; + return pageTemplate; } try diff --git a/src/GitHubExtension/Widgets/WidgetImplFactory.cs b/src/GitHubExtension/Widgets/WidgetImplFactory.cs index 661ec1e5..eb229c67 100644 --- a/src/GitHubExtension/Widgets/WidgetImplFactory.cs +++ b/src/GitHubExtension/Widgets/WidgetImplFactory.cs @@ -7,7 +7,7 @@ namespace GitHubExtension.Widgets; [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Templated class")] -internal class WidgetImplFactory : IWidgetImplFactory +internal sealed class WidgetImplFactory : IWidgetImplFactory where T : WidgetImpl, new() { public WidgetImpl Create(WidgetContext widgetContext, string state) diff --git a/src/GitHubExtension/Widgets/WidgetProvider.cs b/src/GitHubExtension/Widgets/WidgetProvider.cs index 964a60ae..bec71210 100644 --- a/src/GitHubExtension/Widgets/WidgetProvider.cs +++ b/src/GitHubExtension/Widgets/WidgetProvider.cs @@ -34,11 +34,11 @@ private void InitializeWidget(WidgetContext widgetContext, string state) var widgetId = widgetContext.Id; var widgetDefinitionId = widgetContext.DefinitionId; _log.Verbose($"Calling Initialize for Widget Id: {widgetId} - {widgetDefinitionId}"); - if (_widgetDefinitionRegistry.ContainsKey(widgetDefinitionId)) + if (_widgetDefinitionRegistry.TryGetValue(widgetDefinitionId, out var widgetDefinition)) { if (!_runningWidgets.ContainsKey(widgetId)) { - var factory = _widgetDefinitionRegistry[widgetDefinitionId]; + var factory = widgetDefinition; var widgetImpl = factory.Create(widgetContext, state); _runningWidgets.Add(widgetId, widgetImpl); } @@ -93,18 +93,18 @@ public void Activate(WidgetContext widgetContext) { _log.Verbose($"Activate id: {widgetContext.Id} definitionId: {widgetContext.DefinitionId}"); var widgetId = widgetContext.Id; - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].Activate(widgetContext); + widget.Activate(widgetContext); } else { // Called to activate a widget that we don't know about, which is unexpected. Try to recover by creating it. _log.Warning($"Found WidgetId that was not known: {widgetContext.Id}, attempting to recover by creating it."); CreateWidget(widgetContext); - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var newWidget)) { - _runningWidgets[widgetId].Activate(widgetContext); + newWidget.Activate(widgetContext); } } } @@ -112,18 +112,18 @@ public void Activate(WidgetContext widgetContext) public void Deactivate(string widgetId) { _log.Verbose($"Deactivate id: {widgetId}"); - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].Deactivate(widgetId); + widget.Deactivate(widgetId); } } public void DeleteWidget(string widgetId, string customState) { _log.Information($"DeleteWidget id: {widgetId}"); - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].DeleteWidget(widgetId, customState); + widget.DeleteWidget(widgetId, customState); _runningWidgets.Remove(widgetId); } } @@ -133,9 +133,9 @@ public void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs) _log.Debug($"OnActionInvoked id: {actionInvokedArgs.WidgetContext.Id} definitionId: {actionInvokedArgs.WidgetContext.DefinitionId}"); var widgetContext = actionInvokedArgs.WidgetContext; var widgetId = widgetContext.Id; - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].OnActionInvoked(actionInvokedArgs); + widget.OnActionInvoked(actionInvokedArgs); } } @@ -144,9 +144,9 @@ public void OnCustomizationRequested(WidgetCustomizationRequestedArgs customizat _log.Debug($"OnCustomizationRequested id: {customizationRequestedArgs.WidgetContext.Id} definitionId: {customizationRequestedArgs.WidgetContext.DefinitionId}"); var widgetContext = customizationRequestedArgs.WidgetContext; var widgetId = widgetContext.Id; - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].OnCustomizationRequested(customizationRequestedArgs); + widget.OnCustomizationRequested(customizationRequestedArgs); } } @@ -155,9 +155,9 @@ public void OnWidgetContextChanged(WidgetContextChangedArgs contextChangedArgs) _log.Debug($"OnWidgetContextChanged id: {contextChangedArgs.WidgetContext.Id} definitionId: {contextChangedArgs.WidgetContext.DefinitionId}"); var widgetContext = contextChangedArgs.WidgetContext; var widgetId = widgetContext.Id; - if (_runningWidgets.ContainsKey(widgetId)) + if (_runningWidgets.TryGetValue(widgetId, out var widget)) { - _runningWidgets[widgetId].OnWidgetContextChanged(contextChangedArgs); + widget.OnWidgetContextChanged(contextChangedArgs); } } } diff --git a/src/GitHubExtension/Widgets/WidgetServer.cs b/src/GitHubExtension/Widgets/WidgetServer.cs index 59790e84..27f22005 100644 --- a/src/GitHubExtension/Widgets/WidgetServer.cs +++ b/src/GitHubExtension/Widgets/WidgetServer.cs @@ -65,7 +65,7 @@ public void Dispose() } } - private class Ole32 + private sealed class Ole32 { #pragma warning disable SA1310 // Field names should not contain underscore // https://docs.microsoft.com/windows/win32/api/wtypesbase/ne-wtypesbase-clsctx diff --git a/src/Telemetry/Logger.cs b/src/Telemetry/Logger.cs index 51883644..9c334c73 100644 --- a/src/Telemetry/Logger.cs +++ b/src/Telemetry/Logger.cs @@ -12,7 +12,7 @@ namespace GitHubExtension.Telemetry; -internal class Logger : ILogger +internal sealed class Logger : ILogger { private const string ProviderName = "Microsoft.GitHubExtension"; From b14a0efb00e942b0c5c84746bf0cf78a7197d48e Mon Sep 17 00:00:00 2001 From: Matt Hyman Date: Wed, 17 Jul 2024 10:32:43 -0700 Subject: [PATCH 2/9] Fix program method logic. (#417) --- src/GitHubExtensionServer/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GitHubExtensionServer/Program.cs b/src/GitHubExtensionServer/Program.cs index 0e99d467..7f3d734d 100644 --- a/src/GitHubExtensionServer/Program.cs +++ b/src/GitHubExtensionServer/Program.cs @@ -14,7 +14,7 @@ namespace GitHubExtension; public sealed class Program { [MTAThread] - public static void Main([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray] string[] args) + public static async Task Main([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray] string[] args) { // Setup Logging Environment.SetEnvironmentVariable("DEVHOME_LOGS_ROOT", ApplicationData.Current.TemporaryFolder.Path); @@ -38,7 +38,7 @@ public static void Main([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyA if (!mainInstance.IsCurrent) { Log.Information($"Not main instance, redirecting."); - mainInstance.RedirectActivationToAsync(activationArgs).AsTask().Wait(); + await mainInstance.RedirectActivationToAsync(activationArgs); notificationManager.Unregister(); Log.CloseAndFlush(); return; @@ -74,7 +74,7 @@ private static void AppActivationRedirected(object? sender, Microsoft.Windows.Ap var d = activationArgs.Data as ILaunchActivatedEventArgs; var args = d?.Arguments.Split(); - if (args?.Length > 0 && args[1] == "-RegisterProcessAsComServer") + if (args?.Length > 1 && args[1] == "-RegisterProcessAsComServer") { Log.Information($"Activation COM Registration Redirect: {string.Join(' ', args.ToList())}"); HandleCOMServerActivation(); From 276e9c41d5f4512729aef126faae7bb704ae4a67 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Tue, 23 Jul 2024 10:40:00 -0700 Subject: [PATCH 3/9] Fix duplicate classIDs for different builds (#418) * Fix duplicate classIDs for different builds * Fix duplicate classIDs for different builds --- build/azure-pipelines.yml | 2 +- build/scripts/Build.ps1 | 64 +--- build/scripts/CreateBuildInfo.ps1 | 2 +- src/GitHubExtension/GitHubExtension.cs | 6 + src/GitHubExtension/Widgets/WidgetProvider.cs | 6 + .../GitHubExtensionServer.csproj | 18 ++ .../Package-Can.appxmanifest | 294 ++++++++++++++++++ .../Package-Dev.appxmanifest | 294 ++++++++++++++++++ .../Package.appxmanifest | 10 +- 9 files changed, 628 insertions(+), 68 deletions(-) create mode 100644 src/GitHubExtensionServer/Package-Can.appxmanifest create mode 100644 src/GitHubExtensionServer/Package-Dev.appxmanifest diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index f30f3881..953f00d1 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -20,7 +20,7 @@ parameters: - release variables: - MSIXVersion: '0.1600' + MSIXVersion: '0.1700' solution: '**/GitHubExtension.sln' appxPackageDir: 'AppxPackages' testOutputArtifactDir: 'TestResults' diff --git a/build/scripts/Build.ps1 b/build/scripts/Build.ps1 index dab04cdb..3e6267e6 100644 --- a/build/scripts/Build.ps1 +++ b/build/scripts/Build.ps1 @@ -86,63 +86,22 @@ $ErrorActionPreference = "Stop" Try { if (($BuildStep -ieq "all") -Or ($BuildStep -ieq "msix")) { $buildRing = "Dev" - $newPackageName = $null - $newPackageDisplayName = $null - $newAppDisplayNameResource = $null - $newWidgetProviderDisplayName = $null + $appxmanifestPath = (Join-Path $env:Build_RootDirectory "src\GitHubExtensionServer\Package-Dev.appxmanifest") if ($AzureBuildingBranch -ieq "release") { $buildRing = "Stable" - $newPackageName = "Microsoft.Windows.DevHomeGitHubExtension" - $newPackageDisplayName = "Dev Home GitHub Extension (Preview)" - $newAppDisplayNameResource = "ms-resource:AppDisplayNameStable" - $newWidgetProviderDisplayName = "ms-resource:WidgetProviderDisplayNameStable" + $appxmanifestPath = (Join-Path $env:Build_RootDirectory "src\GitHubExtensionServer\Package.appxmanifest") } elseif ($AzureBuildingBranch -ieq "staging") { $buildRing = "Canary" - $newPackageName = "Microsoft.Windows.DevHomeGitHubExtension.Canary" - $newPackageDisplayName = "Dev Home GitHub Extension (Canary)" - $newAppDisplayNameResource = "ms-resource:AppDisplayNameCanary" - $newWidgetProviderDisplayName = "ms-resource:WidgetProviderDisplayNameCanary" + $appxmanifestPath = (Join-Path $env:Build_RootDirectory "src\GitHubExtensionServer\Package-Can.appxmanifest") } [Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") $xIdentity = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity"); - $xProperties = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Properties"); - $xDisplayName = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}DisplayName"); - $xApplications = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Applications"); - $xApplication = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Application"); - $uapVisualElements = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/uap/windows10}VisualElements"); - $xExtensions = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Extensions"); - $uapExtension = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/uap/windows10/3}Extension"); - $uapAppExtension = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/uap/windows10/3}AppExtension"); # Update the appxmanifest - $appxmanifestPath = (Join-Path $env:Build_RootDirectory "src\GitHubExtensionServer\Package.appxmanifest") $appxmanifest = [System.Xml.Linq.XDocument]::Load($appxmanifestPath) $appxmanifest.Root.Element($xIdentity).Attribute("Version").Value = $env:msix_version - if (-not ([string]::IsNullOrEmpty($newPackageName))) { - $appxmanifest.Root.Element($xIdentity).Attribute("Name").Value = $newPackageName - } - if (-not ([string]::IsNullOrEmpty($newPackageDisplayName))) { - $appxmanifest.Root.Element($xProperties).Element($xDisplayName).Value = $newPackageDisplayName - } - if (-not ([string]::IsNullOrEmpty($newAppDisplayNameResource))) { - $appxmanifest.Root.Element($xApplications).Element($xApplication).Element($uapVisualElements).Attribute("DisplayName").Value = $newAppDisplayNameResource - $extensions = $appxmanifest.Root.Element($xApplications).Element($xApplication).Element($xExtensions).Elements($uapExtension) - foreach ($extension in $extensions) { - if ($extension.Attribute("Category").Value -eq "windows.appExtension") { - $appExtension = $extension.Element($uapAppExtension) - switch ($appExtension.Attribute("Name").Value) { - "com.microsoft.devhome" { - $appExtension.Attribute("DisplayName").Value = $newAppDisplayNameResource - } - "com.microsoft.windows.widgets" { - $appExtension.Attribute("DisplayName").Value = $newWidgetProviderDisplayName - } - } - } - } - } $appxmanifest.Save($appxmanifestPath) foreach ($platform in $env:Build_Platform.Split(",")) { @@ -171,23 +130,6 @@ Try { # Reset the appxmanifest to prevent unnecessary code changes $appxmanifest = [System.Xml.Linq.XDocument]::Load($appxmanifestPath) $appxmanifest.Root.Element($xIdentity).Attribute("Version").Value = "0.0.0.0" - $appxmanifest.Root.Element($xIdentity).Attribute("Name").Value = "Microsoft.Windows.DevHomeGitHubExtension.Dev" - $appxmanifest.Root.Element($xProperties).Element($xDisplayName).Value = "Dev Home GitHub Extension (Dev)" - $appxmanifest.Root.Element($xApplications).Element($xApplication).Element($uapVisualElements).Attribute("DisplayName").Value = "ms-resource:AppDisplayNameDev" - $extensions = $appxmanifest.Root.Element($xApplications).Element($xApplication).Element($xExtensions).Elements($uapExtension) - foreach ($extension in $extensions) { - if ($extension.Attribute("Category").Value -eq "windows.appExtension") { - $appExtension = $extension.Element($uapAppExtension) - switch ($appExtension.Attribute("Name").Value) { - "com.microsoft.devhome" { - $appExtension.Attribute("DisplayName").Value = "ms-resource:AppDisplayNameDev" - } - "com.microsoft.windows.widgets" { - $appExtension.Attribute("DisplayName").Value = "ms-resource:WidgetProviderDisplayNameDev" - } - } - } - } $appxmanifest.Save($appxmanifestPath) } diff --git a/build/scripts/CreateBuildInfo.ps1 b/build/scripts/CreateBuildInfo.ps1 index 02d7de18..ac0fa3a5 100644 --- a/build/scripts/CreateBuildInfo.ps1 +++ b/build/scripts/CreateBuildInfo.ps1 @@ -5,7 +5,7 @@ Param( ) $Major = "0" -$Minor = "16" +$Minor = "17" $Patch = "99" # default to 99 for local builds $versionSplit = $Version.Split("."); diff --git a/src/GitHubExtension/GitHubExtension.cs b/src/GitHubExtension/GitHubExtension.cs index fb48d023..e74ccd31 100644 --- a/src/GitHubExtension/GitHubExtension.cs +++ b/src/GitHubExtension/GitHubExtension.cs @@ -10,7 +10,13 @@ namespace GitHubExtension; [ComVisible(true)] +#if CANARY_BUILD +[Guid("7AB70F8F-3644-495C-B473-A6750AE1D547")] +#elif STABLE_BUILD [Guid("6B5F1179-B2AE-4D5E-94FC-E5E119D1B8F0")] +#else +[Guid("190B5CB2-BBAC-424E-92F8-98C7C41C1039")] +#endif [ComDefaultInterface(typeof(IExtension))] public sealed class GitHubExtension : IExtension { diff --git a/src/GitHubExtension/Widgets/WidgetProvider.cs b/src/GitHubExtension/Widgets/WidgetProvider.cs index bec71210..9ac0c86c 100644 --- a/src/GitHubExtension/Widgets/WidgetProvider.cs +++ b/src/GitHubExtension/Widgets/WidgetProvider.cs @@ -9,7 +9,13 @@ namespace GitHubExtension.Widgets; [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] +#if CANARY_BUILD +[Guid("E8778523-0D5F-478F-8AC3-1467928BDEF7")] +#elif STABLE_BUILD [Guid("F23870B0-B391-4466-84E2-42A991078613")] +#else +[Guid("3AF3462E-0CCE-4200-887B-FB41872A4EFB")] +#endif public sealed class WidgetProvider : IWidgetProvider, IWidgetProvider2 { private readonly ILogger _log = Log.ForContext("SourceContext", nameof(WidgetProvider)); diff --git a/src/GitHubExtensionServer/GitHubExtensionServer.csproj b/src/GitHubExtensionServer/GitHubExtensionServer.csproj index e9f52f69..5ff8609b 100644 --- a/src/GitHubExtensionServer/GitHubExtensionServer.csproj +++ b/src/GitHubExtensionServer/GitHubExtensionServer.csproj @@ -44,6 +44,24 @@ + + + Designer + + + + + + Designer + + + + + + Designer + + + diff --git a/src/GitHubExtensionServer/Package-Can.appxmanifest b/src/GitHubExtensionServer/Package-Can.appxmanifest new file mode 100644 index 00000000..730c73b0 --- /dev/null +++ b/src/GitHubExtensionServer/Package-Can.appxmanifest @@ -0,0 +1,294 @@ + + + + + Dev Home GitHub Extension (Can) + Microsoft Corporation + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Login to Dev Home + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/GitHubExtensionServer/Package-Dev.appxmanifest b/src/GitHubExtensionServer/Package-Dev.appxmanifest new file mode 100644 index 00000000..c351f6b1 --- /dev/null +++ b/src/GitHubExtensionServer/Package-Dev.appxmanifest @@ -0,0 +1,294 @@ + + + + + Dev Home GitHub Extension (Dev) + Microsoft Corporation + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Login to Dev Home + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/GitHubExtensionServer/Package.appxmanifest b/src/GitHubExtensionServer/Package.appxmanifest index 248dde23..7deed841 100644 --- a/src/GitHubExtensionServer/Package.appxmanifest +++ b/src/GitHubExtensionServer/Package.appxmanifest @@ -1,8 +1,8 @@  - + - Dev Home GitHub Extension (Dev) + Dev Home GitHub Extension Microsoft Corporation Assets\StoreLogo.png @@ -14,7 +14,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -65,7 +65,7 @@ - + From da9cfa6981297ec1c7c729324ee9d7b1c1c1f9fc Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Tue, 23 Jul 2024 16:13:03 -0700 Subject: [PATCH 4/9] Fix build break with bad package identity --- src/GitHubExtensionServer/Package-Can.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitHubExtensionServer/Package-Can.appxmanifest b/src/GitHubExtensionServer/Package-Can.appxmanifest index 730c73b0..6eadc853 100644 --- a/src/GitHubExtensionServer/Package-Can.appxmanifest +++ b/src/GitHubExtensionServer/Package-Can.appxmanifest @@ -1,6 +1,6 @@  - + Dev Home GitHub Extension (Can) Microsoft Corporation From efb2b86e1d1e278fe60b2bec63d0fc3292c2c82e Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Wed, 24 Jul 2024 11:09:54 -0700 Subject: [PATCH 5/9] Fix bad Canary display name --- src/GitHubExtensionServer/Package-Can.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitHubExtensionServer/Package-Can.appxmanifest b/src/GitHubExtensionServer/Package-Can.appxmanifest index 6eadc853..4f23bb3a 100644 --- a/src/GitHubExtensionServer/Package-Can.appxmanifest +++ b/src/GitHubExtensionServer/Package-Can.appxmanifest @@ -2,7 +2,7 @@ - Dev Home GitHub Extension (Can) + Dev Home GitHub Extension (Canary) Microsoft Corporation Assets\StoreLogo.png From 76921550a84edfd86745234612dbaa1fbdbd5b5a Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Tue, 30 Jul 2024 13:54:21 -0700 Subject: [PATCH 6/9] Migrate to new nuget feed (#422) --- nuget.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget.config b/nuget.config index 6285fe02..d77f366c 100644 --- a/nuget.config +++ b/nuget.config @@ -7,7 +7,7 @@ - + From 459610ef968e25f7df1b35625a76c358fbc02cdb Mon Sep 17 00:00:00 2001 From: David Bennett Date: Thu, 1 Aug 2024 09:49:06 -0700 Subject: [PATCH 7/9] Fix widget manifest localization (#423) --- .../Package-Can.appxmanifest | 46 +++++++++--------- .../Package-Dev.appxmanifest | 46 +++++++++--------- .../Package.appxmanifest | 46 +++++++++--------- .../Strings/en-us/Resources.resw | 48 +++++++++++++++++++ 4 files changed, 117 insertions(+), 69 deletions(-) diff --git a/src/GitHubExtensionServer/Package-Can.appxmanifest b/src/GitHubExtensionServer/Package-Can.appxmanifest index 4f23bb3a..6fb37d8b 100644 --- a/src/GitHubExtensionServer/Package-Can.appxmanifest +++ b/src/GitHubExtensionServer/Package-Can.appxmanifest @@ -76,7 +76,7 @@ - + @@ -90,14 +90,14 @@ - + - + @@ -105,12 +105,12 @@ - + - + @@ -124,14 +124,14 @@ - + - + @@ -139,12 +139,12 @@ - + - + @@ -158,14 +158,14 @@ - + - + @@ -173,12 +173,12 @@ - + - + @@ -192,14 +192,14 @@ - + - + @@ -207,12 +207,12 @@ - + - + @@ -226,14 +226,14 @@ - + - + @@ -241,7 +241,7 @@ - + @@ -260,14 +260,14 @@ - + - + @@ -275,7 +275,7 @@ - + diff --git a/src/GitHubExtensionServer/Package-Dev.appxmanifest b/src/GitHubExtensionServer/Package-Dev.appxmanifest index c351f6b1..92db75ba 100644 --- a/src/GitHubExtensionServer/Package-Dev.appxmanifest +++ b/src/GitHubExtensionServer/Package-Dev.appxmanifest @@ -76,7 +76,7 @@ - + @@ -90,14 +90,14 @@ - + - + @@ -105,12 +105,12 @@ - + - + @@ -124,14 +124,14 @@ - + - + @@ -139,12 +139,12 @@ - + - + @@ -158,14 +158,14 @@ - + - + @@ -173,12 +173,12 @@ - + - + @@ -192,14 +192,14 @@ - + - + @@ -207,12 +207,12 @@ - + - + @@ -226,14 +226,14 @@ - + - + @@ -241,7 +241,7 @@ - + @@ -260,14 +260,14 @@ - + - + @@ -275,7 +275,7 @@ - + diff --git a/src/GitHubExtensionServer/Package.appxmanifest b/src/GitHubExtensionServer/Package.appxmanifest index 7deed841..6895de1d 100644 --- a/src/GitHubExtensionServer/Package.appxmanifest +++ b/src/GitHubExtensionServer/Package.appxmanifest @@ -76,7 +76,7 @@ - + @@ -90,14 +90,14 @@ - + - + @@ -105,12 +105,12 @@ - + - + @@ -124,14 +124,14 @@ - + - + @@ -139,12 +139,12 @@ - + - + @@ -158,14 +158,14 @@ - + - + @@ -173,12 +173,12 @@ - + - + @@ -192,14 +192,14 @@ - + - + @@ -207,12 +207,12 @@ - + - + @@ -226,14 +226,14 @@ - + - + @@ -241,7 +241,7 @@ - + @@ -260,14 +260,14 @@ - + - + @@ -275,7 +275,7 @@ - + diff --git a/src/GitHubExtensionServer/Strings/en-us/Resources.resw b/src/GitHubExtensionServer/Strings/en-us/Resources.resw index 5de11c8c..b077678d 100644 --- a/src/GitHubExtensionServer/Strings/en-us/Resources.resw +++ b/src/GitHubExtensionServer/Strings/en-us/Resources.resw @@ -153,4 +153,52 @@ Releases Title for widget that displays the releases of a repository + + List of pull requests and issues assigned to the user in a GitHub repository. + + + List of issues in a GitHub repository. + + + List of issues and pull requests the user is mentioned in in a GitHub repository. + + + List of open pull requests in a GitHub repository. + + + List of pull requests where the user is requested for a review. + + + Assigned to me + + + Issues + + + Mentioned me + + + Pull requests + + + Review requested + + + Assigned To Me widget preview image + + + Issues widget preview image + + + Mentioned In widget preview image + + + Pull Requests widget preview image + + + Releases widget preview image + + + Review Requested widget preview image + \ No newline at end of file From ab8806e99ac56afd0775bf73f00dce621a584646 Mon Sep 17 00:00:00 2001 From: Vineeth Thomas Alex Date: Mon, 12 Aug 2024 11:44:44 -0500 Subject: [PATCH 8/9] Fix JsonSerializerOptions (#426) Co-authored-by: Vineeth Thomas Alex --- .../LoginUI/EnterpriseServerPATPage.cs | 6 ++--- .../LoginUI/EnterpriseServerPage.cs | 8 +++---- .../LoginUI/JsonSourceGenerationContext.cs | 22 +++++++++++++++++++ .../DeveloperId/LoginUI/LoginFailedPage.cs | 2 +- .../DeveloperId/LoginUI/LoginPage.cs | 6 ++--- .../DeveloperId/LoginUI/LoginSucceededPage.cs | 2 +- .../DeveloperId/LoginUI/LoginUIPage.cs | 10 +++++++++ .../DeveloperId/LoginUI/WaitingPage.cs | 2 +- src/GitHubExtension/Helpers/Json.cs | 4 ++-- 9 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 src/GitHubExtension/DeveloperId/LoginUI/JsonSourceGenerationContext.cs diff --git a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs index 8c80e28b..bd931a8a 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPATPage.cs @@ -11,7 +11,7 @@ internal sealed class EnterpriseServerPATPage : LoginUIPage public EnterpriseServerPATPage(Uri hostAddress, string errorText, SecureString inputPAT) : base(LoginUIState.EnterpriseServerPATPage) { - Data = new PageData() + Data = new EnterpriseServerPATPageData() { EnterpriseServerPATPageInputValue = new System.Net.NetworkCredential(string.Empty, inputPAT).Password ?? string.Empty, EnterpriseServerPATPageErrorValue = errorText ?? string.Empty, @@ -22,7 +22,7 @@ public EnterpriseServerPATPage(Uri hostAddress, string errorText, SecureString i }; } - internal sealed class PageData : ILoginUIPageData + internal sealed class EnterpriseServerPATPageData : ILoginUIPageData { public string EnterpriseServerPATPageInputValue { get; set; } = string.Empty; @@ -36,7 +36,7 @@ internal sealed class PageData : ILoginUIPageData public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs index b5e09908..123b3229 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/EnterpriseServerPage.cs @@ -10,7 +10,7 @@ internal sealed class EnterpriseServerPage : LoginUIPage public EnterpriseServerPage(Uri? hostAddress, string errorText) : base(LoginUIState.EnterpriseServerPage) { - Data = new PageData() + Data = new EnterpriseServerPageData() { EnterpriseServerInputValue = hostAddress?.ToString() ?? string.Empty, EnterpriseServerPageErrorValue = errorText ?? string.Empty, @@ -21,7 +21,7 @@ public EnterpriseServerPage(Uri? hostAddress, string errorText) public EnterpriseServerPage(string hostAddress, string errorText) : base(LoginUIState.EnterpriseServerPage) { - Data = new PageData() + Data = new EnterpriseServerPageData() { EnterpriseServerInputValue = hostAddress, EnterpriseServerPageErrorValue = errorText ?? string.Empty, @@ -29,7 +29,7 @@ public EnterpriseServerPage(string hostAddress, string errorText) }; } - internal sealed class PageData : ILoginUIPageData + internal sealed class EnterpriseServerPageData : ILoginUIPageData { public string EnterpriseServerInputValue { get; set; } = string.Empty; @@ -40,7 +40,7 @@ internal sealed class PageData : ILoginUIPageData public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/JsonSourceGenerationContext.cs b/src/GitHubExtension/DeveloperId/LoginUI/JsonSourceGenerationContext.cs new file mode 100644 index 00000000..618aa423 --- /dev/null +++ b/src/GitHubExtension/DeveloperId/LoginUI/JsonSourceGenerationContext.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System.Text.Json.Serialization; +using static GitHubExtension.DeveloperId.LoginUI.EnterpriseServerPage; +using static GitHubExtension.DeveloperId.LoginUI.EnterpriseServerPATPage; +using static GitHubExtension.DeveloperId.LoginUI.LoginFailedPage; +using static GitHubExtension.DeveloperId.LoginUI.LoginPage; +using static GitHubExtension.DeveloperId.LoginUI.LoginSucceededPage; +using static GitHubExtension.DeveloperId.LoginUI.WaitingPage; + +namespace GitHubExtension.DeveloperId; + +[JsonSerializable(typeof(EnterpriseServerPageData))] +[JsonSerializable(typeof(EnterpriseServerPATPageData))] +[JsonSerializable(typeof(LoginFailedPageData))] +[JsonSerializable(typeof(LoginPageData))] +[JsonSerializable(typeof(LoginSucceededPageData))] +[JsonSerializable(typeof(WaitingPageData))] +internal sealed partial class JsonSourceGenerationContext : JsonSerializerContext +{ +} diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs index cda9985b..8d3818fb 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs @@ -17,7 +17,7 @@ internal sealed class LoginFailedPageData : ILoginUIPageData { public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs index 53b542a0..54dec8eb 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs @@ -10,14 +10,14 @@ internal sealed class LoginPage : LoginUIPage public LoginPage() : base(LoginUIState.LoginPage) { - Data = new PageData(); + Data = new LoginPageData(); } - internal sealed class PageData : ILoginUIPageData + internal sealed class LoginPageData : ILoginUIPageData { public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs index 511c1789..28086182 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs @@ -23,7 +23,7 @@ internal sealed class LoginSucceededPageData : ILoginUIPageData public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } } diff --git a/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs index 063cee7d..15434800 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Text.Json; +using System.Text.Json.Serialization; using GitHubExtension.Helpers; using Microsoft.Windows.DevHome.SDK; @@ -12,6 +14,14 @@ internal class LoginUIPage private readonly LoginUIState _state; private ILoginUIPageData? _data; + public static readonly JsonSerializerOptions _optionsWithContext = new() + { + PropertyNameCaseInsensitive = true, + DefaultIgnoreCondition = JsonIgnoreCondition.Never, + IncludeFields = true, + TypeInfoResolver = JsonSourceGenerationContext.Default, + }; + public interface ILoginUIPageData { public abstract string GetJson(); diff --git a/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs b/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs index d03a5925..46bbf360 100644 --- a/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs +++ b/src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs @@ -17,7 +17,7 @@ internal sealed class WaitingPageData : ILoginUIPageData { public string GetJson() { - return Json.Stringify(this); + return Json.Stringify(this, _optionsWithContext); } } } diff --git a/src/GitHubExtension/Helpers/Json.cs b/src/GitHubExtension/Helpers/Json.cs index eff1433e..c700ad64 100644 --- a/src/GitHubExtension/Helpers/Json.cs +++ b/src/GitHubExtension/Helpers/Json.cs @@ -42,14 +42,14 @@ public static async Task StringifyAsync(T value) }); } - public static string Stringify(T value) + public static string Stringify(T value, JsonSerializerOptions? options = null) { if (typeof(T) == typeof(bool)) { return value!.ToString()!.ToLowerInvariant(); } - return System.Text.Json.JsonSerializer.Serialize(value, _options); + return System.Text.Json.JsonSerializer.Serialize(value, options ?? _options); } public static T? ToObject(string json) From 1b595b25ff2fe422e0a21cc24b3bca4c0d68d352 Mon Sep 17 00:00:00 2001 From: Vineeth Thomas Alex Date: Fri, 16 Aug 2024 14:09:06 -0500 Subject: [PATCH 9/9] Add JsonSerializerIsReflectionEnabledByDefault to props file (#431) Co-authored-by: Vineeth Thomas Alex --- Directory.Build.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index c6c3307e..3a872c8e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -55,4 +55,8 @@ + + + true + \ No newline at end of file