Skip to content

Commit 660890f

Browse files
committed
add if-defs for libs
1 parent 9f43dbd commit 660890f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,16 @@ public static string ToSerialString(this byte[] serialBytes)
364364
return ToUpperHexString(serialBytes);
365365
}
366366

367-
#if NETCOREAPP || NETSTANDARD2_1
367+
#if NET5_0_OR_GREATER
368368
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
369369
{
370370
return Convert.ToHexString(ba);
371371
}
372+
#elif NETCOREAPP || NETSTANDARD2_1
373+
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
374+
{
375+
return HexConverter.ToString(ba, HexConverter.Casing.Upper);
376+
}
372377
#else
373378
private static string ToUpperHexString(ReadOnlySpan<byte> ba)
374379
{

src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXmlDebugLog.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ private static string FormatBytes(byte[]? bytes)
197197
if (bytes == null)
198198
return NullString;
199199

200+
#if NET9_0_OR_GREATER
200201
return Convert.ToHexStringLower(bytes);
202+
#else
203+
return HexConverter.ToString(bytes, HexConverter.Casing.Lower);
204+
#endif
201205
}
202206

203207
/// <summary>

src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,17 @@ internal static X509Certificate2Collection BuildBagOfCerts(KeyInfoX509Data keyIn
720720
return collection;
721721
}
722722

723+
#if NET5_0_OR_GREATER
723724
internal static string EncodeHexString(byte[] sArray)
724725
{
725726
return Convert.ToHexString(sArray);
726727
}
728+
#else
729+
internal static string EncodeHexString(byte[] sArray)
730+
{
731+
return HexConverter.ToString(sArray);
732+
}
733+
#endif
727734

728735
internal static byte[] DecodeHexString(string s)
729736
{

0 commit comments

Comments
 (0)