Skip to content

Commit

Permalink
add if-defs for libs
Browse files Browse the repository at this point in the history
  • Loading branch information
determ1ne committed Nov 16, 2023
1 parent 9f43dbd commit 660890f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,16 @@ public static string ToSerialString(this byte[] serialBytes)
return ToUpperHexString(serialBytes);
}

#if NETCOREAPP || NETSTANDARD2_1
#if NET5_0_OR_GREATER
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
{
return Convert.ToHexString(ba);
}
#elif NETCOREAPP || NETSTANDARD2_1
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
{
return HexConverter.ToString(ba, HexConverter.Casing.Upper);
}
#else
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ private static string FormatBytes(byte[]? bytes)
if (bytes == null)
return NullString;

#if NET9_0_OR_GREATER
return Convert.ToHexStringLower(bytes);
#else
return HexConverter.ToString(bytes, HexConverter.Casing.Lower);
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,17 @@ internal static X509Certificate2Collection BuildBagOfCerts(KeyInfoX509Data keyIn
return collection;
}

#if NET5_0_OR_GREATER
internal static string EncodeHexString(byte[] sArray)
{
return Convert.ToHexString(sArray);
}
#else
internal static string EncodeHexString(byte[] sArray)
{
return HexConverter.ToString(sArray);
}
#endif

internal static byte[] DecodeHexString(string s)
{
Expand Down

0 comments on commit 660890f

Please sign in to comment.