Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 856ae89

Browse files
committed
porting changes from .net native to CoreCLR
1 parent 9d7584d commit 856ae89

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

src/mscorlib/src/System/Diagnostics/Eventing/EventCounter.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using System;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
26
using System.Collections;
37
using System.Collections.Generic;
48
using System.Threading;
@@ -26,12 +30,12 @@ public EventCounter(string name, EventSource eventSource)
2630
{
2731
if (name == null)
2832
{
29-
throw new ArgumentNullException("name");
33+
throw new ArgumentNullException(nameof(name));
3034
}
3135

3236
if (eventSource == null)
3337
{
34-
throw new ArgumentNullException("eventSource");
38+
throw new ArgumentNullException(nameof(eventSource));
3539
}
3640

3741
InitializeBuffer();
@@ -281,7 +285,7 @@ private static void EnsureEventSourceIndexAvailable(int eventSourceIndex)
281285
else if (eventSourceIndex >= EventCounterGroup.s_eventCounterGroups.Length)
282286
{
283287
EventCounterGroup[] newEventCounterGroups = new EventCounterGroup[eventSourceIndex + 1];
284-
Array.Copy(EventCounterGroup.s_eventCounterGroups, newEventCounterGroups, EventCounterGroup.s_eventCounterGroups.Length);
288+
Array.Copy(EventCounterGroup.s_eventCounterGroups, 0, newEventCounterGroups, 0, EventCounterGroup.s_eventCounterGroups.Length);
285289
EventCounterGroup.s_eventCounterGroups = newEventCounterGroups;
286290
}
287291
}

src/mscorlib/src/System/Diagnostics/Eventing/EventDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ long keywords
7373
{
7474
if (id < 0)
7575
{
76-
throw new ArgumentOutOfRangeException("id", Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
76+
throw new ArgumentOutOfRangeException(nameof(id), Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
7777
}
7878

7979
if (id > ushort.MaxValue)
8080
{
81-
throw new ArgumentOutOfRangeException("id", Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
81+
throw new ArgumentOutOfRangeException(nameof(id), Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
8282
}
8383

8484
m_traceloggingId = 0;
@@ -91,12 +91,12 @@ long keywords
9191

9292
if (task < 0)
9393
{
94-
throw new ArgumentOutOfRangeException("task", Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
94+
throw new ArgumentOutOfRangeException(nameof(task), Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
9595
}
9696

9797
if (task > ushort.MaxValue)
9898
{
99-
throw new ArgumentOutOfRangeException("task", Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
99+
throw new ArgumentOutOfRangeException(nameof(task), Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
100100
}
101101

102102
m_task = (ushort)task;

src/mscorlib/src/System/Diagnostics/Eventing/EventProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal SessionInfo(int sessionIdBit_, int etwSessionId_)
8989
private static WriteEventErrorCode s_returnCode; // The last return code
9090

9191
private const int s_basicTypeAllocationBufferSize = 16;
92-
private const int s_etwMaxNumberArguments = 64;
92+
private const int s_etwMaxNumberArguments = 128;
9393
private const int s_etwAPIMaxRefObjCount = 8;
9494
private const int s_maxEventDataDescriptors = 128;
9595
private const int s_traceEventMaximumSize = 65482;
@@ -560,7 +560,7 @@ private unsafe bool GetDataFromController(int etwSessionId,
560560
dataStart = 0;
561561
if (filterData == null)
562562
{
563-
#if !ES_BUILD_PCL && !FEATURE_PAL
563+
#if (!ES_BUILD_PCL && !PROJECTN && !FEATURE_PAL)
564564
string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}";
565565
if (System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8)
566566
regKey = @"HKEY_LOCAL_MACHINE\Software" + @"\Wow6432Node" + regKey;

src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public EventSourceSettings Settings
404404
public static Guid GetGuid(Type eventSourceType)
405405
{
406406
if (eventSourceType == null)
407-
throw new ArgumentNullException("eventSourceType");
407+
throw new ArgumentNullException(nameof(eventSourceType));
408408
Contract.EndContractBlock();
409409

410410
EventSourceAttribute attrib = (EventSourceAttribute)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute));
@@ -429,7 +429,7 @@ public static Guid GetGuid(Type eventSourceType)
429429

430430
if (name == null)
431431
{
432-
throw new ArgumentException(Resources.GetResourceString("Argument_InvalidTypeName"), "eventSourceType");
432+
throw new ArgumentException(Resources.GetResourceString("Argument_InvalidTypeName"), nameof(eventSourceType));
433433
}
434434
return GenerateGuidFromName(name.ToUpperInvariant()); // Make it case insensitive.
435435
}
@@ -472,7 +472,7 @@ public static string GenerateManifest(Type eventSourceType, string assemblyPathT
472472
public static string GenerateManifest(Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
473473
{
474474
if (eventSourceType == null)
475-
throw new ArgumentNullException("eventSourceType");
475+
throw new ArgumentNullException(nameof(eventSourceType));
476476
Contract.EndContractBlock();
477477

478478
byte[] manifestBytes = EventSource.CreateManifestAndDescriptors(eventSourceType, assemblyPathToIncludeInManifest, null, flags);
@@ -511,12 +511,12 @@ public static IEnumerable<EventSource> GetSources()
511511
public static void SendCommand(EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
512512
{
513513
if (eventSource == null)
514-
throw new ArgumentNullException("eventSource");
514+
throw new ArgumentNullException(nameof(eventSource));
515515

516516
// User-defined EventCommands should not conflict with the reserved commands.
517517
if ((int)command <= (int)EventCommand.Update && (int)command != (int)EventCommand.SendManifest)
518518
{
519-
throw new ArgumentException(Resources.GetResourceString("EventSource_InvalidCommand"), "command");
519+
throw new ArgumentException(Resources.GetResourceString("EventSource_InvalidCommand"), nameof(command));
520520
}
521521

522522
eventSource.SendCommand(null, 0, 0, command, true, EventLevel.LogAlways, EventKeywords.None, commandArguments);
@@ -1451,7 +1451,7 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str
14511451
m_traits = traits;
14521452
if (m_traits != null && m_traits.Length % 2 != 0)
14531453
{
1454-
throw new ArgumentException(Resources.GetResourceString("TraitEven"), "traits");
1454+
throw new ArgumentException(Resources.GetResourceString("TraitEven"), nameof(traits));
14551455
}
14561456

14571457
if (eventSourceGuid == Guid.Empty)
@@ -1543,7 +1543,7 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str
15431543
private static string GetName(Type eventSourceType, EventManifestOptions flags)
15441544
{
15451545
if (eventSourceType == null)
1546-
throw new ArgumentNullException("eventSourceType");
1546+
throw new ArgumentNullException(nameof(eventSourceType));
15471547
Contract.EndContractBlock();
15481548

15491549
EventSourceAttribute attrib = (EventSourceAttribute)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute), flags);
@@ -3672,7 +3672,7 @@ private static void AddEventDescriptor(ref EventMetadata[] eventData, string eve
36723672
if (eventData == null || eventData.Length <= eventAttribute.EventId)
36733673
{
36743674
EventMetadata[] newValues = new EventMetadata[Math.Max(eventData.Length + 16, eventAttribute.EventId + 1)];
3675-
Array.Copy(eventData, newValues, eventData.Length);
3675+
Array.Copy(eventData, 0, newValues, 0, eventData.Length);
36763676
eventData = newValues;
36773677
}
36783678

@@ -3711,7 +3711,7 @@ private static void TrimEventDescriptors(ref EventMetadata[] eventData)
37113711
if (eventData.Length - idx > 2) // allow one wasted slot.
37123712
{
37133713
EventMetadata[] newValues = new EventMetadata[idx + 1];
3714-
Array.Copy(eventData, newValues, newValues.Length);
3714+
Array.Copy(eventData, 0, newValues, 0, newValues.Length);
37153715
eventData = newValues;
37163716
}
37173717
}
@@ -3994,7 +3994,7 @@ private EventSourceSettings ValidateSettings(EventSourceSettings settings)
39943994
EventSourceSettings.EtwSelfDescribingEventFormat;
39953995
if ((settings & evtFormatMask) == evtFormatMask)
39963996
{
3997-
throw new ArgumentException(Resources.GetResourceString("EventSource_InvalidEventFormat"), "settings");
3997+
throw new ArgumentException(Resources.GetResourceString("EventSource_InvalidEventFormat"), nameof(settings));
39983998
}
39993999

40004000
// If you did not explicitly ask for manifest, you get self-describing.
@@ -4351,7 +4351,7 @@ public void EnableEvents(EventSource eventSource, EventLevel level, EventKeyword
43514351
{
43524352
if (eventSource == null)
43534353
{
4354-
throw new ArgumentNullException("eventSource");
4354+
throw new ArgumentNullException(nameof(eventSource));
43554355
}
43564356
Contract.EndContractBlock();
43574357

@@ -4366,7 +4366,7 @@ public void DisableEvents(EventSource eventSource)
43664366
{
43674367
if (eventSource == null)
43684368
{
4369-
throw new ArgumentNullException("eventSource");
4369+
throw new ArgumentNullException(nameof(eventSource));
43704370
}
43714371
Contract.EndContractBlock();
43724372

@@ -6000,7 +6000,7 @@ internal EventDispatcher(EventDispatcher next, bool[] eventEnabled, EventListene
60006000
internal bool m_activityFilteringEnabled; // does THIS EventSource have activity filtering turned on for this listener?
60016001
#endif // FEATURE_ACTIVITYSAMPLING
60026002

6003-
// Only guarenteed to exist after a InsureInit()
6003+
// Only guaranteed to exist after a InsureInit()
60046004
internal EventDispatcher m_Next; // These form a linked list in code:EventSource.m_Dispatchers
60056005
// Of all listeners for that eventSource.
60066006
}

src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ private string GetTypeNameHelper(Type type)
178178
else if ((type.IsArray || type.IsPointer) && type.GetElementType() == typeof(byte))
179179
return "win:Binary";
180180

181-
ManifestError(Environment.GetResourceString("EventSource_UnsupportedEventTypeInManifest", type.Name), true);
181+
ManifestError(Resources.GetResourceString("EventSource_UnsupportedEventTypeInManifest", type.Name), true);
182182
return string.Empty;
183183
}
184184
}
185185
}
186-
186+
187187
internal partial class EventProvider
188188
{
189189
[System.Security.SecurityCritical]

0 commit comments

Comments
 (0)