-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Remove the FullCLR-only symbol-info related code from EventManager.cs #6563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,6 @@ | |
| using System.Reflection.Emit; | ||
| using System.Threading; | ||
|
|
||
| #if !CORECLR | ||
| // StackFrame and SymbolStore related types are not available in CoreCLR. | ||
| using System.Diagnostics.SymbolStore; | ||
| using System.Diagnostics; | ||
| #endif | ||
|
|
||
| namespace System.Management.Automation | ||
| { | ||
| /// <summary> | ||
|
|
@@ -359,9 +353,6 @@ internal PSLocalEventManager(ExecutionContext context) | |
| private AssemblyBuilder _eventAssembly = null; | ||
| private ModuleBuilder _eventModule = null; | ||
| private int _typeId = 0; | ||
| #if !CORECLR | ||
| private bool debugMode = false; | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// Gets the list of event subscribers. | ||
|
|
@@ -673,22 +664,10 @@ private void ProcessNewSubscriber(PSEventSubscriber subscriber, Object source, s | |
|
|
||
| if (_eventAssembly == null) | ||
| { | ||
| #if !CORECLR | ||
| // Define the assembly that will hold our event handlers | ||
| StackFrame callStack = new StackFrame(0, true); | ||
| debugMode = (callStack.GetFileName() != null); | ||
| #endif | ||
| _eventAssembly = AssemblyBuilder.DefineDynamicAssembly( | ||
| new AssemblyName("PSEventHandler"), | ||
| AssemblyBuilderAccess.Run); | ||
| } | ||
| if (_eventModule == null) | ||
| { | ||
| #if CORECLR | ||
| _eventModule = _eventAssembly.DefineDynamicModule("PSGenericEventModule"); | ||
| #else | ||
| _eventModule = _eventAssembly.DefineDynamicModule("PSGenericEventModule", debugMode); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: |
||
| #endif | ||
| } | ||
|
|
||
| string engineEventSourceIdentifier = null; | ||
|
|
@@ -748,14 +727,7 @@ private void ProcessNewSubscriber(PSEventSubscriber subscriber, Object source, s | |
| } | ||
| } | ||
| } | ||
| #if !CORECLR | ||
| // If it is a ManagementEventWatcher, enable it | ||
| ManagementEventWatcher eventWatcher = source as ManagementEventWatcher; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: WMIv1 ( |
||
| if (eventWatcher != null) | ||
| { | ||
| eventWatcher.Start(); | ||
| } | ||
| #endif | ||
|
|
||
| // Get its invoke method, and register ourselves as a handler | ||
| MethodInfo invokeMethod = eventInfo.EventHandlerType.GetMethod("Invoke"); | ||
|
|
||
|
|
@@ -767,7 +739,6 @@ private void ProcessNewSubscriber(PSEventSubscriber subscriber, Object source, s | |
| if (invokeMethod.ReturnType != typeof(void)) | ||
| { | ||
| string errorMessage = EventingResources.NonVoidDelegateNotSupported; | ||
|
|
||
| throw new ArgumentException(errorMessage, "eventName"); | ||
| } | ||
|
|
||
|
|
@@ -1423,16 +1394,7 @@ private IEnumerable<PSEventSubscriber> GetEventSubscribers(string sourceIdentifi | |
| private Type GenerateEventHandler(MethodInfo invokeSignature) | ||
| { | ||
| int parameterCount = invokeSignature.GetParameters().Length; | ||
| #if !CORECLR | ||
| StackFrame callStack = new StackFrame(0, true); | ||
|
|
||
| // Get the filename to associate with the debug symbols | ||
| ISymbolDocumentWriter doc = null; | ||
| if (debugMode) | ||
| { | ||
| doc = _eventModule.DefineDocument(callStack.GetFileName(), Guid.Empty, Guid.Empty, Guid.Empty); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: API does not exist in .NET Core. |
||
| } | ||
| #endif | ||
| // Define the type that will respond to the event. It | ||
| // derives from PSEventHandler so that complex | ||
| // functionality can go into its base class. | ||
|
|
@@ -1445,21 +1407,6 @@ private Type GenerateEventHandler(MethodInfo invokeSignature) | |
| typeof(PSEventHandler).GetConstructor( | ||
| new Type[] { typeof(PSEventManager), typeof(Object), typeof(string), typeof(PSObject) }); | ||
|
|
||
| #if !CORECLR | ||
| if (debugMode) | ||
| { | ||
| // Mark as debuggable | ||
| Type debugAttributeType = typeof(DebuggableAttribute); | ||
| ConstructorInfo debugAttributeCtor = debugAttributeType.GetConstructor(new Type[] { typeof(DebuggableAttribute.DebuggingModes) }); | ||
|
|
||
| CustomAttributeBuilder debugAttributeBuilder = new CustomAttributeBuilder(debugAttributeCtor, | ||
| new object[] { | ||
| DebuggableAttribute.DebuggingModes.DisableOptimizations | | ||
| DebuggableAttribute.DebuggingModes.Default | ||
| }); | ||
| _eventAssembly.SetCustomAttribute(debugAttributeBuilder); | ||
| } | ||
| #endif | ||
| // Define the new constructor | ||
| // public TestEventHandler(PSEventManager eventManager, Object sender, string sourceIdentifier, PSObject extraData) | ||
| // : base(eventManager, sender, sourceIdentifier, extraData) | ||
|
|
@@ -1499,35 +1446,19 @@ private Type GenerateEventHandler(MethodInfo invokeSignature) | |
|
|
||
| ILGenerator methodContents = eventMethod.GetILGenerator(); | ||
|
|
||
| // Object[] args = | ||
| LocalBuilder argsBuilder = methodContents.DeclareLocal(typeof(object[])); | ||
|
|
||
| #if !CORECLR | ||
| if (debugMode) | ||
| { | ||
| argsBuilder.SetLocalSymInfo("args"); | ||
| // Declare a local variable of the type 'object[]' at index 0, say 'object[] args' | ||
| methodContents.DeclareLocal(typeof(object[])); | ||
|
|
||
| // new Object[ invokeSignature.GetParameters().Length ] | ||
| methodContents.MarkSequencePoint(doc, callStack.GetFileLineNumber() - 1, 1, callStack.GetFileLineNumber(), 100); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: API doesn't exist in .NET Core. |
||
| } | ||
| #endif | ||
| methodContents.Emit(OpCodes.Ldc_I4, parameterCount); | ||
| methodContents.Emit(OpCodes.Newarr, typeof(Object)); | ||
|
|
||
| // Retrieve the args variable from local variable index 0 | ||
| // Store the new array to the local variable 'args' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this an error in the previous comment?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see -- never mind |
||
| methodContents.Emit(OpCodes.Stloc_0); | ||
|
|
||
| // Inline, this converts into a series of setting args[n] to | ||
| // the argument at the same parameter index | ||
| for (int counter = 1; counter <= parameterCount; counter++) | ||
| { | ||
| #if !CORECLR | ||
| if (debugMode) | ||
| { | ||
| // args[n] = argument[n] | ||
| methodContents.MarkSequencePoint(doc, callStack.GetFileLineNumber() - 1, 1, callStack.GetFileLineNumber(), 100); | ||
| } | ||
| #endif | ||
| methodContents.Emit(OpCodes.Ldloc_0); | ||
| methodContents.Emit(OpCodes.Ldc_I4, counter - 1); | ||
| methodContents.Emit(OpCodes.Ldarg, counter); | ||
|
|
@@ -1572,16 +1503,9 @@ private Type GenerateEventHandler(MethodInfo invokeSignature) | |
|
|
||
| // Finally, invoke the method | ||
| MethodInfo generateEventMethod = typeof(PSEventManager).GetMethod( | ||
| "GenerateEvent", | ||
| new Type[] { typeof(string), typeof(object), typeof(object[]), typeof(PSObject) } | ||
| ); | ||
| #if !CORECLR | ||
| if (debugMode) | ||
| { | ||
| // GenerateEvent(sourceIdentifier, args, extraData); | ||
| methodContents.MarkSequencePoint(doc, callStack.GetFileLineNumber() - 1, 1, callStack.GetFileLineNumber(), 100); | ||
| } | ||
| #endif | ||
| nameof(PSEventManager.GenerateEvent), | ||
| new Type[] { typeof(string), typeof(object), typeof(object[]), typeof(PSObject) }); | ||
|
|
||
| methodContents.Emit(OpCodes.Callvirt, generateEventMethod); | ||
|
|
||
| // Discard the return value, and return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:
callstack.GetFileName()return null if the corresponding.pdbfile is not put beside the.dllfile. So this is actually to see if we are currently debugging the.dll.