Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to .NET 8 #411

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/GitHubExt-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@
</PackageReference>
</ItemGroup>

<!-- Needed for reverting back to pre-.NET 8 method of Host using the RID graph to determine assets
This is due to a change in how the RuntimeIdentifier graph was changed in .NET 8. Without this, any assets from
NuGet packages that are targeting win10-* won't get picked up and referenced prooperly. -->
<!-- https://learn.microsoft.com/en-us/dotnet/core/compatibility/deployment/8.0/rid-asset-list -->
<PropertyGroup>
<UseRidGraph>true</UseRidGraph>
</PropertyGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions GitHubExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ToolingVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE-CODE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Client/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 5 additions & 5 deletions src/GitHubExtension/DataManager/GitHubDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Repository> GetRepositories()
Expand Down Expand Up @@ -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}");
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/DataModel/DataObjects/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static IEnumerable<Repository> 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}");
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/DeveloperId/LoginUI/EndPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace GitHubExtension.DeveloperId.LoginUI;

internal class EndPage : LoginUIPage
internal sealed class EndPage : LoginUIPage
{
public EndPage()
: base(LoginUIState.End)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand All @@ -40,15 +40,15 @@ public string GetJson()
}
}

internal class ActionPayload : SubmitActionPayload
internal sealed class ActionPayload : SubmitActionPayload
{
public string? URL
{
get; set;
}
}

internal class InputPayload
internal sealed class InputPayload
{
public string? PAT
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand All @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DeveloperId/LoginUI/LoginFailedPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

namespace GitHubExtension.DeveloperId.LoginUI;

internal class LoginFailedPage : LoginUIPage
internal sealed class LoginFailedPage : LoginUIPage
{
public LoginFailedPage()
: base(LoginUIState.LoginFailedPage)
{
Data = new LoginFailedPageData();
}

internal class LoginFailedPageData : ILoginUIPageData
internal sealed class LoginFailedPageData : ILoginUIPageData
{
public string GetJson()
{
Expand Down
6 changes: 3 additions & 3 deletions src/GitHubExtension/DeveloperId/LoginUI/LoginPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@

namespace GitHubExtension.DeveloperId.LoginUI;

internal class LoginPage : LoginUIPage
internal sealed class LoginPage : LoginUIPage
{
public LoginPage()
: base(LoginUIState.LoginPage)
{
Data = new PageData();
}

internal class PageData : ILoginUIPageData
internal sealed class PageData : ILoginUIPageData
{
public string GetJson()
{
return Json.Stringify(this);
}
}

internal class ActionPayload : SubmitActionPayload
internal sealed class ActionPayload : SubmitActionPayload
{
public bool IsEnterprise()
{
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DeveloperId/LoginUI/LoginSucceededPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GitHubExtension.DeveloperId.LoginUI;

internal class LoginSucceededPage : LoginUIPage
internal sealed class LoginSucceededPage : LoginUIPage
{
public LoginSucceededPage(IDeveloperId developerId)
: base(LoginUIState.LoginSucceededPage)
Expand All @@ -17,7 +17,7 @@ public LoginSucceededPage(IDeveloperId developerId)
};
}

internal class LoginSucceededPageData : ILoginUIPageData
internal sealed class LoginSucceededPageData : ILoginUIPageData
{
public string? Message { get; set; } = string.Empty;

Expand Down
5 changes: 1 addition & 4 deletions src/GitHubExtension/DeveloperId/LoginUI/LoginUIPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DeveloperId/LoginUI/WaitingPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

namespace GitHubExtension.DeveloperId.LoginUI;

internal class WaitingPage : LoginUIPage
internal sealed class WaitingPage : LoginUIPage
{
public WaitingPage()
: base(LoginUIState.WaitingPage)
{
Data = new WaitingPageData();
}

internal class WaitingPageData : ILoginUIPageData
internal sealed class WaitingPageData : ILoginUIPageData
{
public string GetJson()
{
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DeveloperId/OAuthRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace GitHubExtension.DeveloperId;

internal class OAuthRequest : IDisposable
internal sealed class OAuthRequest : IDisposable
{
private static readonly Lazy<ILogger> _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(OAuthRequest)));

Expand All @@ -33,7 +33,7 @@ internal OAuthRequest()
State = string.Empty;
}

protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Helpers/IconData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace GitHubExtension.Helpers;

internal class IconData
internal sealed class IconData
{
public const string AssignedWidgetTitleIconData =
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwS" +
Expand Down
3 changes: 1 addition & 2 deletions src/GitHubExtension/Helpers/IconLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand Down
23 changes: 9 additions & 14 deletions src/GitHubExtension/Helpers/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> ToObjectAsync<T>(string value)
{
if (typeof(T) == typeof(bool))
Expand Down Expand Up @@ -42,14 +49,7 @@ public static string Stringify<T>(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<T>(string json)
Expand All @@ -59,11 +59,6 @@ public static string Stringify<T>(T value)
return (T)(object)bool.Parse(json);
}

return System.Text.Json.JsonSerializer.Deserialize<T>(json, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
IncludeFields = true,
});
return System.Text.Json.JsonSerializer.Deserialize<T>(json, _options);
}
}
4 changes: 2 additions & 2 deletions src/GitHubExtension/Helpers/LocalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object>? _settings;
private static Dictionary<string, object>? _settings;

private static async Task InitializeAsync()
{
Expand All @@ -23,7 +23,7 @@ private static async Task InitializeAsync()
}
else
{
_settings = await Task.Run(() => FileHelper.Read<IDictionary<string, object>>(_applicationDataFolder, _localSettingsFile)) ?? new Dictionary<string, object>();
_settings = await Task.Run(() => FileHelper.Read<Dictionary<string, object>>(_applicationDataFolder, _localSettingsFile)) ?? new Dictionary<string, object>();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Helpers/TimeSpanHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GitHubExtension.Helpers;

internal class TimeSpanHelper
internal sealed class TimeSpanHelper
{
public static string TimeSpanToDisplayString(TimeSpan timeSpan, ILogger? log = null)
{
Expand Down
Loading
Loading