@@ -649,15 +649,9 @@ protected EventSource(EventSourceSettings settings, params string[]? traits)
649
649
{
650
650
m_config = ValidateSettings ( settings ) ;
651
651
652
-
653
- GetMetadata ( out Guid eventSourceGuid , out string ? eventSourceName , out _ , out _ ) ;
654
-
655
- if ( eventSourceGuid . Equals ( Guid . Empty ) || eventSourceName == null )
656
- {
657
- Type myType = this . GetType ( ) ;
658
- eventSourceGuid = GetGuid ( myType ) ;
659
- eventSourceName = GetName ( myType ) ;
660
- }
652
+ Type myType = this . GetType ( ) ;
653
+ Guid eventSourceGuid = GetGuid ( myType ) ;
654
+ string eventSourceName = GetName ( myType ) ;
661
655
662
656
Initialize ( eventSourceGuid , eventSourceName , traits ) ;
663
657
}
@@ -709,25 +703,6 @@ private unsafe void DefineEventPipeEvents()
709
703
}
710
704
#endif
711
705
712
- internal virtual void GetMetadata ( out Guid eventSourceGuid , out string ? eventSourceName , out EventMetadata [ ] ? eventData , out byte [ ] ? manifestBytes )
713
- {
714
- //
715
- // In ProjectN subclasses need to override this method, and return the data from their EventSourceAttribute and EventAttribute annotations.
716
- // On other architectures it is a no-op.
717
- //
718
- // eventDescriptors needs to contain one EventDescriptor for each event; the event's ID should be the same as its index in this array.
719
- // manifestBytes is a UTF-8 encoding of the ETW manifest for the type.
720
- //
721
- // This will be implemented by an IL rewriter, so we can't make this method abstract or the initial build of the subclass would fail.
722
- //
723
- eventSourceGuid = Guid . Empty ;
724
- eventSourceName = null ;
725
- eventData = null ;
726
- manifestBytes = null ;
727
-
728
- return ;
729
- }
730
-
731
706
/// <summary>
732
707
/// This method is called when the eventSource is updated by the controller.
733
708
/// </summary>
@@ -1469,7 +1444,7 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str
1469
1444
m_etwProvider = etwProvider ;
1470
1445
1471
1446
#if TARGET_WINDOWS
1472
- #if ( ! ES_BUILD_STANDALONE && ! ES_BUILD_PN )
1447
+ #if ( ! ES_BUILD_STANDALONE )
1473
1448
// API available on OS >= Win 8 and patched Win 7.
1474
1449
// Disable only for FrameworkEventSource to avoid recursion inside exception handling.
1475
1450
if ( this . Name != "System.Diagnostics.Eventing.FrameworkEventSource" || Environment . IsWindows8OrAbove )
@@ -1831,11 +1806,8 @@ private static Guid GenerateGuidFromName(string name)
1831
1806
if ( dataType . IsEnum ( ) )
1832
1807
{
1833
1808
dataType = Enum . GetUnderlyingType ( dataType ) ;
1834
- #if ES_BUILD_PN
1835
- int dataTypeSize = ( int ) dataType . TypeHandle . ToEETypePtr ( ) . ValueTypeSize ;
1836
- #else
1809
+
1837
1810
int dataTypeSize = System . Runtime . InteropServices . Marshal . SizeOf ( dataType ) ;
1838
- #endif
1839
1811
if ( dataTypeSize < sizeof ( int ) )
1840
1812
dataType = typeof ( int ) ;
1841
1813
goto Again ;
@@ -2452,49 +2424,8 @@ protected override void OnControllerCommand(ControllerCommand command, IDictiona
2452
2424
/// code:m_eventData for where we use this.
2453
2425
/// </summary>
2454
2426
2455
- /*
2456
- EventMetadata was public in the separate System.Diagnostics.Tracing assembly(pre NS2.0),
2457
- now the move to CoreLib marked them as private.
2458
- While they are technically private (it's a contract used between the library and the ILC toolchain),
2459
- we need them to be rooted and exported from shared library for the system to work.
2460
- For now I'm simply marking them as public again.A cleaner solution might be to use.rd.xml to
2461
- root them and modify shared library definition to force export them.
2462
- */
2463
- #if ES_BUILD_PN
2464
- public
2465
- #else
2466
- internal
2467
- #endif
2468
- partial struct EventMetadata
2469
- {
2470
- #if ES_BUILD_PN
2471
- public EventMetadata ( EventDescriptor descriptor ,
2472
- EventTags tags ,
2473
- bool enabledForAnyListener ,
2474
- bool enabledForETW ,
2475
- string name ,
2476
- string message ,
2477
- EventParameterType [ ] parameterTypes )
2478
- {
2479
- this . Descriptor = descriptor ;
2480
- this . Tags = tags ;
2481
- this . EnabledForAnyListener = enabledForAnyListener ;
2482
- this . EnabledForETW = enabledForETW ;
2483
- #if FEATURE_PERFTRACING
2484
- this . EnabledForEventPipe = false ;
2485
- #endif
2486
- this . TriggersActivityTracking = 0 ;
2487
- this . Name = name ;
2488
- this . Message = message ;
2489
- this . Parameters = null ! ;
2490
- this . TraceLoggingEventTypes = null ;
2491
- this . ActivityOptions = EventActivityOptions . None ;
2492
- this . ParameterTypes = parameterTypes ;
2493
- this . HasRelatedActivityID = false ;
2494
- this . EventHandle = IntPtr . Zero ;
2495
- }
2496
- #endif
2497
-
2427
+ internal partial struct EventMetadata
2428
+ {
2498
2429
public EventDescriptor Descriptor ;
2499
2430
public IntPtr EventHandle ; // EventPipeEvent handle.
2500
2431
public EventTags Tags ;
@@ -2514,13 +2445,8 @@ public EventMetadata(EventDescriptor descriptor,
2514
2445
2515
2446
public TraceLoggingEventTypes ? TraceLoggingEventTypes ;
2516
2447
public EventActivityOptions ActivityOptions ;
2517
-
2518
- #if ES_BUILD_PN
2519
- public EventParameterType [ ] ParameterTypes ;
2520
- #endif
2521
2448
}
2522
2449
2523
- #if ! ES_BUILD_PN
2524
2450
private static int GetParameterCount ( EventMetadata eventData )
2525
2451
{
2526
2452
return eventData . Parameters . Length ;
@@ -2532,101 +2458,6 @@ private static Type GetDataType(EventMetadata eventData, int parameterId)
2532
2458
}
2533
2459
2534
2460
private const bool m_EventSourcePreventRecursion = false ;
2535
- #else
2536
- private static int GetParameterCount ( EventMetadata eventData )
2537
- {
2538
- int paramCount ;
2539
- if ( eventData . Parameters == null )
2540
- {
2541
- paramCount = eventData . ParameterTypes . Length ;
2542
- }
2543
- else
2544
- {
2545
- paramCount = eventData . Parameters . Length ;
2546
- }
2547
-
2548
- return paramCount ;
2549
- }
2550
-
2551
- private static Type GetDataType ( EventMetadata eventData , int parameterId )
2552
- {
2553
- Type dataType ;
2554
- if ( eventData . Parameters == null )
2555
- {
2556
- dataType = EventTypeToType ( eventData . ParameterTypes [ parameterId ] ) ;
2557
- }
2558
- else
2559
- {
2560
- dataType = eventData . Parameters [ parameterId ] . ParameterType ;
2561
- }
2562
-
2563
- return dataType ;
2564
- }
2565
-
2566
- private static readonly bool m_EventSourcePreventRecursion = true ;
2567
-
2568
- public enum EventParameterType
2569
- {
2570
- Boolean ,
2571
- Byte ,
2572
- SByte ,
2573
- Char ,
2574
- Int16 ,
2575
- UInt16 ,
2576
- Int32 ,
2577
- UInt32 ,
2578
- Int64 ,
2579
- UInt64 ,
2580
- IntPtr ,
2581
- Single ,
2582
- Double ,
2583
- Decimal ,
2584
- Guid ,
2585
- String
2586
- }
2587
-
2588
- private static Type EventTypeToType ( EventParameterType type )
2589
- {
2590
- switch ( type )
2591
- {
2592
- case EventParameterType . Boolean :
2593
- return typeof ( bool ) ;
2594
- case EventParameterType . Byte :
2595
- return typeof ( byte ) ;
2596
- case EventParameterType . SByte :
2597
- return typeof ( sbyte ) ;
2598
- case EventParameterType . Char :
2599
- return typeof ( char ) ;
2600
- case EventParameterType . Int16 :
2601
- return typeof ( short ) ;
2602
- case EventParameterType . UInt16 :
2603
- return typeof ( ushort ) ;
2604
- case EventParameterType . Int32 :
2605
- return typeof ( int ) ;
2606
- case EventParameterType . UInt32 :
2607
- return typeof ( uint ) ;
2608
- case EventParameterType . Int64 :
2609
- return typeof ( long ) ;
2610
- case EventParameterType . UInt64 :
2611
- return typeof ( ulong ) ;
2612
- case EventParameterType . IntPtr :
2613
- return typeof ( IntPtr ) ;
2614
- case EventParameterType . Single :
2615
- return typeof ( float ) ;
2616
- case EventParameterType . Double :
2617
- return typeof ( double ) ;
2618
- case EventParameterType . Decimal :
2619
- return typeof ( decimal ) ;
2620
- case EventParameterType . Guid :
2621
- return typeof ( Guid ) ;
2622
- case EventParameterType . String :
2623
- return typeof ( string ) ;
2624
- default :
2625
- // TODO: should I throw an exception here?
2626
- return null ! ;
2627
- }
2628
- }
2629
- #endif
2630
2461
2631
2462
// This is the internal entry point that code:EventListeners call when wanting to send a command to a
2632
2463
// eventSource. The logic is as follows
@@ -2915,28 +2746,11 @@ private void EnsureDescriptorsInitialized()
2915
2746
#endif
2916
2747
if ( m_eventData == null )
2917
2748
{
2918
- Guid eventSourceGuid = Guid . Empty ;
2919
-
2920
- // Try the GetMetadata provided by the ILTransform in ProjectN. The default sets all to null, and in that case we fall back
2921
- // to the reflection approach.
2922
- GetMetadata ( out eventSourceGuid , out string ? eventSourceName , out EventMetadata [ ] ? eventData , out byte [ ] ? manifest ) ;
2923
-
2924
- if ( eventSourceGuid . Equals ( Guid . Empty ) || eventSourceName == null || eventData == null || manifest == null )
2925
- {
2926
- // GetMetadata failed, so we have to set it via reflection.
2927
- Debug . Assert ( m_rawManifest == null ) ;
2749
+ // get the metadata via reflection.
2750
+ Debug . Assert ( m_rawManifest == null ) ;
2751
+ m_rawManifest = CreateManifestAndDescriptors ( this . GetType ( ) , Name , this ) ;
2752
+ Debug . Assert ( m_eventData != null ) ;
2928
2753
2929
- m_rawManifest = CreateManifestAndDescriptors ( this . GetType ( ) , Name , this ) ;
2930
- Debug . Assert ( m_eventData != null ) ;
2931
- }
2932
- else
2933
- {
2934
- // GetMetadata worked, so set the fields as appropriate.
2935
- m_name = eventSourceName ;
2936
- m_guid = eventSourceGuid ;
2937
- m_eventData = eventData ;
2938
- m_rawManifest = manifest ;
2939
- }
2940
2754
// TODO Enforce singleton pattern
2941
2755
Debug . Assert ( EventListener . s_EventSources != null , "should be called within lock on EventListener.EventListenersLock which ensures s_EventSources to be initialized" ) ;
2942
2756
foreach ( WeakReference < EventSource > eventSourceRef in EventListener . s_EventSources )
@@ -3058,11 +2872,9 @@ internal static Attribute GetCustomAttributeHelper(Type type, Type attributeType
3058
2872
// When that is the case, we have the build the custom assemblies on a member by hand.
3059
2873
internal static Attribute ? GetCustomAttributeHelper ( MemberInfo member , Type attributeType , EventManifestOptions flags = EventManifestOptions . None )
3060
2874
{
3061
- #if ! ES_BUILD_PN
3062
- // On ProjectN, ReflectionOnly() always equals false. AllowEventSourceOverride is an option that allows either Microsoft.Diagnostics.Tracing or
2875
+ // AllowEventSourceOverride is an option that allows either Microsoft.Diagnostics.Tracing or
3063
2876
// System.Diagnostics.Tracing EventSource to be considered valid. This should not mattter anywhere but in Microsoft.Diagnostics.Tracing (nuget package).
3064
2877
if ( ! member . Module . Assembly . ReflectionOnly ( ) && ( flags & EventManifestOptions . AllowEventSourceOverride ) == 0 )
3065
- #endif // !ES_BUILD_PN
3066
2878
{
3067
2879
// Let the runtime to the work for us, since we can execute code in this context.
3068
2880
Attribute ? firstAttribute = null ;
@@ -3074,7 +2886,7 @@ internal static Attribute GetCustomAttributeHelper(Type type, Type attributeType
3074
2886
return firstAttribute ;
3075
2887
}
3076
2888
3077
- #if ( ! ES_BUILD_PCL && ! ES_BUILD_PN )
2889
+ #if ( ! ES_BUILD_PCL )
3078
2890
foreach ( CustomAttributeData data in CustomAttributeData . GetCustomAttributes ( member ) )
3079
2891
{
3080
2892
if ( AttributeTypeNamesMatch ( attributeType , data . Constructor . ReflectedType ! ) )
@@ -3116,7 +2928,7 @@ internal static Attribute GetCustomAttributeHelper(Type type, Type attributeType
3116
2928
}
3117
2929
3118
2930
return null ;
3119
- #else // ES_BUILD_PCL && ES_BUILD_PN
2931
+ #else // ES_BUILD_PCL
3120
2932
// Don't use nameof here because the resource doesn't exist on some platforms, which results in a compilation error.
3121
2933
throw new ArgumentException ( "EventSource_PCLPlatformNotSupportedReflection" , "EventSource" ) ;
3122
2934
#endif
@@ -3705,7 +3517,7 @@ private static void DebugCheckEvent(ref Dictionary<string, string>? eventsByName
3705
3517
/// <returns>The literal value or -1 if the value could not be determined. </returns>
3706
3518
private static int GetHelperCallFirstArg ( MethodInfo method )
3707
3519
{
3708
- #if ( ! ES_BUILD_PCL && ! ES_BUILD_PN )
3520
+ #if ( ! ES_BUILD_PCL )
3709
3521
// Currently searches for the following pattern
3710
3522
//
3711
3523
// ... // CAN ONLY BE THE INSTRUCTIONS BELOW
@@ -3834,7 +3646,7 @@ internal void ReportOutOfBandMessage(string msg)
3834
3646
{
3835
3647
try
3836
3648
{
3837
- #if ( ! ES_BUILD_PCL && ! ES_BUILD_PN )
3649
+ #if ( ! ES_BUILD_PCL )
3838
3650
// send message to debugger without delay
3839
3651
System . Diagnostics . Debugger . Log ( 0 , null , string . Format ( "EventSource Error: {0}{1}" , msg , Environment . NewLine ) ) ;
3840
3652
#endif
0 commit comments