Skip to content

Commit

Permalink
Update FilesHashSet
Browse files Browse the repository at this point in the history
 - Fix nullability
- Use App.PathSeparatorRegex
  • Loading branch information
cooolbros committed Dec 31, 2023
1 parent c24f9f6 commit dcd5f07
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/HUDMerger/Models/FilesHashSet.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;

namespace HUDMerger.Models;

public class FilesHashSet : HashSet<string>
{
private class FilePathComparer : IEqualityComparer<string>
{
public bool Equals(string x, string y)
public bool Equals(string? x, string? y)
{
return x == Encode(y);
return x == (y != null ? Encode(y) : null);
}

public int GetHashCode([DisallowNull] string obj)
Expand All @@ -21,7 +20,7 @@ public int GetHashCode([DisallowNull] string obj)

public static string Encode(string filePath)
{
return String.Join('\\', Regex.Split(filePath, @"[/\\]+"));
return App.PathSeparatorRegex().Replace(filePath, "\\");
}
}

Expand Down

0 comments on commit dcd5f07

Please sign in to comment.