Moved all extension methods into extension blocks (#1155)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-04 10:46:18 +01:00
1 parent acc7d09fa2
commit c0a75f39ac
138 files changed
+5884 -4954

No files matched your search

+41 -37
View File
@@ -12,51 +12,55 @@ public static class FNVHash
private const uint FNV_PRIME_32_BIT = 16_777_619;
private const ulong FNV_PRIME_64_BIT = 1_099_511_628_211;
/// <summary>
/// Computes the 32bit FNV-1a hash of a string.
/// </summary>
/// <param name="text">The string to hash.</param>
/// <returns>The 32bit FNV-1a hash of the string.</returns>
public static uint ToFNV32(this string text) => ToFNV32(text.AsSpan());
/// <summary>
/// Computes the 32bit FNV-1a hash of a string.
/// </summary>
/// <param name="text">The string to hash.</param>
/// <returns>The 32bit FNV-1a hash of the string.</returns>
public static uint ToFNV32(this ReadOnlySpan<char> text)
extension(string text)
{
var hash = FNV_OFFSET_BASIS_32_BIT;
foreach (var c in text)
{
hash ^= c;
hash *= FNV_PRIME_32_BIT;
}
/// <summary>
/// Computes the 32bit FNV-1a hash of a string.
/// </summary>
/// <returns>The 32bit FNV-1a hash of the string.</returns>
public uint ToFNV32() => ToFNV32(text.AsSpan());
return hash;
/// <summary>
/// Computes the 64bit FNV-1a hash of a string.
/// </summary>
/// <returns>The 64bit FNV-1a hash of the string.</returns>
public ulong ToFNV64() => ToFNV64(text.AsSpan());
}
/// <summary>
/// Computes the 64bit FNV-1a hash of a string.
/// </summary>
/// <param name="text">The string to hash.</param>
/// <returns>The 64bit FNV-1a hash of the string.</returns>
public static ulong ToFNV64(this string text) => ToFNV64(text.AsSpan());
/// <summary>
/// Computes the 64bit FNV-1a hash of a string.
/// </summary>
/// <param name="text">The string to hash.</param>
/// <returns>The 64bit FNV-1a hash of the string.</returns>
public static ulong ToFNV64(this ReadOnlySpan<char> text)
extension(ReadOnlySpan<char> text)
{
var hash = FNV_OFFSET_BASIS_64_BIT;
foreach (var c in text)
/// <summary>
/// Computes the 32bit FNV-1a hash of a string.
/// </summary>
/// <returns>The 32bit FNV-1a hash of the string.</returns>
public uint ToFNV32()
{
hash ^= c;
hash *= FNV_PRIME_64_BIT;
var hash = FNV_OFFSET_BASIS_32_BIT;
foreach (var c in text)
{
hash ^= c;
hash *= FNV_PRIME_32_BIT;
}
return hash;
}
return hash;
/// <summary>
/// Computes the 64bit FNV-1a hash of a string.
/// </summary>
/// <returns>The 64bit FNV-1a hash of the string.</returns>
public ulong ToFNV64()
{
var hash = FNV_OFFSET_BASIS_64_BIT;
foreach (var c in text)
{
hash ^= c;
hash *= FNV_PRIME_64_BIT;
}
return hash;
}
}
}
+38 -32
View File
@@ -34,45 +34,51 @@ public static class RIDExtensions
};
}
public static string AsMicrosoftRid(this RID rid) => rid switch
extension(RID rid)
{
RID.WIN_X64 => "win-x64",
RID.WIN_ARM64 => "win-arm64",
public string AsMicrosoftRid() => rid switch
{
RID.WIN_X64 => "win-x64",
RID.WIN_ARM64 => "win-arm64",
RID.LINUX_X64 => "linux-x64",
RID.LINUX_ARM64 => "linux-arm64",
RID.LINUX_X64 => "linux-x64",
RID.LINUX_ARM64 => "linux-arm64",
RID.OSX_X64 => "osx-x64",
RID.OSX_ARM64 => "osx-arm64",
RID.OSX_X64 => "osx-x64",
RID.OSX_ARM64 => "osx-arm64",
_ => string.Empty,
};
_ => string.Empty,
};
public string ToUserFriendlyName() => rid switch
{
RID.WIN_X64 => "Windows x64",
RID.WIN_ARM64 => "Windows ARM64",
RID.LINUX_X64 => "Linux x64",
RID.LINUX_ARM64 => "Linux ARM64",
RID.OSX_X64 => "macOS x64",
RID.OSX_ARM64 => "macOS ARM64",
_ => "unknown",
};
}
public static string ToUserFriendlyName(this RID rid) => rid switch
extension(string rid)
{
RID.WIN_X64 => "Windows x64",
RID.WIN_ARM64 => "Windows ARM64",
public RID ToRID() => rid switch
{
"win-x64" => RID.WIN_X64,
"win-arm64" => RID.WIN_ARM64,
RID.LINUX_X64 => "Linux x64",
RID.LINUX_ARM64 => "Linux ARM64",
"linux-x64" => RID.LINUX_X64,
"linux-arm64" => RID.LINUX_ARM64,
RID.OSX_X64 => "macOS x64",
RID.OSX_ARM64 => "macOS ARM64",
"osx-x64" => RID.OSX_X64,
"osx-arm64" => RID.OSX_ARM64,
_ => "unknown",
};
public static RID ToRID(this string rid) => rid switch
{
"win-x64" => RID.WIN_X64,
"win-arm64" => RID.WIN_ARM64,
"linux-x64" => RID.LINUX_X64,
"linux-arm64" => RID.LINUX_ARM64,
"osx-x64" => RID.OSX_X64,
"osx-arm64" => RID.OSX_ARM64,
_ => RID.NONE,
};
_ => RID.NONE,
};
}
}