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

Commit f28cc64

Browse files
brianrobsafern
authored andcommitted
Port EventSource Nuget Package Changes (dotnet/coreclr#14669)
* Add missing resource strings. * Bring back code changes required to build the nuget package. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent f5cb4dd commit f28cc64

18 files changed

+195
-104
lines changed

src/Common/src/CoreLib/System/Diagnostics/Tracing/ActivityTracker.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
using System;
66
using System.Diagnostics;
77
using System.Threading;
8+
#if !ES_BUILD_AGAINST_DOTNET_V35
9+
using Contract = System.Diagnostics.Contracts.Contract;
10+
#else
11+
using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
12+
#endif
13+
814
#if ES_BUILD_STANDALONE
915
namespace Microsoft.Diagnostics.Tracing
1016
#else
@@ -37,6 +43,7 @@ namespace System.Diagnostics.Tracing
3743
/// </summary>
3844
internal class ActivityTracker
3945
{
46+
4047
/// <summary>
4148
/// Called on work item begins. The activity name = providerName + activityName without 'Start' suffix.
4249
/// It updates CurrentActivityId to track.

src/Common/src/CoreLib/System/Diagnostics/Tracing/EventDescriptor.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
using Environment = Microsoft.Diagnostics.Tracing.Internal.Environment;
1010
#endif
1111

12+
#if !ES_BUILD_AGAINST_DOTNET_V35
13+
using Contract = System.Diagnostics.Contracts.Contract;
14+
#else
15+
using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
16+
#endif
17+
1218
#if ES_BUILD_STANDALONE
1319
namespace Microsoft.Diagnostics.Tracing
1420
#else
@@ -83,12 +89,12 @@ long keywords
8389
{
8490
if (id < 0)
8591
{
86-
throw new ArgumentOutOfRangeException(nameof(id), Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
92+
throw new ArgumentOutOfRangeException(nameof(id), SR.ArgumentOutOfRange_NeedNonNegNum);
8793
}
8894

8995
if (id > ushort.MaxValue)
9096
{
91-
throw new ArgumentOutOfRangeException(nameof(id), Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
97+
throw new ArgumentOutOfRangeException(nameof(id), SR.Format(SR.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
9298
}
9399

94100
m_traceloggingId = 0;
@@ -101,12 +107,12 @@ long keywords
101107

102108
if (task < 0)
103109
{
104-
throw new ArgumentOutOfRangeException(nameof(task), Resources.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
110+
throw new ArgumentOutOfRangeException(nameof(task), SR.ArgumentOutOfRange_NeedNonNegNum);
105111
}
106112

107113
if (task > ushort.MaxValue)
108114
{
109-
throw new ArgumentOutOfRangeException(nameof(task), Resources.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
115+
throw new ArgumentOutOfRangeException(nameof(task), SR.Format(SR.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
110116
}
111117

112118
m_task = (ushort)task;

src/Common/src/CoreLib/System/Diagnostics/Tracing/EventProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
using System.Threading;
1515
using System;
1616

17+
#if !ES_BUILD_AGAINST_DOTNET_V35
18+
using Contract = System.Diagnostics.Contracts.Contract;
19+
#else
20+
using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
21+
#endif
22+
1723
#if ES_BUILD_AGAINST_DOTNET_V35
1824
using Microsoft.Internal; // for Tuple (can't define alias for open generic types so we "use" the whole namespace)
1925
#endif
@@ -628,6 +634,7 @@ public bool IsEnabled(byte level, long keywords)
628634
if ((level <= m_level) ||
629635
(m_level == 0))
630636
{
637+
631638
//
632639
// Check if Keyword is enabled
633640
//

src/Common/src/CoreLib/System/Diagnostics/Tracing/EventSource.cs

Lines changed: 86 additions & 70 deletions
Large diffs are not rendered by default.

src/Common/src/CoreLib/System/Diagnostics/Tracing/EventSourceException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Resources;
67
using System.Runtime.Serialization;
78

89
#if ES_BUILD_STANDALONE
@@ -27,7 +28,7 @@ public class EventSourceException : Exception
2728
/// Initializes a new instance of the EventSourceException class.
2829
/// </summary>
2930
public EventSourceException() :
30-
base(Resources.GetResourceString("EventSource_ListenerWriteFailure")) { }
31+
base(SR.EventSource_ListenerWriteFailure) { }
3132

3233
/// <summary>
3334
/// Initializes a new instance of the EventSourceException class with a specified error message.
@@ -48,6 +49,6 @@ protected EventSourceException(SerializationInfo info, StreamingContext context)
4849
#endif
4950

5051
internal EventSourceException(Exception innerException) :
51-
base(Resources.GetResourceString("EventSource_ListenerWriteFailure"), innerException) { }
52+
base(SR.EventSource_ListenerWriteFailure, innerException) { }
5253
}
5354
}

src/Common/src/CoreLib/System/Diagnostics/Tracing/IEventProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using Microsoft.Win32;
67

78
#if ES_BUILD_STANDALONE

src/Common/src/CoreLib/System/Diagnostics/Tracing/StubEnvironment.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,18 @@ public static int GetCurrentThreadId()
356356
}
357357
}
358358
#endif
359+
360+
#if ES_BUILD_STANDALONE
361+
namespace Microsoft.Win32
362+
{
363+
using System.Runtime.InteropServices;
364+
using System.Security;
365+
366+
[SuppressUnmanagedCodeSecurityAttribute()]
367+
internal static class Win32Native
368+
{
369+
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
370+
internal static extern uint GetCurrentProcessId();
371+
}
372+
}
373+
#endif

src/Common/src/CoreLib/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Resources;
67
using System.Runtime.InteropServices;
78
using System.Security;
89

@@ -85,7 +86,7 @@ internal void AddScalar(void* value, int size)
8586
var scratchNew = scratchOld + size;
8687
if (this.scratchEnd < scratchNew)
8788
{
88-
throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_AddScalarOutOfRange"));
89+
throw new IndexOutOfRangeException(SR.EventSource_AddScalarOutOfRange);
8990
}
9091

9192
this.ScalarsBegin();
@@ -272,13 +273,13 @@ private void PinArray(object value, int size)
272273
var pinsTemp = this.pins;
273274
if (this.pinsEnd <= pinsTemp)
274275
{
275-
throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_PinArrayOutOfRange"));
276+
throw new IndexOutOfRangeException(SR.EventSource_PinArrayOutOfRange);
276277
}
277278

278279
var datasTemp = this.datas;
279280
if (this.datasEnd <= datasTemp)
280281
{
281-
throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
282+
throw new IndexOutOfRangeException(SR.EventSource_DataDescriptorsOutOfRange);
282283
}
283284

284285
this.pins = pinsTemp + 1;
@@ -296,7 +297,7 @@ private void ScalarsBegin()
296297
var datasTemp = this.datas;
297298
if (this.datasEnd <= datasTemp)
298299
{
299-
throw new IndexOutOfRangeException(Resources.GetResourceString("EventSource_DataDescriptorsOutOfRange"));
300+
throw new IndexOutOfRangeException(SR.EventSource_DataDescriptorsOutOfRange);
300301
}
301302

302303
datasTemp->DataPointer = (IntPtr) this.scratch;

src/Common/src/CoreLib/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
using System.Collections;
77
using System.Diagnostics;
88

9+
#if !ES_BUILD_AGAINST_DOTNET_V35
10+
using Contract = System.Diagnostics.Contracts.Contract;
11+
#else
12+
using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
13+
#endif
14+
915
#if ES_BUILD_STANDALONE
1016
namespace Microsoft.Diagnostics.Tracing
1117
#else

src/Common/src/CoreLib/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
using System;
66

7+
#if !ES_BUILD_AGAINST_DOTNET_V35
8+
using Contract = System.Diagnostics.Contracts.Contract;
9+
#else
10+
using Contract = Microsoft.Diagnostics.Contracts.Internal.Contract;
11+
#endif
12+
713
#if ES_BUILD_STANDALONE
814
namespace Microsoft.Diagnostics.Tracing
915
#else

0 commit comments

Comments
 (0)