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

Clean up code with NET8_0_OR_GREATER #109507

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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;
karakasa marked this conversation as resolved.
Show resolved Hide resolved
#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
eiriktsarpalis marked this conversation as resolved.
Show resolved Hide resolved
[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)
{
karakasa marked this conversation as resolved.
Show resolved Hide resolved
#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
Loading