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

[Dev][Build] .NET 8 Upgrade #1968

Merged
merged 34 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fbcf7af
[Dev] Update TFM references to .NET 8
snickler Nov 28, 2023
d0d04f8
[Dev] Update RuntimeIdentifiers to use win-
snickler Nov 28, 2023
150bfe2
[Dev] Add RuntimeIdentifiers to Test projects
snickler Nov 28, 2023
c9d67d5
[Dev] Update Nuget packages to .NET 8 version
snickler Nov 28, 2023
2fc57bd
[Dev] Update CSWinRT and Microsoft.Windows.SDK.BuildTools to latest
snickler Nov 28, 2023
ee42133
[Dev][Analyzers] Use ArgumentNullException.ThrowIfNull to satisfy CA1510
snickler Nov 28, 2023
78118ce
[Dev][Analyzers] Use static SHA256 HashData method to satisfy CA1850
snickler Nov 28, 2023
90e2f3d
[Dev][Analyzers] Use TryGetValue to satisfy CA1854
snickler Nov 28, 2023
5cb2bce
[Dev][Analyzers] Compare Count to 0 instead of using Any to satisfy C…
snickler Nov 28, 2023
a17fbde
[Dev][Analyzers] Use TryAdd to satisfy CA1864
snickler Nov 28, 2023
d084804
[Dev][Analyzers] Remove guard around ContainsKey to satisfy CA1853
snickler Nov 28, 2023
26fbbc4
[Dev][Analyzers] Satisfy CA1869
snickler Nov 28, 2023
7f72e12
Fix comment issue
snickler Nov 28, 2023
d57edb0
[Dev][Analyzers] Use new collection initializers and fix new()
snickler Nov 28, 2023
5158063
[Dev][Analyzers] Sealed classes to satisfy CA1852
snickler Nov 28, 2023
def9bf9
[DEV][Analyzers] Suppress CA1861
snickler Nov 28, 2023
e09efa3
[Dev] Update to latest CSWin32 package and resolve issues.
snickler Nov 28, 2023
1f8d060
[Dev][Analyzers] Another CA1860 fix
snickler Nov 28, 2023
95835cf
[Dev] Resolve issues with PInvoke
snickler Nov 28, 2023
1ed2574
Merge branch 'microsoft:main' into user/snickler/net8-upgrade
snickler Nov 30, 2023
70fa8be
Add RuntimeIdentifiers to DevHome.SDK.Lib
snickler Nov 30, 2023
6282bbe
[Dev] Add UseRidGraph flag to workaround RID issues with packages
snickler Dec 1, 2023
c749cd2
Merge branch 'main' into user/snickler/net8-upgrade
snickler Dec 1, 2023
6be9b3c
Remove whitespace
snickler Dec 1, 2023
d2c9a3b
[Dev] Added comment to explain workaround for RID graph issue in .NET 8
snickler Dec 1, 2023
a246648
Merge branch 'microsoft:main' into user/snickler/net8-upgrade
snickler Dec 7, 2023
737c5d9
Merge branch 'main' into user/snickler/net8-upgrade
snickler Jan 11, 2024
eacc125
Merge branch 'microsoft:main' into user/snickler/net8-upgrade
snickler Jan 12, 2024
5286f24
[Deps] Update Microsoft.Management.Infrastructure to 3.0.0
snickler Jan 12, 2024
3ebfe11
[SetupFlow] Fix regression with IPCSetup
snickler Jan 13, 2024
c11033e
[TelemetryEvents] Fix SHA256 hashing caused by merge conflict
snickler Jan 13, 2024
8d52dc8
Migrated the rest of of the Newtonsoft.Json references to System.Text…
snickler Jan 13, 2024
e163264
Merge branch 'main' into user/snickler/net8-upgrade
EricJohnson327 Jan 17, 2024
c8a6d34
Update tfm back to .NET 8 in ToolVersion.props
snickler Jan 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/DevHome-CI.yml
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 Expand Up @@ -77,11 +77,11 @@ jobs:

- name: DevHome UnitTests
if: ${{ matrix.platform != 'arm64' }}
run: cmd /c "$env:VSDevTestCmd" /Platform:${{ matrix.platform }} test\\bin\\${{ matrix.platform }}\\${{ matrix.configuration }}\\net6.0-windows10.0.22000.0\\DevHome.Test.dll
run: cmd /c "$env:VSDevTestCmd" /Platform:${{ matrix.platform }} test\\bin\\${{ matrix.platform }}\\${{ matrix.configuration }}\\net8.0-windows10.0.22000.0\\DevHome.Test.dll

- name: Tools UnitTests
if: ${{ matrix.platform != 'arm64' }}
run: |
foreach ($UnitTestPath in (Get-ChildItem "tools\\*\\*UnitTest\\bin\\${{ matrix.platform }}\\${{ matrix.configuration }}\\net6.0-windows10.0.22000.0\\*.UnitTest.dll")) {
foreach ($UnitTestPath in (Get-ChildItem "tools\\*\\*UnitTest\\bin\\${{ matrix.platform }}\\${{ matrix.configuration }}\\net8.0-windows10.0.22000.0\\*.UnitTest.dll")) {
cmd /c "$env:VSDevTestCmd" /Platform:${{ matrix.platform }} $UnitTestPath.FullName
}
6 changes: 3 additions & 3 deletions CoreWidgetProvider/CoreWidgetProvider.csproj
Expand Up @@ -12,16 +12,16 @@
<Nullable>enable</Nullable>
<CsWinRTEnabled>false</CsWinRTEnabled>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfileFullPath Condition="'$(BuildingInsideVisualStudio)' != 'True'">$(SolutionDir)\src\Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfileFullPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.206-beta">
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="7.0.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 8 additions & 3 deletions CoreWidgetProvider/Helpers/CPUStats.cs
Expand Up @@ -5,15 +5,15 @@

namespace CoreWidgetProvider.Helpers;

internal class CPUStats : IDisposable
internal sealed class CPUStats : IDisposable
{
// CPU counters
private readonly PerformanceCounter procPerf = new ("Processor Information", "% Processor Utility", "_Total");
private readonly PerformanceCounter procPerformance = new ("Processor Information", "% Processor Performance", "_Total");
private readonly PerformanceCounter procFrequency = new ("Processor Information", "Processor Frequency", "_Total");
private readonly Dictionary<Process, PerformanceCounter> cpuCounters = new ();

internal class ProcessStats
internal sealed class ProcessStats
{
public Process? Process { get; set; }

Expand All @@ -31,7 +31,12 @@ internal class ProcessStats
public CPUStats()
{
CpuUsage = 0;
ProcessCPUStats = new ProcessStats[3] { new ProcessStats(), new ProcessStats(), new ProcessStats() };
ProcessCPUStats =
[
new ProcessStats(),
new ProcessStats(),
new ProcessStats()
];

InitCPUPerfCounters();
}
Expand Down
2 changes: 1 addition & 1 deletion CoreWidgetProvider/Helpers/ChartHelper.cs
Expand Up @@ -7,7 +7,7 @@

namespace CoreWidgetProvider.Helpers;

internal class ChartHelper
internal sealed class ChartHelper
{
public enum ChartType
{
Expand Down
2 changes: 1 addition & 1 deletion CoreWidgetProvider/Helpers/DataManager.cs
Expand Up @@ -5,7 +5,7 @@

namespace CoreWidgetProvider.Helpers;

internal class DataManager : IDisposable
internal sealed class DataManager : IDisposable
{
private readonly SystemData systemData;
private readonly DataType dataType;
Expand Down
11 changes: 6 additions & 5 deletions CoreWidgetProvider/Helpers/GPUStats.cs
Expand Up @@ -7,14 +7,14 @@

namespace CoreWidgetProvider.Helpers;

internal class GPUStats : IDisposable
internal sealed class GPUStats : IDisposable
{
// GPU counters
private readonly Dictionary<int, List<PerformanceCounter>> gpuCounters = new ();

private readonly List<Data> stats = new ();

public class Data
public sealed class Data
{
public string? Name { get; set; }

Expand Down Expand Up @@ -79,12 +79,13 @@ public void GetGPUPerfCounters()
continue;
}

if (!gpuCounters.ContainsKey(phys))
if (!gpuCounters.TryGetValue(phys, out var value))
{
gpuCounters.Add(phys, new ());
value = new ();
gpuCounters.Add(phys, value);
}

gpuCounters[phys].Add(counter);
value.Add(counter);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions CoreWidgetProvider/Helpers/IconLoader.cs
Expand Up @@ -10,13 +10,14 @@ public class IconLoader
public static string GetIconAsBase64(string filename)
{
Log.Logger()?.ReportDebug(nameof(IconLoader), $"Asking for icon: {filename}");
if (!Base64ImageRegistry.ContainsKey(filename))
if (!Base64ImageRegistry.TryGetValue(filename, out var value))
{
Base64ImageRegistry.Add(filename, ConvertIconToDataString(filename));
value = ConvertIconToDataString(filename);
Base64ImageRegistry.Add(filename, value);
Log.Logger()?.ReportDebug(nameof(IconLoader), $"The icon {filename} was converted and is now stored.");
}

return Base64ImageRegistry[filename];
return value;
}

private static string ConvertIconToDataString(string fileName)
Expand Down
2 changes: 1 addition & 1 deletion CoreWidgetProvider/Helpers/MemoryStats.cs
Expand Up @@ -7,7 +7,7 @@

namespace CoreWidgetProvider.Helpers;

internal class MemoryStats : IDisposable
internal sealed class MemoryStats : IDisposable
{
private readonly PerformanceCounter memCommitted = new ("Memory", "Committed Bytes", string.Empty);
private readonly PerformanceCounter memCached = new ("Memory", "Cache Bytes", string.Empty);
Expand Down
8 changes: 4 additions & 4 deletions CoreWidgetProvider/Helpers/NetworkStats.cs
Expand Up @@ -5,15 +5,15 @@

namespace CoreWidgetProvider.Helpers;

internal class NetworkStats : IDisposable
internal sealed class NetworkStats : IDisposable
{
private readonly Dictionary<string, List<PerformanceCounter>> networkCounters = new ();

private Dictionary<string, Data> NetworkUsages { get; set; } = new Dictionary<string, Data>();

private Dictionary<string, List<float>> NetChartValues { get; set; } = new Dictionary<string, List<float>>();

public class Data
public sealed class Data
{
public float Usage
{
Expand Down Expand Up @@ -114,12 +114,12 @@ public Data GetNetworkUsage(int networkIndex)
}

var currNetworkName = NetChartValues.ElementAt(networkIndex).Key;
if (!NetworkUsages.ContainsKey(currNetworkName))
if (!NetworkUsages.TryGetValue(currNetworkName, out var value))
{
return new Data();
}

return NetworkUsages[currNetworkName];
return value;
}

public int GetPrevNetworkIndex(int networkIndex)
Expand Down
6 changes: 3 additions & 3 deletions CoreWidgetProvider/Helpers/Resources.cs
Expand Up @@ -51,8 +51,8 @@ public static string ReplaceIdentifers(string str, string[] resourceIdentifiers,
// These are all the string identifiers that appear in widgets.
public static string[] GetWidgetResourceIdentifiers()
{
return new string[]
{
return
[
"Widget_Template/Loading",
"Widget_Template_Tooltip/Submit",
"SSH_Widget_Template/Name",
Expand Down Expand Up @@ -89,6 +89,6 @@ public static string[] GetWidgetResourceIdentifiers()
"CPUUsage_Widget_Template/End_Process",
"Widget_Template_Button/Save",
"Widget_Template_Button/Cancel",
};
];
}
}
2 changes: 1 addition & 1 deletion CoreWidgetProvider/Helpers/SystemData.cs
Expand Up @@ -3,7 +3,7 @@

namespace CoreWidgetProvider.Helpers;

internal class SystemData : IDisposable
internal sealed class SystemData : IDisposable
{
public static MemoryStats MemStats { get; set; } = new MemoryStats();

Expand Down
4 changes: 2 additions & 2 deletions CoreWidgetProvider/Widgets/CoreWidget.cs
Expand Up @@ -125,10 +125,10 @@ public virtual string GetData(WidgetPageState page)

protected string GetTemplateForPage(WidgetPageState page)
{
if (Template.ContainsKey(page))
if (Template.TryGetValue(page, out var value))
{
Log.Logger()?.ReportDebug(Name, ShortId, $"Using cached template for {page}");
return Template[page];
return value;
}

try
Expand Down
12 changes: 6 additions & 6 deletions CoreWidgetProvider/Widgets/SSHWalletWidget.cs
Expand Up @@ -13,17 +13,17 @@

namespace CoreWidgetProvider.Widgets;

internal class SSHWalletWidget : CoreWidget
internal sealed class SSHWalletWidget : CoreWidget
{
protected static readonly string DefaultConfigFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\.ssh\\config";
private static readonly string DefaultConfigFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\.ssh\\config";

private static readonly Regex HostRegex = new (@"^Host\s+(\S*)\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);

private FileSystemWatcher? FileWatcher { get; set; }

protected static readonly new string Name = nameof(SSHWalletWidget);
private static readonly new string Name = nameof(SSHWalletWidget);

protected string ConfigFile
private string ConfigFile
{
get => State();

Expand Down Expand Up @@ -401,7 +401,7 @@ private void SetConfigure()
}
}

internal class DataPayload
internal sealed class DataPayload
{
public string? ConfigFile
{
Expand All @@ -411,6 +411,6 @@ internal class DataPayload

[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(DataPayload))]
internal partial class SourceGenerationContext : JsonSerializerContext
internal sealed partial class SourceGenerationContext : JsonSerializerContext
{
}
4 changes: 2 additions & 2 deletions CoreWidgetProvider/Widgets/SystemCPUUsageWidget.cs
Expand Up @@ -8,11 +8,11 @@
using Microsoft.Windows.Widgets.Providers;

namespace CoreWidgetProvider.Widgets;
internal class SystemCPUUsageWidget : CoreWidget, IDisposable
internal sealed class SystemCPUUsageWidget : CoreWidget, IDisposable
{
private static Dictionary<string, string> Templates { get; set; } = new ();

protected static readonly new string Name = nameof(SystemCPUUsageWidget);
private static readonly new string Name = nameof(SystemCPUUsageWidget);

private readonly DataManager dataManager;

Expand Down
4 changes: 2 additions & 2 deletions CoreWidgetProvider/Widgets/SystemGPUUsageWidget.cs
Expand Up @@ -9,11 +9,11 @@
using Microsoft.Windows.Widgets.Providers;

namespace CoreWidgetProvider.Widgets;
internal class SystemGPUUsageWidget : CoreWidget, IDisposable
internal sealed class SystemGPUUsageWidget : CoreWidget, IDisposable
{
private static Dictionary<string, string> Templates { get; set; } = new ();

protected static readonly new string Name = nameof(SystemGPUUsageWidget);
private static readonly new string Name = nameof(SystemGPUUsageWidget);

private readonly DataManager dataManager;

Expand Down
4 changes: 2 additions & 2 deletions CoreWidgetProvider/Widgets/SystemMemoryWidget.cs
Expand Up @@ -8,11 +8,11 @@

namespace CoreWidgetProvider.Widgets;

internal class SystemMemoryWidget : CoreWidget, IDisposable
internal sealed class SystemMemoryWidget : CoreWidget, IDisposable
{
private static Dictionary<string, string> Templates { get; set; } = new ();

protected static readonly new string Name = nameof(SystemMemoryWidget);
private static readonly new string Name = nameof(SystemMemoryWidget);

private readonly DataManager dataManager;

Expand Down
4 changes: 2 additions & 2 deletions CoreWidgetProvider/Widgets/SystemNetworkUsageWidget.cs
Expand Up @@ -8,13 +8,13 @@
using Microsoft.Windows.Widgets.Providers;

namespace CoreWidgetProvider.Widgets;
internal class SystemNetworkUsageWidget : CoreWidget, IDisposable
internal sealed class SystemNetworkUsageWidget : CoreWidget, IDisposable
{
private static Dictionary<string, string> Templates { get; set; } = new ();

private int networkIndex;

protected static readonly new string Name = nameof(SystemNetworkUsageWidget);
private static readonly new string Name = nameof(SystemNetworkUsageWidget);

private readonly DataManager dataManager;

Expand Down
2 changes: 1 addition & 1 deletion CoreWidgetProvider/Widgets/WidgetImplFactory.cs
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Windows.Widgets.Providers;

namespace CoreWidgetProvider.Widgets;
internal class WidgetImplFactory<T> : IWidgetImplFactory
internal sealed class WidgetImplFactory<T> : IWidgetImplFactory
where T : WidgetImpl, new()
{
public WidgetImpl Create(WidgetContext widgetContext, string state)
Expand Down