Skip to content

Commit

Permalink
Clean up code with NET8_0_OR_GREATER (#109507)
Browse files Browse the repository at this point in the history
  • Loading branch information
karakasa authored Nov 7, 2024
1 parent bad7318 commit 70c574d
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#if NET8_0_OR_GREATER
#if NET
using static System.ArgumentNullException;
using static System.ArgumentOutOfRangeException;
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static void ThrowIndexArgumentOutOfRange() =>
internal static void ThrowVersionCheckFailed() =>
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);

#if !NET8_0_OR_GREATER
#if !NET
/// <summary>Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is null.</summary>
/// <param name="argument">The reference type argument to validate as non-null.</param>
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,16 @@ public ZLibException(string? message, Exception? innerException) : base(message,
/// </summary>
/// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
#if NET8_0_OR_GREATER
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
#endif
protected ZLibException(SerializationInfo info, StreamingContext context) : base(info, context)
{
_zlibErrorContext = info.GetString("zlibErrorContext");
_zlibErrorCode = (ZLibNative.ErrorCode)info.GetInt32("zlibErrorCode");
_zlibErrorMessage = info.GetString("zlibErrorMessage");
}

#if NET8_0_OR_GREATER
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
{
base.GetObjectData(si, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class ICollectionDebugView<T>

public ICollectionDebugView(ICollection<T> collection)
{
#if NET8_0_OR_GREATER
#if NET
ArgumentNullException.ThrowIfNull(collection);
#else
if (collection is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ public static bool ParticipatesInCaseConversion(ReadOnlySpan<char> s)
/// <summary>Gets whether the specified span contains only ASCII.</summary>
public static bool IsAscii(ReadOnlySpan<char> s)
{
#if NET8_0_OR_GREATER
#if NET
return Ascii.IsValid(s);
#else
foreach (char c in s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ internal static int MapCaptureNumber(int capnum, Hashtable? caps) =>
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Q, S, 0, 0, 0
];

#if NET8_0_OR_GREATER
#if NET
private static readonly SearchValues<char> s_metachars =
SearchValues.Create("\t\n\f\r #$()*+.?[\\^{|");

Expand Down

0 comments on commit 70c574d

Please sign in to comment.