Skip to content

Commit

Permalink
Merge pull request #167 from DHancock/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DHancock authored Jan 25, 2025
2 parents d2ecf8c + 86ae4f5 commit 3aca833
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CsWin32Lib/CsWin32Lib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
Expand Down
18 changes: 4 additions & 14 deletions WinAppSdkCleaner/Models/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,26 @@ public static VersionRecord CategorizePackageVersion(SdkId sdkId, PackageVersion
return new VersionRecord(string.Empty, string.Empty, sdkId, packageVersion);
}

private static void AddDependents(Dictionary<string, PackageData> lookUpTable, IEnumerable<Package> allPackages)
private static void AddDependents(Dictionary<string, PackageData> sdkFrameworksLookUpTable, IEnumerable<Package> allPackages)
{
object lockObject = new object();
Dictionary<string, PackageData> subLookUp = new Dictionary<string, PackageData>();
Lock lockObject = new();

Parallel.ForEach(allPackages, package =>
{
foreach (Package dependency in package.Dependencies)
{
// TryGetValue() is thread safe as long as the dictionary isn't modified by another thread
if (lookUpTable.TryGetValue(dependency.Id.FullName, out PackageData? parentPackageRecord))
if (sdkFrameworksLookUpTable.TryGetValue(dependency.Id.FullName, out PackageData? parentPackageRecord))
{
lock (lockObject)
{
PackageData dependentPackage = new PackageData(package, new List<PackageData>());
parentPackageRecord!.PackagesDependentOnThis.Add(dependentPackage);

if (package.IsFramework)
{
subLookUp[package.Id.FullName] = dependentPackage;
}
Debug.Assert(!package.IsFramework); // framework packages cannot be dependent on other framework packages
}
}
}
});

if (subLookUp.Count > 0)
{
AddDependents(subLookUp, allPackages);
}
}

public static async Task<IEnumerable<SdkData>> GetSDKsAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0-windows10.0.17763.0\publish\win-arm64\</PublishDir>
<PublishDir>bin\Release\net9.0-windows10.0.17763.0\publish\win-arm64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0-windows10.0.17763.0\publish\win-x64\</PublishDir>
<PublishDir>bin\Release\net9.0-windows10.0.17763.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0-windows10.0.17763.0\publish\win-x86\</PublishDir>
<PublishDir>bin\Release\net9.0-windows10.0.17763.0\publish\win-x86\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
Expand Down
24 changes: 12 additions & 12 deletions WinAppSdkCleaner/Views/ViewTraceListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

internal sealed partial class ViewTraceListener : TraceListener
{
private readonly object lockObject = new object();
private StringBuilder? store = null;
private TextBox? Consumer { get; set; }
private readonly Lock lockObject = new();
private StringBuilder? store;
private TextBox? consumer;

public ViewTraceListener() : base(nameof(ViewTraceListener))
{
Expand All @@ -14,9 +14,9 @@ public void RegisterConsumer(TextBox textBox)
{
lock (lockObject)
{
Debug.Assert(Consumer is null && textBox.IsInitialized);
Debug.Assert(consumer is null && textBox.IsInitialized);

Consumer = textBox;
consumer = textBox;

if (store is not null)
{
Expand All @@ -38,7 +38,7 @@ private void WriteInternal(string message)

try
{
if (Consumer is null)
if (consumer is null)
{
if (store is null)
{
Expand All @@ -54,20 +54,20 @@ private void WriteInternal(string message)
}
else
{
Consumer.Dispatcher.BeginInvoke(() =>
consumer.Dispatcher.BeginInvoke(() =>
{
int selectionStart = Consumer.SelectionStart;
int selectionLength = Consumer.SelectionLength;
int selectionStart = consumer.SelectionStart;
int selectionLength = consumer.SelectionLength;

Consumer.Text += message;
consumer.Text += message;

if (selectionLength > 0)
{
Consumer.Select(selectionStart, selectionLength);
consumer.Select(selectionStart, selectionLength);
}
else
{
Consumer.CaretIndex = Consumer.Text.Length;
consumer.CaretIndex = consumer.Text.Length;
}
},
DispatcherPriority.Background);
Expand Down
2 changes: 1 addition & 1 deletion WinAppSdkCleaner/WinAppSdkCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
Expand Down

0 comments on commit 3aca833

Please sign in to comment.