Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static unsafe int AcquireDefaultCredential(
ref outCredential._handle,
out timeStamp);

if (NetEventSource.Log.IsEnabled()) NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");

if (errorCode != 0)
{
Expand Down Expand Up @@ -265,7 +265,7 @@ public static unsafe int AcquireCredentialsHandle(
ref outCredential._handle,
out _);

if (NetEventSource.Log.IsEnabled()) NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");

if (errorCode != 0)
{
Expand Down Expand Up @@ -296,7 +296,7 @@ public static unsafe int AcquireCredentialsHandle(
ref outCredential._handle,
out timeStamp);

if (NetEventSource.Log.IsEnabled()) NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");

if (errorCode != 0)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// 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.Tracing;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Diagnostics;

namespace System.Net
{
internal sealed partial class NetEventSource
{
private const int AssociateEventId = 3;

/// <summary>Logs a relationship between two objects.</summary>
/// <param name="first">The first object.</param>
/// <param name="second">The second object.</param>
/// <param name="memberName">The calling member.</param>
[NonEvent]
public static void Associate(object first, object second, [CallerMemberName] string? memberName = null) =>
Associate(first, first, second, memberName);

/// <summary>Logs a relationship between two objects.</summary>
/// <param name="thisOrContextObject">`this`, or another object that serves to provide context for the operation.</param>
/// <param name="first">The first object.</param>
/// <param name="second">The second object.</param>
/// <param name="memberName">The calling member.</param>
[NonEvent]
public static void Associate(object? thisOrContextObject, object first, object second, [CallerMemberName] string? memberName = null) =>
Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second));

[Event(AssociateEventId, Level = EventLevel.Informational, Keywords = Keywords.Default, Message = "[{2}]<-->[{3}]")]
private void Associate(string thisOrContextObject, string? memberName, string first, string second)
{
Debug.Assert(IsEnabled());
WriteEvent(AssociateEventId, thisOrContextObject, memberName ?? MissingMember, first, second);
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = EventSourceSuppressMessage)]
[NonEvent]
private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? arg3, string? arg4)
{
arg1 ??= "";
arg2 ??= "";
arg3 ??= "";
arg4 ??= "";

fixed (char* string1Bytes = arg1)
fixed (char* string2Bytes = arg2)
fixed (char* string3Bytes = arg3)
fixed (char* string4Bytes = arg4)
{
const int NumEventDatas = 4;
EventData* descrs = stackalloc EventData[NumEventDatas];

descrs[0] = new EventData
{
DataPointer = (IntPtr)string1Bytes,
Size = ((arg1.Length + 1) * 2)
};
descrs[1] = new EventData
{
DataPointer = (IntPtr)string2Bytes,
Size = ((arg2.Length + 1) * 2)
};
descrs[2] = new EventData
{
DataPointer = (IntPtr)string3Bytes,
Size = ((arg3.Length + 1) * 2)
};
descrs[3] = new EventData
{
DataPointer = (IntPtr)string4Bytes,
Size = ((arg4.Length + 1) * 2)
};

WriteEventCore(eventId, NumEventDatas, descrs);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// 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.Tracing;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System.Net
{
internal sealed partial class NetEventSource
{
private const int DumpArrayEventId = 4;
private const int MaxDumpSize = 1024;

[NonEvent]
public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, [CallerMemberName] string? memberName = null) =>
DumpBuffer(thisOrContextObject, buffer.AsSpan(), memberName);

/// <summary>Logs the contents of a buffer.</summary>
/// <param name="thisOrContextObject">`this`, or another object that serves to provide context for the operation.</param>
/// <param name="buffer">The buffer to be logged.</param>
/// <param name="offset">The starting offset from which to log.</param>
/// <param name="count">The number of bytes to log.</param>
/// <param name="memberName">The calling member.</param>
[NonEvent]
public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, int offset, int count, [CallerMemberName] string? memberName = null) =>
DumpBuffer(thisOrContextObject, buffer.AsSpan(offset, count), memberName);

/// <summary>Logs the contents of a buffer.</summary>
/// <param name="thisOrContextObject">`this`, or another object that serves to provide context for the operation.</param>
/// <param name="buffer">The buffer to be logged.</param>
/// <param name="memberName">The calling member.</param>
[NonEvent]
public static void DumpBuffer(object? thisOrContextObject, ReadOnlySpan<byte> buffer, [CallerMemberName] string? memberName = null) =>
Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer.Slice(0, Math.Min(buffer.Length, MaxDumpSize)).ToArray());

[Event(DumpArrayEventId, Level = EventLevel.Verbose, Keywords = Keywords.Debug)]
private unsafe void DumpBuffer(string thisOrContextObject, string? memberName, byte[] buffer) =>
WriteEvent(DumpArrayEventId, thisOrContextObject, memberName ?? MissingMember, buffer);

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = EventSourceSuppressMessage)]
[NonEvent]
private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, byte[]? arg3)
{
arg1 ??= "";
arg2 ??= "";
arg3 ??= Array.Empty<byte>();

fixed (char* arg1Ptr = arg1)
fixed (char* arg2Ptr = arg2)
fixed (byte* arg3Ptr = arg3)
{
int bufferLength = arg3.Length;
const int NumEventDatas = 4;
EventData* descrs = stackalloc EventData[NumEventDatas];

descrs[0] = new EventData
{
DataPointer = (IntPtr)arg1Ptr,
Size = (arg1.Length + 1) * sizeof(char)
};
descrs[1] = new EventData
{
DataPointer = (IntPtr)arg2Ptr,
Size = (arg2.Length + 1) * sizeof(char)
};
descrs[2] = new EventData
{
DataPointer = (IntPtr)(&bufferLength),
Size = 4
};
descrs[3] = new EventData
{
DataPointer = (IntPtr)arg3Ptr,
Size = bufferLength
};

WriteEventCore(eventId, NumEventDatas, descrs);
}
}
}
}
Loading