From c45e0d707de9881fbefb7d735d9d26866b91f655 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2020 09:40:47 -0700 Subject: [PATCH] Sync shared code from runtime (#23843) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/Shared/runtime/NetEventSource.Common.cs | 45 ++++++----- .../MsQuic/MsQuicConnection.cs | 40 +++++----- .../Implementations/MsQuic/MsQuicListener.cs | 4 +- .../Implementations/MsQuic/MsQuicStream.cs | 74 +++++++++---------- 4 files changed, 80 insertions(+), 83 deletions(-) diff --git a/src/Shared/runtime/NetEventSource.Common.cs b/src/Shared/runtime/NetEventSource.Common.cs index 43da47aeab..48a67e1155 100644 --- a/src/Shared/runtime/NetEventSource.Common.cs +++ b/src/Shared/runtime/NetEventSource.Common.cs @@ -29,8 +29,8 @@ namespace System.Net // Usage: // - Operations that may allocate (e.g. boxing a value type, using string interpolation, etc.) or that may have computations // at call sites should guard access like: - // if (NetEventSource.IsEnabled) NetEventSource.Enter(this, refArg1, valueTypeArg2); // entering an instance method with a value type arg - // if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"Found certificate: {cert}"); // info logging with a formattable string + // if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this, refArg1, valueTypeArg2); // entering an instance method with a value type arg + // if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"Found certificate: {cert}"); // info logging with a formattable string // - Operations that have zero allocations / measurable computations at call sites can use a simpler pattern, calling methods like: // NetEventSource.Enter(this); // entering an instance method // NetEventSource.Info(this, "literal string"); // arbitrary message with a literal string @@ -103,7 +103,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// Logs entrance to a method. @@ -115,7 +115,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); - if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})"); + if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})"); } /// Logs entrance to a method. @@ -129,7 +129,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); DebugValidateArg(arg1); - if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})"); + if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})"); } /// Logs entrance to a method. @@ -145,7 +145,7 @@ namespace System.Net DebugValidateArg(arg0); DebugValidateArg(arg1); DebugValidateArg(arg2); - if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})"); + if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})"); } [Event(EnterEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)] @@ -163,7 +163,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// Logs exit from a method. @@ -175,7 +175,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); - if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString()); + if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString()); } /// Logs exit from a method. @@ -189,7 +189,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); DebugValidateArg(arg1); - if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}"); + if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}"); } [Event(ExitEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)] @@ -207,7 +207,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// Logs an information message. @@ -219,7 +219,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(message); - if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString()); } [Event(InfoEventId, Level = EventLevel.Informational, Keywords = Keywords.Default)] @@ -237,7 +237,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString)); + if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString)); } /// Logs an error message. @@ -249,7 +249,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(message); - if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString()); } [Event(ErrorEventId, Level = EventLevel.Error, Keywords = Keywords.Default)] @@ -268,7 +268,7 @@ namespace System.Net // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations // that should never happen in production, and thus we don't care about extra costs. - if (IsEnabled) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(formattableString)); + if (Log.IsEnabled()) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(formattableString)); Debug.Fail(Format(formattableString), $"{IdOf(thisOrContextObject)}.{memberName}"); } @@ -282,7 +282,7 @@ namespace System.Net // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations // that should never happen in production, and thus we don't care about extra costs. - if (IsEnabled) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (Log.IsEnabled()) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(message).ToString()); Debug.Fail(Format(message).ToString(), $"{IdOf(thisOrContextObject)}.{memberName}"); } @@ -311,7 +311,7 @@ namespace System.Net [NonEvent] public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, int offset, int count, [CallerMemberName] string? memberName = null) { - if (IsEnabled) + if (Log.IsEnabled()) { if (offset < 0 || offset > buffer.Length - count) { @@ -343,7 +343,7 @@ namespace System.Net Debug.Assert(bufferPtr != IntPtr.Zero); Debug.Assert(count >= 0); - if (IsEnabled) + if (Log.IsEnabled()) { var buffer = new byte[Math.Min(count, MaxDumpSize)]; fixed (byte* targetPtr = buffer) @@ -369,7 +369,7 @@ namespace System.Net { DebugValidateArg(first); DebugValidateArg(second); - if (IsEnabled) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second)); + if (Log.IsEnabled()) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second)); } /// Logs a relationship between two objects. @@ -383,7 +383,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(first); DebugValidateArg(second); - if (IsEnabled) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second)); + if (Log.IsEnabled()) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second)); } [Event(AssociateEventId, Level = EventLevel.Informational, Keywords = Keywords.Default, Message = "[{2}]<-->[{3}]")] @@ -396,7 +396,7 @@ namespace System.Net [Conditional("DEBUG_NETEVENTSOURCE_MISUSE")] private static void DebugValidateArg(object? arg) { - if (!IsEnabled) + if (!Log.IsEnabled()) { Debug.Assert(!(arg is ValueType), $"Should not be passing value type {arg?.GetType()} to logging without IsEnabled check"); Debug.Assert(!(arg is FormattableString), $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); @@ -406,12 +406,9 @@ namespace System.Net [Conditional("DEBUG_NETEVENTSOURCE_MISUSE")] private static void DebugValidateArg(FormattableString? arg) { - Debug.Assert(IsEnabled || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); + Debug.Assert(Log.IsEnabled() || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); } - public static new bool IsEnabled => - Log.IsEnabled(); - [NonEvent] public static string IdOf(object? value) => value != null ? value.GetType().Name + "#" + GetHashCode(value) : NullInstance; diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs index 534bb84afd..4fe328965a 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs @@ -51,20 +51,20 @@ namespace System.Net.Quic.Implementations.MsQuic // constructor for inbound connections public MsQuicConnection(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, IntPtr nativeObjPtr) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); _localEndPoint = localEndPoint; _remoteEndPoint = remoteEndPoint; _ptr = nativeObjPtr; SetCallbackHandler(); SetIdleTimeout(TimeSpan.FromSeconds(120)); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } // constructor for outbound connections public MsQuicConnection(QuicClientConnectionOptions options) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); // TODO need to figure out if/how we want to expose sessions // Creating a session per connection isn't ideal. @@ -75,7 +75,7 @@ namespace System.Net.Quic.Implementations.MsQuic SetCallbackHandler(); SetIdleTimeout(options.IdleTimeout); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override IPEndPoint LocalEndPoint @@ -168,7 +168,7 @@ namespace System.Net.Quic.Implementations.MsQuic private uint HandleEventConnected(ConnectionEvent connectionEvent) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); SOCKADDR_INET inetAddress = MsQuicParameterHelpers.GetINetParam(MsQuicApi.Api, _ptr, (uint)QUIC_PARAM_LEVEL.CONNECTION, (uint)QUIC_PARAM_CONN.LOCAL_ADDRESS); _localEndPoint = MsQuicAddressHelpers.INetToIPEndPoint(inetAddress); @@ -179,13 +179,13 @@ namespace System.Net.Quic.Implementations.MsQuic // handle event shutdown initiated by transport _connectTcs.Complete(MsQuicStatusCodes.Success); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventShutdownInitiatedByTransport(ConnectionEvent connectionEvent) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); if (!_connected) { @@ -194,7 +194,7 @@ namespace System.Net.Quic.Implementations.MsQuic _acceptQueue.Writer.Complete(); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } @@ -208,22 +208,22 @@ namespace System.Net.Quic.Implementations.MsQuic private uint HandleEventShutdownComplete(ConnectionEvent connectionEvent) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); _shutdownTcs.Complete(MsQuicStatusCodes.Success); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventNewStream(ConnectionEvent connectionEvent) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); MsQuicStream msQuicStream = new MsQuicStream(this, connectionEvent.StreamFlags, connectionEvent.Data.NewStream.Stream, inbound: true); _acceptQueue.Writer.TryWrite(msQuicStream); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } @@ -235,7 +235,7 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask AcceptStreamAsync(CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -254,7 +254,7 @@ namespace System.Net.Quic.Implementations.MsQuic }; } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return stream; } @@ -305,7 +305,7 @@ namespace System.Net.Quic.Implementations.MsQuic private MsQuicStream StreamOpen( QUIC_STREAM_OPEN_FLAG flags) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); IntPtr streamPtr = IntPtr.Zero; QuicExceptionHelpers.ThrowIfFailed( @@ -319,7 +319,7 @@ namespace System.Net.Quic.Implementations.MsQuic MsQuicStream stream = new MsQuicStream(this, flags, streamPtr, inbound: false); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return stream; } @@ -337,7 +337,7 @@ namespace System.Net.Quic.Implementations.MsQuic QUIC_CONNECTION_SHUTDOWN_FLAG Flags, long ErrorCode) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); uint status = MsQuicApi.Api.ConnectionShutdownDelegate( _ptr, @@ -345,7 +345,7 @@ namespace System.Net.Quic.Implementations.MsQuic ErrorCode); QuicExceptionHelpers.ThrowIfFailed(status, "Failed to shutdown connection."); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return _shutdownTcs.GetTypelessValueTask(); } @@ -377,7 +377,7 @@ namespace System.Net.Quic.Implementations.MsQuic return; } - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); if (_ptr != IntPtr.Zero) { @@ -395,7 +395,7 @@ namespace System.Net.Quic.Implementations.MsQuic _disposed = true; - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask CloseAsync(long errorCode, CancellationToken cancellationToken = default) diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs index 71bf88e432..0a9b004bb6 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs @@ -62,7 +62,7 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask AcceptConnectionAsync(CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -81,7 +81,7 @@ namespace System.Net.Quic.Implementations.MsQuic _options.CertificateFilePath, _options.PrivateKeyFilePath).ConfigureAwait(false); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return connection; } diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs index b84a4ee864..085abfd84a 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs @@ -124,7 +124,7 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask WriteAsync(ReadOnlySequence buffers, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -134,7 +134,7 @@ namespace System.Net.Quic.Implementations.MsQuic HandleWriteCompletedState(); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask WriteAsync(ReadOnlyMemory> buffers, CancellationToken cancellationToken = default) @@ -144,7 +144,7 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask WriteAsync(ReadOnlyMemory> buffers, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -154,12 +154,12 @@ namespace System.Net.Quic.Implementations.MsQuic HandleWriteCompletedState(); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override async ValueTask WriteAsync(ReadOnlyMemory buffer, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -169,7 +169,7 @@ namespace System.Net.Quic.Implementations.MsQuic HandleWriteCompletedState(); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } private async ValueTask HandleWriteStartState(CancellationToken cancellationToken) @@ -228,7 +228,7 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask ReadAsync(Memory destination, CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -241,7 +241,7 @@ namespace System.Net.Quic.Implementations.MsQuic { if (_readState == ReadState.ReadsCompleted) { - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return 0; } else if (_readState == ReadState.Aborted) @@ -310,7 +310,7 @@ namespace System.Net.Quic.Implementations.MsQuic } } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return actual; } @@ -319,7 +319,7 @@ namespace System.Net.Quic.Implementations.MsQuic // If so, we need to complete the read here as well. internal override void AbortRead(long errorCode) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -330,12 +330,12 @@ namespace System.Net.Quic.Implementations.MsQuic MsQuicApi.Api.StreamShutdownDelegate(_ptr, (uint)QUIC_STREAM_SHUTDOWN_FLAG.ABORT_RECV, errorCode); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override void AbortWrite(long errorCode) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -357,12 +357,12 @@ namespace System.Net.Quic.Implementations.MsQuic MsQuicApi.Api.StreamShutdownDelegate(_ptr, (uint)QUIC_STREAM_SHUTDOWN_FLAG.ABORT_SEND, errorCode); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask ShutdownWriteCompleted(CancellationToken cancellationToken = default) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); ThrowIfDisposed(); @@ -385,7 +385,7 @@ namespace System.Net.Quic.Implementations.MsQuic } }); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return _shutdownWriteResettableCompletionSource.GetTypelessValueTask(); } @@ -434,7 +434,7 @@ namespace System.Net.Quic.Implementations.MsQuic return default; } - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); CleanupSendState(); @@ -448,7 +448,7 @@ namespace System.Net.Quic.Implementations.MsQuic _handle.Free(); _disposed = true; - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return default; } @@ -471,7 +471,7 @@ namespace System.Net.Quic.Implementations.MsQuic return; } - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); CleanupSendState(); @@ -484,7 +484,7 @@ namespace System.Net.Quic.Implementations.MsQuic _handle.Free(); - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); _disposed = true; } @@ -577,7 +577,7 @@ namespace System.Net.Quic.Implementations.MsQuic private unsafe uint HandleEventRecv(ref MsQuicNativeMethods.StreamEvent evt) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); StreamEventDataRecv receieveEvent = evt.Data.Recv; for (int i = 0; i < receieveEvent.BufferCount; i++) @@ -600,14 +600,14 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.Complete((uint)receieveEvent.TotalBufferLength); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Pending; } private uint HandleEventPeerRecvAborted(ref StreamEvent evt) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) @@ -625,14 +625,14 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.CompleteException(new QuicStreamAbortedException(_sendErrorCode)); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleStartComplete() { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) @@ -649,14 +649,14 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventSendShutdownComplete(ref MsQuicNativeMethods.StreamEvent evt) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) { @@ -672,14 +672,14 @@ namespace System.Net.Quic.Implementations.MsQuic _shutdownWriteResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventShutdownComplete() { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldReadComplete = false; bool shouldShutdownWriteComplete = false; @@ -687,7 +687,7 @@ namespace System.Net.Quic.Implementations.MsQuic lock (_sync) { // This event won't occur within the middle of a receive. - if (NetEventSource.IsEnabled) NetEventSource.Info("Completing resettable event source."); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Info("Completing resettable event source."); if (_readState == ReadState.None) { @@ -713,14 +713,14 @@ namespace System.Net.Quic.Implementations.MsQuic _shutdownWriteResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventPeerSendAborted(ref StreamEvent evt) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) @@ -738,21 +738,21 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.CompleteException(new QuicStreamAbortedException(_readErrorCode)); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventPeerSendShutdown() { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) { // This event won't occur within the middle of a receive. - if (NetEventSource.IsEnabled) NetEventSource.Info("Completing resettable event source."); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Info("Completing resettable event source."); if (_readState == ReadState.None) { @@ -767,14 +767,14 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.Complete(0); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventSendComplete(ref StreamEvent evt) { - if (NetEventSource.IsEnabled) NetEventSource.Enter(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); CleanupSendState(); @@ -796,7 +796,7 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.IsEnabled) NetEventSource.Exit(this); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; }