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 @@ -779,7 +779,7 @@ public static void SetActivityId(ref Guid id)
[System.Security.SecurityCritical]
public static Guid CreateActivityId()
{
Guid newId = new Guid();
Guid newId = new();
UnsafeNativeMethods.EventActivityIdControl((int)ActivityControl.EVENT_ACTIVITY_CTRL_CREATE_ID, ref newId);
return newId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public EventProviderTraceListener(string providerId, string name, string delimit

private void InitProvider(string providerId)
{
Guid controlGuid = new Guid(providerId);
Guid controlGuid = new(providerId);
//
// Create The ETW TraceProvider
//
Expand Down Expand Up @@ -148,7 +148,7 @@ public sealed override void TraceData(TraceEventCache eventCache, string source,
return;
}

StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
StringBuilder dataString = new(s_defaultPayloadSize);

if (data != null)
{
Expand Down Expand Up @@ -177,7 +177,7 @@ public sealed override void TraceData(TraceEventCache eventCache, string source,
}

int index;
StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
StringBuilder dataString = new(s_defaultPayloadSize);

if ((data != null) && (data.Length > 0))
{
Expand Down Expand Up @@ -242,7 +242,7 @@ public sealed override void TraceEvent(TraceEventCache eventCache, string source
return;
}

StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
StringBuilder dataString = new(s_defaultPayloadSize);
dataString.Append(message);

_provider.WriteMessageEvent(dataString.ToString(),
Expand Down Expand Up @@ -278,7 +278,7 @@ public sealed override void TraceEvent(TraceEventCache eventCache, string source

public override void Fail(string message, string detailMessage)
{
StringBuilder failMessage = new StringBuilder(message);
StringBuilder failMessage = new(message);
if (detailMessage != null)
{
failMessage.Append(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public static string EvtFormatMessage(EventLogHandle handle, uint msgId)
{
int bufferNeeded;

StringBuilder sb = new StringBuilder(null);
StringBuilder sb = new(null);
bool status = UnsafeNativeMethods.EvtFormatMessage(handle, EventLogHandle.Zero, msgId, 0, null, UnsafeNativeMethods.EvtFormatMessageFlags.EvtFormatMessageId, 0, sb, out bufferNeeded);
int error = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -672,9 +672,9 @@ public static object EvtGetChannelConfigProperty(EventLogHandle handle, UnsafeNa
[System.Security.SecuritySafeCritical]
public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNativeMethods.EvtChannelConfigPropertyId enumType, object val)
{
UnsafeNativeMethods.EvtVariant varVal = new UnsafeNativeMethods.EvtVariant();
UnsafeNativeMethods.EvtVariant varVal = new();

CoTaskMemSafeHandle taskMem = new CoTaskMemSafeHandle();
CoTaskMemSafeHandle taskMem = new();

using (taskMem)
{
Expand Down Expand Up @@ -762,7 +762,7 @@ public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNati
[System.Security.SecurityCritical]
public static string EvtNextChannelPath(EventLogHandle handle, ref bool finish)
{
StringBuilder sb = new StringBuilder(null);
StringBuilder sb = new(null);
int channelNameNeeded;

bool status = UnsafeNativeMethods.EvtNextChannelPath(handle, 0, sb, out channelNameNeeded);
Expand Down Expand Up @@ -791,7 +791,7 @@ public static string EvtNextChannelPath(EventLogHandle handle, ref bool finish)
[System.Security.SecurityCritical]
public static string EvtNextPublisherId(EventLogHandle handle, ref bool finish)
{
StringBuilder sb = new StringBuilder(null);
StringBuilder sb = new(null);
int ProviderIdNeeded;

bool status = UnsafeNativeMethods.EvtNextPublisherId(handle, 0, sb, out ProviderIdNeeded);
Expand Down Expand Up @@ -976,7 +976,7 @@ public static IList<object> EvtRenderBufferWithContextUserOrValues(EventLogHandl
if (!status)
ThrowEventLogException(win32Error);

List<object> valuesList = new List<object>(propCount);
List<object> valuesList = new(propCount);
if (propCount > 0)
{
pointer = buffer;
Expand All @@ -1001,7 +1001,7 @@ public static IList<object> EvtRenderBufferWithContextUserOrValues(EventLogHandl
public static string EvtFormatMessageRenderName(EventLogHandle pmHandle, EventLogHandle eventHandle, UnsafeNativeMethods.EvtFormatMessageFlags flag)
{
int bufferNeeded;
StringBuilder sb = new StringBuilder(null);
StringBuilder sb = new(null);

bool status = UnsafeNativeMethods.EvtFormatMessage(pmHandle, eventHandle, 0, 0, null, flag, 0, sb, out bufferNeeded);
int error = Marshal.GetLastWin32Error();
Expand Down Expand Up @@ -1059,7 +1059,7 @@ public static IEnumerable<string> EvtFormatMessageRenderKeywords(EventLogHandle

try
{
List<string> keywordsList = new List<string>();
List<string> keywordsList = new();
bool status = UnsafeNativeMethods.EvtFormatMessageBuffer(pmHandle, eventHandle, 0, 0, IntPtr.Zero, flag, 0, IntPtr.Zero, out bufferNeeded);
int error = Marshal.GetLastWin32Error();

Expand Down Expand Up @@ -1164,7 +1164,7 @@ public static string EvtFormatMessageFormatDescription(EventLogHandle handle, Ev
stringVariants[i].StringVal = values[i];
}

StringBuilder sb = new StringBuilder(null);
StringBuilder sb = new(null);
bool status = UnsafeNativeMethods.EvtFormatMessage(handle, eventHandle, 0xffffffff, values.Length, stringVariants, UnsafeNativeMethods.EvtFormatMessageFlags.EvtFormatMessageEvent, 0, sb, out bufferNeeded);
int error = Marshal.GetLastWin32Error();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal static extern int FormatMessage(int dwFlags, IntPtr lpSource,
[SecurityCritical]
internal static string GetMessage(int errorCode)
{
StringBuilder sb = new StringBuilder(512);
StringBuilder sb = new(512);
int result = UnsafeNativeMethods.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
UnsafeNativeMethods.s_NULL, errorCode, 0, sb, sb.Capacity, UnsafeNativeMethods.s_NULL);
Expand Down