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

Natural Sort without interop #3196

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Remove old interop implementation
  • Loading branch information
christophwille committed Apr 26, 2024
commit e3ec6d8e5918edbbab22660c12cd0599706da13e
21 changes: 1 addition & 20 deletions ILSpy/TreeNodes/NaturalStringComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,16 @@

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

using NaturalSort.Extension;

namespace ICSharpCode.ILSpy.TreeNodes
{
/// <summary>
/// .NET natural string comparison emulating .Instance behavior of original native-interop variant
/// .NET natural string comparison
/// </summary>
public sealed class NaturalStringComparer
{
public static readonly IComparer<string> Instance = StringComparison.CurrentCultureIgnoreCase.WithNaturalSort();
// public static readonly NaturalStringComparer Instance = new NaturalStringComparer();
}

#if WINDOWS
/// <summary>
/// Native-Interop natural string comparion using StrCmpLogicalW from shlwapi.dll
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
public sealed class NativeNaturalStringComparer : IComparer<string>
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
static extern int StrCmpLogicalW(string psz1, string psz2);

public int Compare(string x, string y)
{
return StrCmpLogicalW(x, y);
}
}
#endif
}
Loading