diff --git a/src/Components/Components/src/BindConverter.cs b/src/Components/Components/src/BindConverter.cs
index 441d84f6e1b3..8320e835325d 100644
--- a/src/Components/Components/src/BindConverter.cs
+++ b/src/Components/Components/src/BindConverter.cs
@@ -1223,7 +1223,7 @@ private static bool ConvertToDateTimeCore(object? obj, CultureInfo? culture, out
return ConvertToDateTimeCore(obj, culture, format: null, out value);
}
- private static bool ConvertToDateTimeCore(object? obj, CultureInfo? culture, string? format, out DateTime value)
+ private static bool ConvertToDateTimeCore(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.TimeSpanFormat)] string? format, out DateTime value)
{
var text = (string?)obj;
if (string.IsNullOrEmpty(text))
@@ -1252,7 +1252,7 @@ private static bool ConvertToNullableDateTimeCore(object? obj, CultureInfo? cult
return ConvertToNullableDateTimeCore(obj, culture, format: null, out value);
}
- private static bool ConvertToNullableDateTimeCore(object? obj, CultureInfo? culture, string? format, out DateTime? value)
+ private static bool ConvertToNullableDateTimeCore(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, out DateTime? value)
{
var text = (string?)obj;
if (string.IsNullOrEmpty(text))
@@ -1336,7 +1336,7 @@ private static bool ConvertToDateTimeOffsetCore(object? obj, CultureInfo? cultur
return ConvertToDateTimeOffsetCore(obj, culture, format: null, out value);
}
- private static bool ConvertToDateTimeOffsetCore(object? obj, CultureInfo? culture, string? format, out DateTimeOffset value)
+ private static bool ConvertToDateTimeOffsetCore(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, out DateTimeOffset value)
{
var text = (string?)obj;
if (string.IsNullOrEmpty(text))
@@ -1365,7 +1365,7 @@ private static bool ConvertToNullableDateTimeOffsetCore(object? obj, CultureInfo
return ConvertToNullableDateTimeOffsetCore(obj, culture, format: null, out value);
}
- private static bool ConvertToNullableDateTimeOffsetCore(object? obj, CultureInfo? culture, string? format, out DateTimeOffset? value)
+ private static bool ConvertToNullableDateTimeOffsetCore(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, out DateTimeOffset? value)
{
var text = (string?)obj;
if (string.IsNullOrEmpty(text))
diff --git a/src/Middleware/OutputCaching/test/TestUtils.cs b/src/Middleware/OutputCaching/test/TestUtils.cs
index b745adae97dc..f684898e6d42 100644
--- a/src/Middleware/OutputCaching/test/TestUtils.cs
+++ b/src/Middleware/OutputCaching/test/TestUtils.cs
@@ -3,6 +3,7 @@
#nullable enable
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Text;
using Microsoft.AspNetCore.Builder;
@@ -29,7 +30,7 @@ static TestUtils()
StreamUtilities.BodySegmentSize = 10;
}
- private static bool TestRequestDelegate(HttpContext context, string guid)
+ private static bool TestRequestDelegate(HttpContext context, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string guid)
{
var headers = context.Response.GetTypedHeaders();
headers.Date = DateTimeOffset.UtcNow;
diff --git a/src/Middleware/ResponseCaching/test/TestUtils.cs b/src/Middleware/ResponseCaching/test/TestUtils.cs
index a3a64267e550..64094bcf051f 100644
--- a/src/Middleware/ResponseCaching/test/TestUtils.cs
+++ b/src/Middleware/ResponseCaching/test/TestUtils.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net.Http;
using System.Text;
@@ -29,7 +30,7 @@ static TestUtils()
StreamUtilities.BodySegmentSize = 10;
}
- private static bool TestRequestDelegate(HttpContext context, string guid)
+ private static bool TestRequestDelegate(HttpContext context, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string guid)
{
var headers = context.Response.GetTypedHeaders();
diff --git a/src/Servers/Connections.Abstractions/src/DefaultConnectionContext.cs b/src/Servers/Connections.Abstractions/src/DefaultConnectionContext.cs
index da2449ae21f5..74290d0a0425 100644
--- a/src/Servers/Connections.Abstractions/src/DefaultConnectionContext.cs
+++ b/src/Servers/Connections.Abstractions/src/DefaultConnectionContext.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using System.Net;
using System.Security.Claims;
@@ -40,7 +41,7 @@ public DefaultConnectionContext() :
/// The caller is expected to set the and pipes manually.
///
/// The .
- public DefaultConnectionContext(string id)
+ public DefaultConnectionContext([StringSyntax(StringSyntaxAttribute.GuidFormat)] string id)
{
ConnectionId = id;
@@ -61,7 +62,7 @@ public DefaultConnectionContext(string id)
/// The .
/// The .
/// The .
- public DefaultConnectionContext(string id, IDuplexPipe transport, IDuplexPipe application)
+ public DefaultConnectionContext([StringSyntax(StringSyntaxAttribute.GuidFormat)] string id, IDuplexPipe transport, IDuplexPipe application)
: this(id)
{
Transport = transport;
diff --git a/src/Servers/IIS/IIS/src/Core/IISHttpContext.Log.cs b/src/Servers/IIS/IIS/src/Core/IISHttpContext.Log.cs
index 74c687c6f52d..1db8e7481343 100644
--- a/src/Servers/IIS/IIS/src/Core/IISHttpContext.Log.cs
+++ b/src/Servers/IIS/IIS/src/Core/IISHttpContext.Log.cs
@@ -11,21 +11,21 @@ internal abstract partial class IISHttpContext
private static partial class Log
{
[LoggerMessage(1, LogLevel.Debug, @"Connection ID ""{ConnectionId}"" disconnecting.", EventName = "ConnectionDisconnect")]
- public static partial void ConnectionDisconnect(ILogger logger, string connectionId);
+ public static partial void ConnectionDisconnect(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(2, LogLevel.Error, @"Connection ID ""{ConnectionId}"", Request ID ""{TraceIdentifier}"": An unhandled exception was thrown by the application.", EventName = "ApplicationError")]
- public static partial void ApplicationError(ILogger logger, string connectionId, string traceIdentifier, Exception ex);
+ public static partial void ApplicationError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier, Exception ex);
[LoggerMessage(3, LogLevel.Error, @"Unexpected exception in ""{ClassName}.{MethodName}"".", EventName = "UnexpectedError")]
public static partial void UnexpectedError(ILogger logger, string className, Exception ex, [CallerMemberName] string? methodName = null);
- public static void ConnectionBadRequest(ILogger logger, string connectionId, Microsoft.AspNetCore.Http.BadHttpRequestException ex)
+ public static void ConnectionBadRequest(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Microsoft.AspNetCore.Http.BadHttpRequestException ex)
=> ConnectionBadRequest(logger, connectionId, ex.Message, ex);
[LoggerMessage(4, LogLevel.Debug, @"Connection id ""{ConnectionId}"" bad request data: ""{message}""", EventName = nameof(ConnectionBadRequest))]
- private static partial void ConnectionBadRequest(ILogger logger, string connectionId, string message, Microsoft.AspNetCore.Http.BadHttpRequestException ex);
+ private static partial void ConnectionBadRequest(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string message, Microsoft.AspNetCore.Http.BadHttpRequestException ex);
[LoggerMessage(5, LogLevel.Debug, @"Connection ID ""{ConnectionId}"", Request ID ""{TraceIdentifier}"": The request was aborted by the client.", EventName = "RequestAborted")]
- public static partial void RequestAborted(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestAborted(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
}
}
diff --git a/src/Servers/Kestrel/Core/src/Internal/ConnectionLogScope.cs b/src/Servers/Kestrel/Core/src/Internal/ConnectionLogScope.cs
index 22094285b904..5db1ad4c770c 100644
--- a/src/Servers/Kestrel/Core/src/Internal/ConnectionLogScope.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/ConnectionLogScope.cs
@@ -3,6 +3,7 @@
using System.Collections;
using System.Globalization;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
@@ -12,7 +13,7 @@ internal sealed class ConnectionLogScope : IReadOnlyList memoryPool,
KestrelTrace log,
diff --git a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
index e8fca0c394b3..3a0aad1f5ad6 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
@@ -4,6 +4,7 @@
using System.Buffers;
using System.Buffers.Binary;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using System.Net.Http.HPack;
using System.Threading.Channels;
@@ -58,7 +59,7 @@ public Http2FrameWriter(
int maxStreamsPerConnection,
ITimeoutControl timeoutControl,
MinDataRate? minResponseDataRate,
- string connectionId,
+ [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId,
MemoryPool memoryPool,
ServiceContext serviceContext)
{
@@ -82,7 +83,7 @@ public Http2FrameWriter(
// This is bounded by the maximum number of concurrent Http2Streams per Http2Connection.
// This isn't the same as SETTINGS_MAX_CONCURRENT_STREAMS, but typically double (with a floor of 100)
// which is the max number of Http2Streams that can end up in the Http2Connection._streams dictionary.
- //
+ //
// Setting a lower limit of SETTINGS_MAX_CONCURRENT_STREAMS might be sufficient because a stream shouldn't
// be rescheduling itself after being completed or canceled, but we're going with the more conservative limit
// in case there's some logic scheduling completed or canceled streams unnecessarily.
diff --git a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2StreamContext.cs b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2StreamContext.cs
index 9537d30b55fa..872b1ecf0ea0 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2StreamContext.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2StreamContext.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Buffers;
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
@@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
internal sealed class Http2StreamContext : HttpConnectionContext
{
public Http2StreamContext(
- string connectionId,
+ [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId,
HttpProtocols protocols,
AltSvcHeader? altSvcHeader,
BaseConnectionContext connectionContext,
diff --git a/src/Servers/Kestrel/Core/src/Internal/Http3/Http3FrameWriter.cs b/src/Servers/Kestrel/Core/src/Internal/Http3/Http3FrameWriter.cs
index dbcd774af4d6..e0552e001d44 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Http3/Http3FrameWriter.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Http3/Http3FrameWriter.cs
@@ -3,6 +3,7 @@
using System.Buffers;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using System.Net.Http;
using System.Net.Http.QPack;
@@ -78,7 +79,7 @@ public Http3FrameWriter(ConnectionContext connectionContext, ITimeoutControl tim
: (int)clientPeerSettings.MaxRequestHeaderFieldSectionSize;
}
- public void Reset(PipeWriter output, string connectionId)
+ public void Reset(PipeWriter output, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
_outputWriter = output;
_flusher.Initialize(output);
diff --git a/src/Servers/Kestrel/Core/src/Internal/Http3/Http3StreamContext.cs b/src/Servers/Kestrel/Core/src/Internal/Http3/Http3StreamContext.cs
index 50c406b3d06c..f3e70b6b204e 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Http3/Http3StreamContext.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Http3/Http3StreamContext.cs
@@ -3,6 +3,7 @@
using System.Buffers;
using System.Net;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
@@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3;
internal sealed class Http3StreamContext : HttpConnectionContext
{
public Http3StreamContext(
- string connectionId,
+ [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId,
HttpProtocols protocols,
AltSvcHeader? altSvcHeader,
BaseConnectionContext connectionContext,
diff --git a/src/Servers/Kestrel/Core/src/Internal/HttpConnectionContext.cs b/src/Servers/Kestrel/Core/src/Internal/HttpConnectionContext.cs
index 92c6ad1a0583..feb8d3034b38 100644
--- a/src/Servers/Kestrel/Core/src/Internal/HttpConnectionContext.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/HttpConnectionContext.cs
@@ -4,6 +4,7 @@
using System.Buffers;
using System.IO.Pipelines;
using System.Net;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
@@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
internal class HttpConnectionContext : BaseHttpConnectionContext
{
public HttpConnectionContext(
- string connectionId,
+ [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId,
HttpProtocols protocols,
AltSvcHeader? altSvcHeader,
BaseConnectionContext connectionContext,
diff --git a/src/Servers/Kestrel/Core/src/Internal/HttpMultiplexedConnectionContext.cs b/src/Servers/Kestrel/Core/src/Internal/HttpMultiplexedConnectionContext.cs
index a579e0e8e3e1..727c6193c6be 100644
--- a/src/Servers/Kestrel/Core/src/Internal/HttpMultiplexedConnectionContext.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/HttpMultiplexedConnectionContext.cs
@@ -3,6 +3,7 @@
using System.Buffers;
using System.Net;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
@@ -12,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
internal sealed class HttpMultiplexedConnectionContext : BaseHttpConnectionContext
{
public HttpMultiplexedConnectionContext(
- string connectionId,
+ [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId,
HttpProtocols protocols,
AltSvcHeader? altSvcHeader,
MultiplexedConnectionContext connectionContext,
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelEventSource.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelEventSource.cs
index a52720dd2a6f..2fdefba5ce2c 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelEventSource.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelEventSource.cs
@@ -70,7 +70,7 @@ public void ConnectionStart(BaseConnectionContext connection)
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(1, Level = EventLevel.Informational)]
- private void ConnectionStart(string connectionId, string? localEndPoint, string? remoteEndPoint)
+ private void ConnectionStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string? localEndPoint, string? remoteEndPoint)
{
WriteEvent(1, connectionId, localEndPoint, remoteEndPoint);
}
@@ -88,7 +88,7 @@ public void ConnectionStop(BaseConnectionContext connection)
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(2, Level = EventLevel.Informational)]
- private void ConnectionStop(string connectionId)
+ private void ConnectionStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
WriteEvent(2, connectionId);
}
@@ -113,7 +113,7 @@ void Core(HttpProtocol httpProtocol)
}
[Event(3, Level = EventLevel.Informational)]
- private void RequestStart(string connectionId, string requestId, string httpVersion, string path, string method)
+ private void RequestStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string requestId, string httpVersion, string path, string method)
{
WriteEvent(3, connectionId, requestId, httpVersion, path, method);
}
@@ -138,14 +138,14 @@ void Core(HttpProtocol httpProtocol)
}
[Event(4, Level = EventLevel.Informational)]
- private void RequestStop(string connectionId, string requestId, string httpVersion, string path, string method)
+ private void RequestStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string requestId, string httpVersion, string path, string method)
{
WriteEvent(4, connectionId, requestId, httpVersion, path, method);
}
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(5, Level = EventLevel.Informational)]
- public void ConnectionRejected(string connectionId)
+ public void ConnectionRejected([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
if (IsEnabled(EventLevel.Informational, EventKeywords.None))
{
@@ -179,7 +179,7 @@ public void TlsHandshakeStart(BaseConnectionContext connectionContext, SslServer
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(8, Level = EventLevel.Informational)]
- private void TlsHandshakeStart(string connectionId, string sslProtocols)
+ private void TlsHandshakeStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string sslProtocols)
{
WriteEvent(8, connectionId, sslProtocols);
}
@@ -202,14 +202,14 @@ public void TlsHandshakeStop(BaseConnectionContext connectionContext, TlsConnect
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(9, Level = EventLevel.Informational)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Parameters passed to WriteEvent are all primative values.")]
- private void TlsHandshakeStop(string connectionId, string sslProtocols, string applicationProtocol, string hostName)
+ private void TlsHandshakeStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string sslProtocols, string applicationProtocol, string hostName)
{
WriteEvent(9, connectionId, sslProtocols, applicationProtocol, hostName);
}
[MethodImpl(MethodImplOptions.NoInlining)]
[Event(10, Level = EventLevel.Error)]
- public void TlsHandshakeFailed(string connectionId)
+ public void TlsHandshakeFailed([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Interlocked.Increment(ref _failedTlsHandshakes);
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.BadRequests.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.BadRequests.cs
index 3903a32c215a..be504983b831 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.BadRequests.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.BadRequests.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.Extensions.Logging;
@@ -8,27 +9,27 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
internal sealed partial class KestrelTrace : ILogger
{
- public void ConnectionBadRequest(string connectionId, AspNetCore.Http.BadHttpRequestException ex)
+ public void ConnectionBadRequest([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, AspNetCore.Http.BadHttpRequestException ex)
{
BadRequestsLog.ConnectionBadRequest(_badRequestsLogger, connectionId, ex.Message, ex);
}
- public void RequestProcessingError(string connectionId, Exception ex)
+ public void RequestProcessingError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex)
{
BadRequestsLog.RequestProcessingError(_badRequestsLogger, connectionId, ex);
}
- public void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string? traceIdentifier, double rate)
+ public void RequestBodyMinimumDataRateNotSatisfied([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string? traceIdentifier, double rate)
{
BadRequestsLog.RequestBodyMinimumDataRateNotSatisfied(_badRequestsLogger, connectionId, traceIdentifier, rate);
}
- public void ResponseMinimumDataRateNotSatisfied(string connectionId, string? traceIdentifier)
+ public void ResponseMinimumDataRateNotSatisfied([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string? traceIdentifier)
{
BadRequestsLog.ResponseMinimumDataRateNotSatisfied(_badRequestsLogger, connectionId, traceIdentifier);
}
- public void PossibleInvalidHttpVersionDetected(string connectionId, HttpVersion expectedHttpVersion, HttpVersion detectedHttpVersion)
+ public void PossibleInvalidHttpVersionDetected([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, HttpVersion expectedHttpVersion, HttpVersion detectedHttpVersion)
{
if (_generalLogger.IsEnabled(LogLevel.Debug))
{
@@ -39,19 +40,19 @@ public void PossibleInvalidHttpVersionDetected(string connectionId, HttpVersion
private static partial class BadRequestsLog
{
[LoggerMessage(17, LogLevel.Debug, @"Connection id ""{ConnectionId}"" bad request data: ""{message}""", EventName = "ConnectionBadRequest")]
- public static partial void ConnectionBadRequest(ILogger logger, string connectionId, string message, Microsoft.AspNetCore.Http.BadHttpRequestException ex);
+ public static partial void ConnectionBadRequest(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string message, Microsoft.AspNetCore.Http.BadHttpRequestException ex);
[LoggerMessage(20, LogLevel.Debug, @"Connection id ""{ConnectionId}"" request processing ended abnormally.", EventName = "RequestProcessingError")]
- public static partial void RequestProcessingError(ILogger logger, string connectionId, Exception ex);
+ public static partial void RequestProcessingError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
[LoggerMessage(27, LogLevel.Debug, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the request timed out because it was not sent by the client at a minimum of {Rate} bytes/second.", EventName = "RequestBodyMinimumDataRateNotSatisfied")]
- public static partial void RequestBodyMinimumDataRateNotSatisfied(ILogger logger, string connectionId, string? traceIdentifier, double rate);
+ public static partial void RequestBodyMinimumDataRateNotSatisfied(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string? traceIdentifier, double rate);
[LoggerMessage(28, LogLevel.Debug, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the connection was closed because the response was not read by the client at the specified minimum data rate.", EventName = "ResponseMinimumDataRateNotSatisfied")]
- public static partial void ResponseMinimumDataRateNotSatisfied(ILogger logger, string connectionId, string? traceIdentifier);
+ public static partial void ResponseMinimumDataRateNotSatisfied(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string? traceIdentifier);
[LoggerMessage(54, LogLevel.Debug, @"Connection id ""{ConnectionId}"": Invalid content received on connection. Possible incorrect HTTP version detected. Expected {ExpectedHttpVersion} but received {DetectedHttpVersion}.", EventName = "PossibleInvalidHttpVersionDetected", SkipEnabledCheck = true)]
- public static partial void PossibleInvalidHttpVersionDetected(ILogger logger, string connectionId, string expectedHttpVersion, string detectedHttpVersion);
+ public static partial void PossibleInvalidHttpVersionDetected(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string expectedHttpVersion, string detectedHttpVersion);
// Highest shared ID is 63. New consecutive IDs start at 64
}
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Connections.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Connections.cs
index 1d1ab4c3598a..a1da080a30e5 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Connections.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Connections.cs
@@ -2,37 +2,38 @@
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Logging;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
internal sealed partial class KestrelTrace : ILogger
{
- public void ConnectionStart(string connectionId)
+ public void ConnectionStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionStart(_connectionsLogger, connectionId);
}
- public void ConnectionStop(string connectionId)
+ public void ConnectionStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionStop(_connectionsLogger, connectionId);
}
- public void ConnectionPause(string connectionId)
+ public void ConnectionPause([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionPause(_connectionsLogger, connectionId);
}
- public void ConnectionResume(string connectionId)
+ public void ConnectionResume([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionResume(_connectionsLogger, connectionId);
}
- public void ConnectionKeepAlive(string connectionId)
+ public void ConnectionKeepAlive([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionKeepAlive(_connectionsLogger, connectionId);
}
- public void ConnectionDisconnect(string connectionId)
+ public void ConnectionDisconnect([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionDisconnect(_connectionsLogger, connectionId);
}
@@ -47,17 +48,17 @@ public void NotAllConnectionsAborted()
ConnectionsLog.NotAllConnectionsAborted(_connectionsLogger);
}
- public void ConnectionRejected(string connectionId)
+ public void ConnectionRejected([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionRejected(_connectionsLogger, connectionId);
}
- public void ApplicationAbortedConnection(string connectionId, string traceIdentifier)
+ public void ApplicationAbortedConnection([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
ConnectionsLog.ApplicationAbortedConnection(_connectionsLogger, connectionId, traceIdentifier);
}
- public void ConnectionAccepted(string connectionId)
+ public void ConnectionAccepted([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
ConnectionsLog.ConnectionAccepted(_connectionsLogger, connectionId);
}
@@ -65,22 +66,22 @@ public void ConnectionAccepted(string connectionId)
private static partial class ConnectionsLog
{
[LoggerMessage(1, LogLevel.Debug, @"Connection id ""{ConnectionId}"" started.", EventName = "ConnectionStart")]
- public static partial void ConnectionStart(ILogger logger, string connectionId);
+ public static partial void ConnectionStart(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(2, LogLevel.Debug, @"Connection id ""{ConnectionId}"" stopped.", EventName = "ConnectionStop")]
- public static partial void ConnectionStop(ILogger logger, string connectionId);
+ public static partial void ConnectionStop(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(4, LogLevel.Debug, @"Connection id ""{ConnectionId}"" paused.", EventName = "ConnectionPause")]
- public static partial void ConnectionPause(ILogger logger, string connectionId);
+ public static partial void ConnectionPause(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(5, LogLevel.Debug, @"Connection id ""{ConnectionId}"" resumed.", EventName = "ConnectionResume")]
- public static partial void ConnectionResume(ILogger logger, string connectionId);
+ public static partial void ConnectionResume(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(9, LogLevel.Debug, @"Connection id ""{ConnectionId}"" completed keep alive response.", EventName = "ConnectionKeepAlive")]
- public static partial void ConnectionKeepAlive(ILogger logger, string connectionId);
+ public static partial void ConnectionKeepAlive(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(10, LogLevel.Debug, @"Connection id ""{ConnectionId}"" disconnecting.", EventName = "ConnectionDisconnect")]
- public static partial void ConnectionDisconnect(ILogger logger, string connectionId);
+ public static partial void ConnectionDisconnect(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(16, LogLevel.Debug, "Some connections failed to close gracefully during server shutdown.", EventName = "NotAllConnectionsClosedGracefully")]
public static partial void NotAllConnectionsClosedGracefully(ILogger logger);
@@ -89,13 +90,13 @@ private static partial class ConnectionsLog
public static partial void NotAllConnectionsAborted(ILogger logger);
[LoggerMessage(24, LogLevel.Warning, @"Connection id ""{ConnectionId}"" rejected because the maximum number of concurrent connections has been reached.", EventName = "ConnectionRejected")]
- public static partial void ConnectionRejected(ILogger logger, string connectionId);
+ public static partial void ConnectionRejected(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(34, LogLevel.Information, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the application aborted the connection.", EventName = "ApplicationAbortedConnection")]
- public static partial void ApplicationAbortedConnection(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void ApplicationAbortedConnection(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
[LoggerMessage(39, LogLevel.Debug, @"Connection id ""{ConnectionId}"" accepted.", EventName = "ConnectionAccepted")]
- public static partial void ConnectionAccepted(ILogger logger, string connectionId);
+ public static partial void ConnectionAccepted(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
// Highest shared ID is 63. New consecutive IDs start at 64
}
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.General.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.General.cs
index 689459c9ec99..960a28561041 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.General.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.General.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using Microsoft.Extensions.Logging;
@@ -8,12 +9,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
internal sealed partial class KestrelTrace : ILogger
{
- public void ApplicationError(string connectionId, string traceIdentifier, Exception ex)
+ public void ApplicationError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier, Exception ex)
{
GeneralLog.ApplicationError(_generalLogger, connectionId, traceIdentifier, ex);
}
- public void ConnectionHeadResponseBodyWrite(string connectionId, long count)
+ public void ConnectionHeadResponseBodyWrite([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long count)
{
GeneralLog.ConnectionHeadResponseBodyWrite(_generalLogger, connectionId, count);
}
@@ -24,27 +25,27 @@ public void HeartbeatSlow(TimeSpan heartbeatDuration, TimeSpan interval, DateTim
GeneralLog.HeartbeatSlow(_generalLogger, now, heartbeatDuration, interval);
}
- public void ApplicationNeverCompleted(string connectionId)
+ public void ApplicationNeverCompleted([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
GeneralLog.ApplicationNeverCompleted(_generalLogger, connectionId);
}
- public void RequestBodyStart(string connectionId, string traceIdentifier)
+ public void RequestBodyStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
GeneralLog.RequestBodyStart(_generalLogger, connectionId, traceIdentifier);
}
- public void RequestBodyDone(string connectionId, string traceIdentifier)
+ public void RequestBodyDone([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
GeneralLog.RequestBodyDone(_generalLogger, connectionId, traceIdentifier);
}
- public void RequestBodyNotEntirelyRead(string connectionId, string traceIdentifier)
+ public void RequestBodyNotEntirelyRead([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
GeneralLog.RequestBodyNotEntirelyRead(_generalLogger, connectionId, traceIdentifier);
}
- public void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier)
+ public void RequestBodyDrainTimedOut([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
GeneralLog.RequestBodyDrainTimedOut(_generalLogger, connectionId, traceIdentifier);
}
@@ -64,7 +65,7 @@ public void Http3DisabledWithHttp1AndNoTls(EndPoint endPoint)
GeneralLog.Http3DisabledWithHttp1AndNoTls(_generalLogger, endPoint);
}
- public void RequestAborted(string connectionId, string traceIdentifier)
+ public void RequestAborted([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier)
{
GeneralLog.RequestAbortedException(_generalLogger, connectionId, traceIdentifier);
}
@@ -72,28 +73,28 @@ public void RequestAborted(string connectionId, string traceIdentifier)
private static partial class GeneralLog
{
[LoggerMessage(13, LogLevel.Error, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": An unhandled exception was thrown by the application.", EventName = "ApplicationError")]
- public static partial void ApplicationError(ILogger logger, string connectionId, string traceIdentifier, Exception ex);
+ public static partial void ApplicationError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier, Exception ex);
[LoggerMessage(18, LogLevel.Debug, @"Connection id ""{ConnectionId}"" write of ""{count}"" body bytes to non-body HEAD response.", EventName = "ConnectionHeadResponseBodyWrite")]
- public static partial void ConnectionHeadResponseBodyWrite(ILogger logger, string connectionId, long count);
+ public static partial void ConnectionHeadResponseBodyWrite(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long count);
[LoggerMessage(22, LogLevel.Warning, @"As of ""{now}"", the heartbeat has been running for ""{heartbeatDuration}"" which is longer than ""{interval}"". This could be caused by thread pool starvation.", EventName = "HeartbeatSlow")]
public static partial void HeartbeatSlow(ILogger logger, DateTimeOffset now, TimeSpan heartbeatDuration, TimeSpan interval);
[LoggerMessage(23, LogLevel.Critical, @"Connection id ""{ConnectionId}"" application never completed.", EventName = "ApplicationNeverCompleted")]
- public static partial void ApplicationNeverCompleted(ILogger logger, string connectionId);
+ public static partial void ApplicationNeverCompleted(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(25, LogLevel.Debug, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": started reading request body.", EventName = "RequestBodyStart", SkipEnabledCheck = true)]
- public static partial void RequestBodyStart(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestBodyStart(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
[LoggerMessage(26, LogLevel.Debug, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": done reading request body.", EventName = "RequestBodyDone", SkipEnabledCheck = true)]
- public static partial void RequestBodyDone(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestBodyDone(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
[LoggerMessage(32, LogLevel.Information, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the application completed without reading the entire request body.", EventName = "RequestBodyNotEntirelyRead")]
- public static partial void RequestBodyNotEntirelyRead(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestBodyNotEntirelyRead(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
[LoggerMessage(33, LogLevel.Information, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": automatic draining of the request body timed out after taking over 5 seconds.", EventName = "RequestBodyDrainTimedOut")]
- public static partial void RequestBodyDrainTimedOut(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestBodyDrainTimedOut(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
[LoggerMessage(41, LogLevel.Warning, "One or more of the following response headers have been removed because they are invalid for HTTP/2 and HTTP/3 responses: 'Connection', 'Transfer-Encoding', 'Keep-Alive', 'Upgrade' and 'Proxy-Connection'.", EventName = "InvalidResponseHeaderRemoved")]
public static partial void InvalidResponseHeaderRemoved(ILogger logger);
@@ -105,7 +106,7 @@ private static partial class GeneralLog
public static partial void Http3DisabledWithHttp1AndNoTls(ILogger logger, EndPoint endPoint);
[LoggerMessage(66, LogLevel.Debug, @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": The request was aborted by the client.", EventName = "RequestAborted")]
- public static partial void RequestAbortedException(ILogger logger, string connectionId, string traceIdentifier);
+ public static partial void RequestAbortedException(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string traceIdentifier);
// Highest shared ID is 66. New consecutive IDs start at 67
}
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs
index 84a7609f0710..5bf02849a9a6 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
using Microsoft.Extensions.Logging;
@@ -9,12 +10,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
internal sealed partial class KestrelTrace : ILogger
{
- public void Http2ConnectionError(string connectionId, Http2ConnectionErrorException ex)
+ public void Http2ConnectionError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2ConnectionErrorException ex)
{
Http2Log.Http2ConnectionError(_http2Logger, connectionId, ex);
}
- public void Http2StreamError(string connectionId, Http2StreamErrorException ex)
+ public void Http2StreamError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2StreamErrorException ex)
{
Http2Log.Http2StreamError(_http2Logger, connectionId, ex);
}
@@ -29,12 +30,12 @@ public void Http2StreamResetAbort(string traceIdentifier, Http2ErrorCode error,
Http2Log.Http2StreamResetAbort(_http2Logger, traceIdentifier, error, abortReason);
}
- public void Http2ConnectionClosing(string connectionId)
+ public void Http2ConnectionClosing([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Http2Log.Http2ConnectionClosing(_http2Logger, connectionId);
}
- public void Http2FrameReceived(string connectionId, Http2Frame frame)
+ public void Http2FrameReceived([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2Frame frame)
{
if (_http2Logger.IsEnabled(LogLevel.Trace))
{
@@ -42,22 +43,22 @@ public void Http2FrameReceived(string connectionId, Http2Frame frame)
}
}
- public void HPackEncodingError(string connectionId, int streamId, Exception ex)
+ public void HPackEncodingError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, int streamId, Exception ex)
{
Http2Log.HPackEncodingError(_http2Logger, connectionId, streamId, ex);
}
- public void Http2MaxConcurrentStreamsReached(string connectionId)
+ public void Http2MaxConcurrentStreamsReached([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Http2Log.Http2MaxConcurrentStreamsReached(_http2Logger, connectionId);
}
- public void Http2ConnectionClosed(string connectionId, int highestOpenedStreamId)
+ public void Http2ConnectionClosed([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, int highestOpenedStreamId)
{
Http2Log.Http2ConnectionClosed(_http2Logger, connectionId, highestOpenedStreamId);
}
- public void Http2FrameSending(string connectionId, Http2Frame frame)
+ public void Http2FrameSending([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2Frame frame)
{
if (_http2Logger.IsEnabled(LogLevel.Trace))
{
@@ -65,22 +66,22 @@ public void Http2FrameSending(string connectionId, Http2Frame frame)
}
}
- public void Http2QueueOperationsExceeded(string connectionId, ConnectionAbortedException ex)
+ public void Http2QueueOperationsExceeded([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, ConnectionAbortedException ex)
{
Http2Log.Http2QueueOperationsExceeded(_http2Logger, connectionId, ex);
}
- public void Http2UnexpectedDataRemaining(int streamId, string connectionId)
+ public void Http2UnexpectedDataRemaining(int streamId, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Http2Log.Http2UnexpectedDataRemaining(_http2Logger, streamId, connectionId);
}
- public void Http2ConnectionQueueProcessingCompleted(string connectionId)
+ public void Http2ConnectionQueueProcessingCompleted([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Http2Log.Http2ConnectionQueueProcessingCompleted(_http2Logger, connectionId);
}
- public void Http2UnexpectedConnectionQueueError(string connectionId, Exception ex)
+ public void Http2UnexpectedConnectionQueueError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex)
{
Http2Log.Http2UnexpectedConnectionQueueError(_http2Logger, connectionId, ex);
}
@@ -88,46 +89,46 @@ public void Http2UnexpectedConnectionQueueError(string connectionId, Exception e
private static partial class Http2Log
{
[LoggerMessage(29, LogLevel.Debug, @"Connection id ""{ConnectionId}"": HTTP/2 connection error.", EventName = "Http2ConnectionError")]
- public static partial void Http2ConnectionError(ILogger logger, string connectionId, Http2ConnectionErrorException ex);
+ public static partial void Http2ConnectionError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2ConnectionErrorException ex);
[LoggerMessage(30, LogLevel.Debug, @"Connection id ""{ConnectionId}"": HTTP/2 stream error.", EventName = "Http2StreamError")]
- public static partial void Http2StreamError(ILogger logger, string connectionId, Http2StreamErrorException ex);
+ public static partial void Http2StreamError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2StreamErrorException ex);
[LoggerMessage(31, LogLevel.Debug, @"Connection id ""{ConnectionId}"": HPACK decoding error while decoding headers for stream ID {StreamId}.", EventName = "HPackDecodingError")]
- public static partial void HPackDecodingError(ILogger logger, string connectionId, int streamId, Exception ex);
+ public static partial void HPackDecodingError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, int streamId, Exception ex);
[LoggerMessage(35, LogLevel.Debug, @"Trace id ""{TraceIdentifier}"": HTTP/2 stream error ""{error}"". A Reset is being sent to the stream.", EventName = "Http2StreamResetAbort")]
public static partial void Http2StreamResetAbort(ILogger logger, string traceIdentifier, Http2ErrorCode error, ConnectionAbortedException abortReason);
[LoggerMessage(36, LogLevel.Debug, @"Connection id ""{ConnectionId}"" is closing.", EventName = "Http2ConnectionClosing")]
- public static partial void Http2ConnectionClosing(ILogger logger, string connectionId);
+ public static partial void Http2ConnectionClosing(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(37, LogLevel.Trace, @"Connection id ""{ConnectionId}"" received {type} frame for stream ID {id} with length {length} and flags {flags}.", EventName = "Http2FrameReceived", SkipEnabledCheck = true)]
- public static partial void Http2FrameReceived(ILogger logger, string connectionId, Http2FrameType type, int id, int length, object flags);
+ public static partial void Http2FrameReceived(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2FrameType type, int id, int length, object flags);
[LoggerMessage(38, LogLevel.Information, @"Connection id ""{ConnectionId}"": HPACK encoding error while encoding headers for stream ID {StreamId}.", EventName = "HPackEncodingError")]
- public static partial void HPackEncodingError(ILogger logger, string connectionId, int streamId, Exception ex);
+ public static partial void HPackEncodingError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, int streamId, Exception ex);
[LoggerMessage(40, LogLevel.Debug, @"Connection id ""{ConnectionId}"" reached the maximum number of concurrent HTTP/2 streams allowed.", EventName = "Http2MaxConcurrentStreamsReached")]
- public static partial void Http2MaxConcurrentStreamsReached(ILogger logger, string connectionId);
+ public static partial void Http2MaxConcurrentStreamsReached(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(48, LogLevel.Debug, @"Connection id ""{ConnectionId}"" is closed. The last processed stream ID was {HighestOpenedStreamId}.", EventName = "Http2ConnectionClosed")]
- public static partial void Http2ConnectionClosed(ILogger logger, string connectionId, int highestOpenedStreamId);
+ public static partial void Http2ConnectionClosed(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, int highestOpenedStreamId);
[LoggerMessage(49, LogLevel.Trace, @"Connection id ""{ConnectionId}"" sending {type} frame for stream ID {id} with length {length} and flags {flags}.", EventName = "Http2FrameSending", SkipEnabledCheck = true)]
- public static partial void Http2FrameSending(ILogger logger, string connectionId, Http2FrameType type, int id, int length, object flags);
+ public static partial void Http2FrameSending(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http2FrameType type, int id, int length, object flags);
[LoggerMessage(60, LogLevel.Critical, @"Connection id ""{ConnectionId}"" exceeded the output operations maximum queue size.", EventName = "Http2QueueOperationsExceeded")]
- public static partial void Http2QueueOperationsExceeded(ILogger logger, string connectionId, ConnectionAbortedException ex);
+ public static partial void Http2QueueOperationsExceeded(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, ConnectionAbortedException ex);
[LoggerMessage(61, LogLevel.Critical, @"Stream {StreamId} on connection id ""{ConnectionId}"" observed an unexpected state where the streams output ended with data still remaining in the pipe.", EventName = "Http2UnexpectedDataRemaining")]
- public static partial void Http2UnexpectedDataRemaining(ILogger logger, int streamId, string connectionId);
+ public static partial void Http2UnexpectedDataRemaining(ILogger logger, int streamId, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(62, LogLevel.Debug, @"The connection queue processing loop for {ConnectionId} completed.", EventName = "Http2ConnectionQueueProcessingCompleted")]
- public static partial void Http2ConnectionQueueProcessingCompleted(ILogger logger, string connectionId);
+ public static partial void Http2ConnectionQueueProcessingCompleted(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(63, LogLevel.Critical, @"The event loop in connection {ConnectionId} failed unexpectedly.", EventName = "Http2UnexpectedConnectionQueueError")]
- public static partial void Http2UnexpectedConnectionQueueError(ILogger logger, string connectionId, Exception ex);
+ public static partial void Http2UnexpectedConnectionQueueError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
// Highest shared ID is 63. New consecutive IDs start at 64
}
diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http3.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http3.cs
index cca9dbd0eb3e..19b8e0a13e13 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http3.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http3.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3;
@@ -10,17 +11,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
internal sealed partial class KestrelTrace : ILogger
{
- public void Http3ConnectionError(string connectionId, Http3ConnectionErrorException ex)
+ public void Http3ConnectionError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http3ConnectionErrorException ex)
{
Http3Log.Http3ConnectionError(_http3Logger, connectionId, ex);
}
- public void Http3ConnectionClosing(string connectionId)
+ public void Http3ConnectionClosing([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Http3Log.Http3ConnectionClosing(_http3Logger, connectionId);
}
- public void Http3ConnectionClosed(string connectionId, long? highestOpenedStreamId)
+ public void Http3ConnectionClosed([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long? highestOpenedStreamId)
{
Http3Log.Http3ConnectionClosed(_http3Logger, connectionId, highestOpenedStreamId);
}
@@ -33,7 +34,7 @@ public void Http3StreamAbort(string traceIdentifier, Http3ErrorCode error, Conne
}
}
- public void Http3FrameReceived(string connectionId, long streamId, Http3RawFrame frame)
+ public void Http3FrameReceived([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Http3RawFrame frame)
{
if (_http3Logger.IsEnabled(LogLevel.Trace))
{
@@ -41,7 +42,7 @@ public void Http3FrameReceived(string connectionId, long streamId, Http3RawFrame
}
}
- public void Http3FrameSending(string connectionId, long streamId, Http3RawFrame frame)
+ public void Http3FrameSending([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Http3RawFrame frame)
{
if (_http3Logger.IsEnabled(LogLevel.Trace))
{
@@ -49,22 +50,22 @@ public void Http3FrameSending(string connectionId, long streamId, Http3RawFrame
}
}
- public void Http3OutboundControlStreamError(string connectionId, Exception ex)
+ public void Http3OutboundControlStreamError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex)
{
Http3Log.Http3OutboundControlStreamError(_http3Logger, connectionId, ex);
}
- public void QPackDecodingError(string connectionId, long streamId, Exception ex)
+ public void QPackDecodingError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Exception ex)
{
Http3Log.QPackDecodingError(_http3Logger, connectionId, streamId, ex);
}
- public void QPackEncodingError(string connectionId, long streamId, Exception ex)
+ public void QPackEncodingError([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Exception ex)
{
Http3Log.QPackEncodingError(_http3Logger, connectionId, streamId, ex);
}
- public void Http3GoAwayStreamId(string connectionId, long goAwayStreamId)
+ public void Http3GoAwayStreamId([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long goAwayStreamId)
{
Http3Log.Http3GoAwayStreamId(_http3Logger, connectionId, goAwayStreamId);
}
@@ -72,34 +73,34 @@ public void Http3GoAwayStreamId(string connectionId, long goAwayStreamId)
private static partial class Http3Log
{
[LoggerMessage(42, LogLevel.Debug, @"Connection id ""{ConnectionId}"": HTTP/3 connection error.", EventName = "Http3ConnectionError")]
- public static partial void Http3ConnectionError(ILogger logger, string connectionId, Http3ConnectionErrorException ex);
+ public static partial void Http3ConnectionError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Http3ConnectionErrorException ex);
[LoggerMessage(43, LogLevel.Debug, @"Connection id ""{ConnectionId}"" is closing.", EventName = "Http3ConnectionClosing")]
- public static partial void Http3ConnectionClosing(ILogger logger, string connectionId);
+ public static partial void Http3ConnectionClosing(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(44, LogLevel.Debug, @"Connection id ""{ConnectionId}"" is closed. The last processed stream ID was {HighestOpenedStreamId}.", EventName = "Http3ConnectionClosed")]
- public static partial void Http3ConnectionClosed(ILogger logger, string connectionId, long? highestOpenedStreamId);
+ public static partial void Http3ConnectionClosed(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long? highestOpenedStreamId);
[LoggerMessage(45, LogLevel.Debug, @"Trace id ""{TraceIdentifier}"": HTTP/3 stream error ""{error}"". An abort is being sent to the stream.", EventName = "Http3StreamAbort", SkipEnabledCheck = true)]
public static partial void Http3StreamAbort(ILogger logger, string traceIdentifier, string error, ConnectionAbortedException abortReason);
[LoggerMessage(46, LogLevel.Trace, @"Connection id ""{ConnectionId}"" received {type} frame for stream ID {id} with length {length}.", EventName = "Http3FrameReceived", SkipEnabledCheck = true)]
- public static partial void Http3FrameReceived(ILogger logger, string connectionId, string type, long id, long length);
+ public static partial void Http3FrameReceived(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string type, long id, long length);
[LoggerMessage(47, LogLevel.Trace, @"Connection id ""{ConnectionId}"" sending {type} frame for stream ID {id} with length {length}.", EventName = "Http3FrameSending", SkipEnabledCheck = true)]
- public static partial void Http3FrameSending(ILogger logger, string connectionId, string type, long id, long length);
+ public static partial void Http3FrameSending(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string type, long id, long length);
[LoggerMessage(50, LogLevel.Debug, @"Connection id ""{ConnectionId}"": Unexpected error when initializing outbound control stream.", EventName = "Http3OutboundControlStreamError")]
- public static partial void Http3OutboundControlStreamError(ILogger logger, string connectionId, Exception ex);
+ public static partial void Http3OutboundControlStreamError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
[LoggerMessage(51, LogLevel.Debug, @"Connection id ""{ConnectionId}"": QPACK decoding error while decoding headers for stream ID {StreamId}.", EventName = "QPackDecodingError")]
- public static partial void QPackDecodingError(ILogger logger, string connectionId, long streamId, Exception ex);
+ public static partial void QPackDecodingError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Exception ex);
[LoggerMessage(52, LogLevel.Information, @"Connection id ""{ConnectionId}"": QPACK encoding error while encoding headers for stream ID {StreamId}.", EventName = "QPackEncodingError")]
- public static partial void QPackEncodingError(ILogger logger, string connectionId, long streamId, Exception ex);
+ public static partial void QPackEncodingError(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long streamId, Exception ex);
[LoggerMessage(53, LogLevel.Debug, @"Connection id ""{ConnectionId}"": GOAWAY stream ID {GoAwayStreamId}.", EventName = "Http3GoAwayHighestOpenedStreamId")]
- public static partial void Http3GoAwayStreamId(ILogger logger, string connectionId, long goAwayStreamId);
+ public static partial void Http3GoAwayStreamId(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long goAwayStreamId);
// Highest shared ID is 63. New consecutive IDs start at 64
}
diff --git a/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs b/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs
index 25a23ee3f491..e365e8c57bfa 100644
--- a/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs
+++ b/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs
@@ -3,6 +3,7 @@
using System.Buffers;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using System.Net.Security;
using System.Security;
@@ -577,7 +578,7 @@ internal static partial class HttpsConnectionMiddlewareLoggerExtensions
public static partial void AuthenticationTimedOut(this ILogger logger);
[LoggerMessage(3, LogLevel.Debug, "Connection {ConnectionId} established using the following protocol: {Protocol}", EventName = "HttpsConnectionEstablished")]
- public static partial void HttpsConnectionEstablished(this ILogger logger, string connectionId, SslProtocols protocol);
+ public static partial void HttpsConnectionEstablished(this ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, SslProtocols protocol);
[LoggerMessage(4, LogLevel.Information, "HTTP/2 over TLS is not supported on Windows versions older than Windows 10 and Windows Server 2016 due to incompatible ciphers or missing ALPN support. Falling back to HTTP/1.1 instead.",
EventName = "Http2DefaultCiphersInsufficient")]
diff --git a/src/Servers/Kestrel/Transport.NamedPipes/src/Internal/NamedPipeLog.cs b/src/Servers/Kestrel/Transport.NamedPipes/src/Internal/NamedPipeLog.cs
index 1e50f7eccdf6..9ec30b5f2cd4 100644
--- a/src/Servers/Kestrel/Transport.NamedPipes/src/Internal/NamedPipeLog.cs
+++ b/src/Servers/Kestrel/Transport.NamedPipes/src/Internal/NamedPipeLog.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Connections;
using Microsoft.Extensions.Logging;
@@ -9,7 +10,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.Internal;
internal static partial class NamedPipeLog
{
[LoggerMessage(1, LogLevel.Debug, @"Connection id ""{ConnectionId}"" accepted.", EventName = "AcceptedConnection", SkipEnabledCheck = true)]
- private static partial void AcceptedConnectionCore(ILogger logger, string connectionId);
+ private static partial void AcceptedConnectionCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void AcceptedConnection(ILogger logger, BaseConnectionContext connection)
{
@@ -20,7 +21,7 @@ public static void AcceptedConnection(ILogger logger, BaseConnectionContext conn
}
[LoggerMessage(2, LogLevel.Debug, @"Connection id ""{ConnectionId}"" unexpected error.", EventName = "ConnectionError", SkipEnabledCheck = true)]
- private static partial void ConnectionErrorCore(ILogger logger, string connectionId, Exception ex);
+ private static partial void ConnectionErrorCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
public static void ConnectionError(ILogger logger, BaseConnectionContext connection, Exception ex)
{
@@ -34,7 +35,7 @@ public static void ConnectionError(ILogger logger, BaseConnectionContext connect
public static partial void ConnectionListenerAborted(ILogger logger, Exception exception);
[LoggerMessage(4, LogLevel.Debug, @"Connection id ""{ConnectionId}"" paused.", EventName = "ConnectionPause", SkipEnabledCheck = true)]
- private static partial void ConnectionPauseCore(ILogger logger, string connectionId);
+ private static partial void ConnectionPauseCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionPause(ILogger logger, NamedPipeConnection connection)
{
@@ -45,7 +46,7 @@ public static void ConnectionPause(ILogger logger, NamedPipeConnection connectio
}
[LoggerMessage(5, LogLevel.Debug, @"Connection id ""{ConnectionId}"" resumed.", EventName = "ConnectionResume", SkipEnabledCheck = true)]
- private static partial void ConnectionResumeCore(ILogger logger, string connectionId);
+ private static partial void ConnectionResumeCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionResume(ILogger logger, NamedPipeConnection connection)
{
@@ -56,7 +57,7 @@ public static void ConnectionResume(ILogger logger, NamedPipeConnection connecti
}
[LoggerMessage(6, LogLevel.Debug, @"Connection id ""{ConnectionId}"" received end of stream.", EventName = "ConnectionReadEnd", SkipEnabledCheck = true)]
- private static partial void ConnectionReadEndCore(ILogger logger, string connectionId);
+ private static partial void ConnectionReadEndCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionReadEnd(ILogger logger, NamedPipeConnection connection)
{
@@ -67,7 +68,7 @@ public static void ConnectionReadEnd(ILogger logger, NamedPipeConnection connect
}
[LoggerMessage(7, LogLevel.Debug, @"Connection id ""{ConnectionId}"" disconnecting stream because: ""{Reason}""", EventName = "ConnectionDisconnect", SkipEnabledCheck = true)]
- private static partial void ConnectionDisconnectCore(ILogger logger, string connectionId, string reason);
+ private static partial void ConnectionDisconnectCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string reason);
public static void ConnectionDisconnect(ILogger logger, NamedPipeConnection connection, string reason)
{
diff --git a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicLog.cs b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicLog.cs
index 7077f79ca6fb..af556af1d502 100644
--- a/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicLog.cs
+++ b/src/Servers/Kestrel/Transport.Quic/src/Internal/QuicLog.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Security;
using Microsoft.AspNetCore.Connections;
@@ -11,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal;
internal static partial class QuicLog
{
[LoggerMessage(1, LogLevel.Debug, @"Connection id ""{ConnectionId}"" accepted.", EventName = "AcceptedConnection", SkipEnabledCheck = true)]
- private static partial void AcceptedConnectionCore(ILogger logger, string connectionId);
+ private static partial void AcceptedConnectionCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void AcceptedConnection(ILogger logger, BaseConnectionContext connection)
{
@@ -22,7 +23,7 @@ public static void AcceptedConnection(ILogger logger, BaseConnectionContext conn
}
[LoggerMessage(2, LogLevel.Debug, @"Stream id ""{ConnectionId}"" type {StreamType} accepted.", EventName = "AcceptedStream", SkipEnabledCheck = true)]
- private static partial void AcceptedStreamCore(ILogger logger, string connectionId, StreamType streamType);
+ private static partial void AcceptedStreamCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, StreamType streamType);
public static void AcceptedStream(ILogger logger, QuicStreamContext streamContext)
{
@@ -33,7 +34,7 @@ public static void AcceptedStream(ILogger logger, QuicStreamContext streamContex
}
[LoggerMessage(3, LogLevel.Debug, @"Stream id ""{ConnectionId}"" type {StreamType} connected.", EventName = "ConnectedStream", SkipEnabledCheck = true)]
- private static partial void ConnectedStreamCore(ILogger logger, string connectionId, StreamType streamType);
+ private static partial void ConnectedStreamCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, StreamType streamType);
public static void ConnectedStream(ILogger logger, QuicStreamContext streamContext)
{
@@ -44,7 +45,7 @@ public static void ConnectedStream(ILogger logger, QuicStreamContext streamConte
}
[LoggerMessage(4, LogLevel.Debug, @"Connection id ""{ConnectionId}"" unexpected error.", EventName = "ConnectionError", SkipEnabledCheck = true)]
- private static partial void ConnectionErrorCore(ILogger logger, string connectionId, Exception ex);
+ private static partial void ConnectionErrorCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
public static void ConnectionError(ILogger logger, BaseConnectionContext connection, Exception ex)
{
@@ -55,7 +56,7 @@ public static void ConnectionError(ILogger logger, BaseConnectionContext connect
}
[LoggerMessage(5, LogLevel.Debug, @"Connection id ""{ConnectionId}"" aborted by peer with error code {ErrorCode}.", EventName = "ConnectionAborted", SkipEnabledCheck = true)]
- private static partial void ConnectionAbortedCore(ILogger logger, string connectionId, long errorCode, Exception ex);
+ private static partial void ConnectionAbortedCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode, Exception ex);
public static void ConnectionAborted(ILogger logger, BaseConnectionContext connection, long errorCode, Exception ex)
{
@@ -66,7 +67,7 @@ public static void ConnectionAborted(ILogger logger, BaseConnectionContext conne
}
[LoggerMessage(6, LogLevel.Debug, @"Connection id ""{ConnectionId}"" aborted by application with error code {ErrorCode} because: ""{Reason}"".", EventName = "ConnectionAbort", SkipEnabledCheck = true)]
- private static partial void ConnectionAbortCore(ILogger logger, string connectionId, long errorCode, string reason);
+ private static partial void ConnectionAbortCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode, string reason);
public static void ConnectionAbort(ILogger logger, BaseConnectionContext connection, long errorCode, string reason)
{
@@ -77,7 +78,7 @@ public static void ConnectionAbort(ILogger logger, BaseConnectionContext connect
}
[LoggerMessage(7, LogLevel.Debug, @"Stream id ""{ConnectionId}"" unexpected error.", EventName = "StreamError", SkipEnabledCheck = true)]
- private static partial void StreamErrorCore(ILogger logger, string connectionId, Exception ex);
+ private static partial void StreamErrorCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
public static void StreamError(ILogger logger, QuicStreamContext streamContext, Exception ex)
{
@@ -88,7 +89,7 @@ public static void StreamError(ILogger logger, QuicStreamContext streamContext,
}
[LoggerMessage(8, LogLevel.Debug, @"Stream id ""{ConnectionId}"" paused.", EventName = "StreamPause", SkipEnabledCheck = true)]
- private static partial void StreamPauseCore(ILogger logger, string connectionId);
+ private static partial void StreamPauseCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamPause(ILogger logger, QuicStreamContext streamContext)
{
@@ -99,7 +100,7 @@ public static void StreamPause(ILogger logger, QuicStreamContext streamContext)
}
[LoggerMessage(9, LogLevel.Debug, @"Stream id ""{ConnectionId}"" resumed.", EventName = "StreamResume", SkipEnabledCheck = true)]
- private static partial void StreamResumeCore(ILogger logger, string connectionId);
+ private static partial void StreamResumeCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamResume(ILogger logger, QuicStreamContext streamContext)
{
@@ -110,7 +111,7 @@ public static void StreamResume(ILogger logger, QuicStreamContext streamContext)
}
[LoggerMessage(10, LogLevel.Debug, @"Stream id ""{ConnectionId}"" shutting down writes because: ""{Reason}"".", EventName = "StreamShutdownWrite", SkipEnabledCheck = true)]
- private static partial void StreamShutdownWriteCore(ILogger logger, string connectionId, string reason);
+ private static partial void StreamShutdownWriteCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string reason);
public static void StreamShutdownWrite(ILogger logger, QuicStreamContext streamContext, string reason)
{
@@ -121,7 +122,7 @@ public static void StreamShutdownWrite(ILogger logger, QuicStreamContext streamC
}
[LoggerMessage(11, LogLevel.Debug, @"Stream id ""{ConnectionId}"" read aborted by peer with error code {ErrorCode}.", EventName = "StreamAbortedRead", SkipEnabledCheck = true)]
- private static partial void StreamAbortedReadCore(ILogger logger, string connectionId, long errorCode);
+ private static partial void StreamAbortedReadCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode);
public static void StreamAbortedRead(ILogger logger, QuicStreamContext streamContext, long errorCode)
{
@@ -132,7 +133,7 @@ public static void StreamAbortedRead(ILogger logger, QuicStreamContext streamCon
}
[LoggerMessage(12, LogLevel.Debug, @"Stream id ""{ConnectionId}"" write aborted by peer with error code {ErrorCode}.", EventName = "StreamAbortedWrite", SkipEnabledCheck = true)]
- private static partial void StreamAbortedWriteCore(ILogger logger, string connectionId, long errorCode);
+ private static partial void StreamAbortedWriteCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode);
public static void StreamAbortedWrite(ILogger logger, QuicStreamContext streamContext, long errorCode)
{
@@ -143,7 +144,7 @@ public static void StreamAbortedWrite(ILogger logger, QuicStreamContext streamCo
}
[LoggerMessage(13, LogLevel.Debug, @"Stream id ""{ConnectionId}"" aborted by application with error code {ErrorCode} because: ""{Reason}"".", EventName = "StreamAbort", SkipEnabledCheck = true)]
- private static partial void StreamAbortCore(ILogger logger, string connectionId, long errorCode, string reason);
+ private static partial void StreamAbortCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode, string reason);
public static void StreamAbort(ILogger logger, QuicStreamContext streamContext, long errorCode, string reason)
{
@@ -154,7 +155,7 @@ public static void StreamAbort(ILogger logger, QuicStreamContext streamContext,
}
[LoggerMessage(14, LogLevel.Debug, @"Stream id ""{ConnectionId}"" read side aborted by application with error code {ErrorCode} because: ""{Reason}"".", EventName = "StreamAbortRead", SkipEnabledCheck = true)]
- private static partial void StreamAbortReadCore(ILogger logger, string connectionId, long errorCode, string reason);
+ private static partial void StreamAbortReadCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode, string reason);
public static void StreamAbortRead(ILogger logger, QuicStreamContext streamContext, long errorCode, string reason)
{
@@ -165,7 +166,7 @@ public static void StreamAbortRead(ILogger logger, QuicStreamContext streamConte
}
[LoggerMessage(15, LogLevel.Debug, @"Stream id ""{ConnectionId}"" write side aborted by application with error code {ErrorCode} because: ""{Reason}"".", EventName = "StreamAbortWrite", SkipEnabledCheck = true)]
- private static partial void StreamAbortWriteCore(ILogger logger, string connectionId, long errorCode, string reason);
+ private static partial void StreamAbortWriteCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long errorCode, string reason);
public static void StreamAbortWrite(ILogger logger, QuicStreamContext streamContext, long errorCode, string reason)
{
@@ -176,7 +177,7 @@ public static void StreamAbortWrite(ILogger logger, QuicStreamContext streamCont
}
[LoggerMessage(16, LogLevel.Trace, @"Stream id ""{ConnectionId}"" pooled for reuse.", EventName = "StreamPooled", SkipEnabledCheck = true)]
- private static partial void StreamPooledCore(ILogger logger, string connectionId);
+ private static partial void StreamPooledCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamPooled(ILogger logger, QuicStreamContext streamContext)
{
@@ -187,7 +188,7 @@ public static void StreamPooled(ILogger logger, QuicStreamContext streamContext)
}
[LoggerMessage(17, LogLevel.Trace, @"Stream id ""{ConnectionId}"" reused from pool.", EventName = "StreamReused", SkipEnabledCheck = true)]
- private static partial void StreamReusedCore(ILogger logger, string connectionId);
+ private static partial void StreamReusedCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamReused(ILogger logger, QuicStreamContext streamContext)
{
@@ -211,7 +212,7 @@ public static void StreamReused(ILogger logger, QuicStreamContext streamContext)
public static partial void ConnectionListenerAborted(ILogger logger, Exception exception);
[LoggerMessage(22, LogLevel.Debug, @"Stream id ""{ConnectionId}"" read timed out.", EventName = "StreamTimeoutRead", SkipEnabledCheck = true)]
- private static partial void StreamTimeoutReadCore(ILogger logger, string connectionId);
+ private static partial void StreamTimeoutReadCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamTimeoutRead(ILogger logger, QuicStreamContext streamContext)
{
@@ -222,7 +223,7 @@ public static void StreamTimeoutRead(ILogger logger, QuicStreamContext streamCon
}
[LoggerMessage(23, LogLevel.Debug, @"Stream id ""{ConnectionId}"" write timed out.", EventName = "StreamTimeoutWrite", SkipEnabledCheck = true)]
- private static partial void StreamTimeoutWriteCore(ILogger logger, string connectionId);
+ private static partial void StreamTimeoutWriteCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void StreamTimeoutWrite(ILogger logger, QuicStreamContext streamContext)
{
diff --git a/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsLog.cs b/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsLog.cs
index 7d5c791fc98f..c3283779b1bf 100644
--- a/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsLog.cs
+++ b/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsLog.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal;
@@ -10,7 +11,7 @@ internal static partial class SocketsLog
// Reserved: Event ID 3, EventName = ConnectionRead
[LoggerMessage(6, LogLevel.Debug, @"Connection id ""{ConnectionId}"" received FIN.", EventName = "ConnectionReadFin", SkipEnabledCheck = true)]
- private static partial void ConnectionReadFinCore(ILogger logger, string connectionId);
+ private static partial void ConnectionReadFinCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionReadFin(ILogger logger, SocketConnection connection)
{
@@ -21,7 +22,7 @@ public static void ConnectionReadFin(ILogger logger, SocketConnection connection
}
[LoggerMessage(7, LogLevel.Debug, @"Connection id ""{ConnectionId}"" sending FIN because: ""{Reason}""", EventName = "ConnectionWriteFin", SkipEnabledCheck = true)]
- private static partial void ConnectionWriteFinCore(ILogger logger, string connectionId, string reason);
+ private static partial void ConnectionWriteFinCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string reason);
public static void ConnectionWriteFin(ILogger logger, SocketConnection connection, string reason)
{
@@ -36,7 +37,7 @@ public static void ConnectionWriteFin(ILogger logger, SocketConnection connectio
// Reserved: Event ID 12, EventName = ConnectionWriteCallback
[LoggerMessage(14, LogLevel.Debug, @"Connection id ""{ConnectionId}"" communication error.", EventName = "ConnectionError", SkipEnabledCheck = true)]
- private static partial void ConnectionErrorCore(ILogger logger, string connectionId, Exception ex);
+ private static partial void ConnectionErrorCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, Exception ex);
public static void ConnectionError(ILogger logger, SocketConnection connection, Exception ex)
{
@@ -47,7 +48,7 @@ public static void ConnectionError(ILogger logger, SocketConnection connection,
}
[LoggerMessage(19, LogLevel.Debug, @"Connection id ""{ConnectionId}"" reset.", EventName = "ConnectionReset", SkipEnabledCheck = true)]
- public static partial void ConnectionReset(ILogger logger, string connectionId);
+ public static partial void ConnectionReset(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionReset(ILogger logger, SocketConnection connection)
{
@@ -58,7 +59,7 @@ public static void ConnectionReset(ILogger logger, SocketConnection connection)
}
[LoggerMessage(4, LogLevel.Debug, @"Connection id ""{ConnectionId}"" paused.", EventName = "ConnectionPause", SkipEnabledCheck = true)]
- private static partial void ConnectionPauseCore(ILogger logger, string connectionId);
+ private static partial void ConnectionPauseCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionPause(ILogger logger, SocketConnection connection)
{
@@ -69,7 +70,7 @@ public static void ConnectionPause(ILogger logger, SocketConnection connection)
}
[LoggerMessage(5, LogLevel.Debug, @"Connection id ""{ConnectionId}"" resumed.", EventName = "ConnectionResume", SkipEnabledCheck = true)]
- private static partial void ConnectionResumeCore(ILogger logger, string connectionId);
+ private static partial void ConnectionResumeCore(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
public static void ConnectionResume(ILogger logger, SocketConnection connection)
{
diff --git a/src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.Log.cs b/src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.Log.cs
index 7d54757cec6b..4a8f93d88594 100644
--- a/src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.Log.cs
+++ b/src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.Log.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using Microsoft.AspNetCore.Connections;
using Microsoft.Extensions.Logging;
@@ -45,7 +46,7 @@ public static void StartingTransport(ILogger logger, HttpTransportType transport
public static partial void EstablishingConnection(ILogger logger, Uri url);
[LoggerMessage(9, LogLevel.Debug, "Established connection '{ConnectionId}' with the server.", EventName = "Established")]
- public static partial void ConnectionEstablished(ILogger logger, string connectionId);
+ public static partial void ConnectionEstablished(ILogger logger, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId);
[LoggerMessage(10, LogLevel.Error, "Failed to start connection. Error getting negotiation response from '{Url}'.", EventName = "ErrorWithNegotiation")]
public static partial void ErrorWithNegotiation(ILogger logger, Uri url, Exception exception);
diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
index 8ec21012979f..2430b49d8b89 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
@@ -3,6 +3,7 @@
using System.Collections.Concurrent;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using System.Security.Claims;
using System.Security.Principal;
@@ -61,7 +62,7 @@ internal sealed partial class HttpConnectionContext : ConnectionContext,
/// Creates the DefaultConnectionContext without Pipes to avoid upfront allocations.
/// The caller is expected to set the and pipes manually.
///
- public HttpConnectionContext(string connectionId, string connectionToken, ILogger logger, MetricsContext metricsContext,
+ public HttpConnectionContext([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string connectionToken, ILogger logger, MetricsContext metricsContext,
IDuplexPipe transport, IDuplexPipe application, HttpConnectionDispatcherOptions options, bool useAcks)
{
Transport = transport;
diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsEventSource.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsEventSource.cs
index a96d84664b1b..1278affe664d 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsEventSource.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsEventSource.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
namespace Microsoft.AspNetCore.Http.Connections.Internal;
@@ -35,7 +36,7 @@ internal HttpConnectionsEventSource(string eventSourceName)
// This has to go through NonEvent because only Primitive types are allowed
// in function parameters for Events
[NonEvent]
- public void ConnectionStop(string connectionId, long startTimestamp, long currentTimestamp)
+ public void ConnectionStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, long startTimestamp, long currentTimestamp)
{
Interlocked.Increment(ref _connectionsStopped);
Interlocked.Decrement(ref _currentConnections);
@@ -53,7 +54,7 @@ public void ConnectionStop(string connectionId, long startTimestamp, long curren
}
[Event(eventId: 1, Level = EventLevel.Informational, Message = "Started connection '{0}'.")]
- public void ConnectionStart(string connectionId)
+ public void ConnectionStart([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Interlocked.Increment(ref _connectionsStarted);
Interlocked.Increment(ref _currentConnections);
@@ -65,10 +66,10 @@ public void ConnectionStart(string connectionId)
}
[Event(eventId: 2, Level = EventLevel.Informational, Message = "Stopped connection '{0}'.")]
- private void ConnectionStop(string connectionId) => WriteEvent(2, connectionId);
+ private void ConnectionStop([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId) => WriteEvent(2, connectionId);
[Event(eventId: 3, Level = EventLevel.Informational, Message = "Connection '{0}' timed out.")]
- public void ConnectionTimedOut(string connectionId)
+ public void ConnectionTimedOut([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId)
{
Interlocked.Increment(ref _connectionsTimedOut);
diff --git a/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsServerTransport.cs b/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsServerTransport.cs
index bf4f9d85d97b..a7451543f856 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsServerTransport.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsServerTransport.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using System.IO.Pipelines;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
@@ -14,11 +15,11 @@ internal sealed partial class ServerSentEventsServerTransport : IHttpTransport
private readonly ILogger _logger;
private readonly HttpConnectionContext? _connection;
- public ServerSentEventsServerTransport(PipeReader application, string connectionId, ILoggerFactory loggerFactory)
+ public ServerSentEventsServerTransport(PipeReader application, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, ILoggerFactory loggerFactory)
: this(application, connectionId, connection: null, loggerFactory)
{ }
- public ServerSentEventsServerTransport(PipeReader application, string connectionId, HttpConnectionContext? connection, ILoggerFactory loggerFactory)
+ public ServerSentEventsServerTransport(PipeReader application, [StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, HttpConnectionContext? connection, ILoggerFactory loggerFactory)
{
_application = application;
_connectionId = connectionId;
diff --git a/src/SignalR/common/Shared/ClientResultsManager.cs b/src/SignalR/common/Shared/ClientResultsManager.cs
index 18fb5a950538..cc9738efd1ed 100644
--- a/src/SignalR/common/Shared/ClientResultsManager.cs
+++ b/src/SignalR/common/Shared/ClientResultsManager.cs
@@ -15,7 +15,7 @@ internal sealed class ClientResultsManager : IInvocationBinder
{
private readonly ConcurrentDictionary Complete)> _pendingInvocations = new();
- public Task AddInvocation(string connectionId, string invocationId, CancellationToken cancellationToken)
+ public Task AddInvocation([StringSyntax(StringSyntaxAttribute.GuidFormat)] string connectionId, string invocationId, CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSourceWithCancellation(this, connectionId, invocationId, cancellationToken);
var result = _pendingInvocations.TryAdd(invocationId, (typeof(T), connectionId, tcs, static (state, completionMessage) =>
@@ -38,7 +38,7 @@ public Task AddInvocation(string connectionId, string invocationId, Cancel
return tcs.Task;
}
- public void AddInvocation(string invocationId, (Type Type, string ConnectionId, object Tcs, Action