Skip to content

Commit

Permalink
Ensure stable order of ‘Set-ItemProperty’ calls for desktop icons
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneegans committed Jan 30, 2025
1 parent 1309501 commit c84a423
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,18 @@ public class DesktopIcon(
string id,
string displayName,
string guid
) : IKeyed
) : IKeyed, IComparable<DesktopIcon>
{
public string Id { get; } = id;

public string DisplayName { get; } = displayName;

public string Guid { get; } = guid;

public int CompareTo(DesktopIcon? other)
{
return Id.CompareTo(other?.Id);
}
}

public class TimeOffset(
Expand Down
13 changes: 10 additions & 3 deletions modifier/Optimizations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -112,9 +113,15 @@ public interface IDesktopIconSettings;

public record class DefaultDesktopIconSettings : IDesktopIconSettings;

public record class CustomDesktopIconSettings(
ImmutableDictionary<DesktopIcon, bool> Settings
) : IDesktopIconSettings;
public record class CustomDesktopIconSettings : IDesktopIconSettings
{
public CustomDesktopIconSettings(IDictionary<DesktopIcon, bool> settings)
{
Settings = ImmutableSortedDictionary.CreateRange(settings);
}

public ImmutableSortedDictionary<DesktopIcon, bool> Settings { get; init; }
}

class OptimizationsModifier(ModifierContext context) : Modifier(context)
{
Expand Down

0 comments on commit c84a423

Please sign in to comment.