Fix IDE0090: Simplify new expression part 5 (#14301)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0090
This commit is contained in:
parent
18717c529b
commit
e0cda04d86
|
@ -779,7 +779,7 @@ namespace System.Diagnostics.Eventing
|
|||
[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;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace System.Diagnostics.Eventing
|
|||
|
||||
private void InitProvider(string providerId)
|
||||
{
|
||||
Guid controlGuid = new Guid(providerId);
|
||||
Guid controlGuid = new(providerId);
|
||||
//
|
||||
// Create The ETW TraceProvider
|
||||
//
|
||||
|
@ -148,7 +148,7 @@ namespace System.Diagnostics.Eventing
|
|||
return;
|
||||
}
|
||||
|
||||
StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
|
||||
StringBuilder dataString = new(s_defaultPayloadSize);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ namespace System.Diagnostics.Eventing
|
|||
}
|
||||
|
||||
int index;
|
||||
StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
|
||||
StringBuilder dataString = new(s_defaultPayloadSize);
|
||||
|
||||
if ((data != null) && (data.Length > 0))
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ namespace System.Diagnostics.Eventing
|
|||
return;
|
||||
}
|
||||
|
||||
StringBuilder dataString = new StringBuilder(s_defaultPayloadSize);
|
||||
StringBuilder dataString = new(s_defaultPayloadSize);
|
||||
dataString.Append(message);
|
||||
|
||||
_provider.WriteMessageEvent(dataString.ToString(),
|
||||
|
@ -278,7 +278,7 @@ namespace System.Diagnostics.Eventing
|
|||
|
||||
public override void Fail(string message, string detailMessage)
|
||||
{
|
||||
StringBuilder failMessage = new StringBuilder(message);
|
||||
StringBuilder failMessage = new(message);
|
||||
if (detailMessage != null)
|
||||
{
|
||||
failMessage.Append(' ');
|
||||
|
|
|
@ -514,7 +514,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
{
|
||||
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();
|
||||
|
||||
|
@ -672,9 +672,9 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
[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)
|
||||
{
|
||||
|
@ -762,7 +762,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
[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);
|
||||
|
@ -791,7 +791,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
[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);
|
||||
|
@ -976,7 +976,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
if (!status)
|
||||
ThrowEventLogException(win32Error);
|
||||
|
||||
List<object> valuesList = new List<object>(propCount);
|
||||
List<object> valuesList = new(propCount);
|
||||
if (propCount > 0)
|
||||
{
|
||||
pointer = buffer;
|
||||
|
@ -1001,7 +1001,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
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();
|
||||
|
@ -1059,7 +1059,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
|
||||
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();
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
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();
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace System.Diagnostics.Eventing
|
|||
[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);
|
||||
|
|
Loading…
Reference in a new issue