You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't use System.Diagnostic.Tracing.EventSource based classes in .NET Core for Linux #27635
When I try to use EventSource execution fails with "Exception during construction of EventSource Microsoft-Diagnostics-DiagnosticSource: Unsupported type IEnumerable`1 in event source.".
It looks like IEnumerable parameters aren't supported in .NET Core for Linux.
Do you have a repro code for how you are using DiagnosticsSource?
What sort of 'fail' are you seeing exactly? Does the application crash with an unhandled exception? (And if so can you include the stack trace from the exception please) On Windows I can also get a sample app to throw an ArgumentException with that text, but the exception is handled and it doesn't cause the app to crash. If you are seeing different failure behavior I don't know if that is because you used DiagnosticsSource differently, or because Windows vs. Linux difference, or something else.
We definitely want to see the repro in more detail (you should be able to make a small one). Note that EventSource DOES support IEnumerable, but the argument type has to be serializable by EventSource (thus a primitive type, or string, or class that was declared with the EventDataAttribute.
What is the type that you are trying to pass? It is an IEnumerable of what?
I'm not sure if this issue is related to the OP or not, but here is a repro that throws a 1st chance exception and catches it. The issue in this case is that ManifestBuilder has no support for IEnumerable, regardless of what type it is instantiated over.
using System.Collections.Generic;
using System.Diagnostics.Tracing;
namespace Repro32822
{
class Program
{
static void Main(string[] args)
{
MyEventSource source = new MyEventSource();
EventListener l = new MyEventListener();
l.EnableEvents(source, EventLevel.Verbose, EventKeywords.All);
source.Event("hi", "there", new int[] { 1 });
}
}
public class MyEventListener : EventListener
{
}
public class MyEventSource : EventSource
{
public MyEventSource() { }
public void Event(string SourceName, string EventName, IEnumerable<int> Arguments)
{
WriteEvent(1, SourceName, EventName, Arguments);
}
}
}
The exception is:
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
Unsupported type IEnumerable`1 in event source.
At callstack:
System.Private.CoreLib.dll!System.Diagnostics.Tracing.ManifestBuilder.GetTypeNameHelper(System.Type type) Line 189 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.ManifestBuilder.AddEventParameter(System.Type type, string name) Line 5161 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.CreateManifestAndDescriptors(System.Type eventSourceType, string eventSourceDllName, System.Diagnostics.Tracing.EventSource source, System.Diagnostics.Tracing.EventManifestOptions flags) Line 3099 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.EnsureDescriptorsInitialized() Line 2612 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.DoCommand(System.Diagnostics.Tracing.EventCommandEventArgs commandArgs) Line 2398 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.SendCommand(System.Diagnostics.Tracing.EventListener listener, int perEventSourceSessionId, int etwSessionId, System.Diagnostics.Tracing.EventCommand command, bool enable, System.Diagnostics.Tracing.EventLevel level, System.Diagnostics.Tracing.EventKeywords matchAnyKeyword, System.Collections.Generic.IDictionary<string, string> commandArguments) Line 2358 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventListener.EnableEvents(System.Diagnostics.Tracing.EventSource eventSource, System.Diagnostics.Tracing.EventLevel level, System.Diagnostics.Tracing.EventKeywords matchAnyKeyword, System.Collections.Generic.IDictionary<string, string> arguments) Line 3887 C#
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventListener.EnableEvents(System.Diagnostics.Tracing.EventSource eventSource, System.Diagnostics.Tracing.EventLevel level, System.Diagnostics.Tracing.EventKeywords matchAnyKeyword) Line 3866 C#
Repro32822.dll!Repro32822.Program.Main(string[] args) Line 12 C#
@noahfalk you need to tweek your example slightly. By default (because of compat), The normal WriteEvent APIs assume you want to emit your events as Manifest-based events, and these do not support IEnumerable. However, if you change the constructor of MyEventSource to this
It tells EventSource that you want to use the self-describing format, which DOES support IEnumerable. Try that. (Note that DiagnosticEventSource does do this). I expect this to to work.
Note you can't pass an arbitrary IEnumerable to the EventSource, it has to be an IEnuemrable of a type that is Serializable (from EventSource's point of view). This means it is either a primitive type, a string (a few other things like Nullable, and DateTime), or a class that has been marked with the EventData attribute and has properties that are in turn serializable.
Note that my strong suspicion is that in the orginal bug report what was passed was an IEnumerable where the element type did not conform to these rules.
This case does not even have an IEnumerable. I would have expected it to work. @noahfalk can you take a look?
@goodvinj - if you can simplify the case even more (e.g remove whatever event does not cause the probem as well as the NonEvent method, and see if removing the [Event] attribute matters, that would be helpful. The smaller the repro the better.
@jorive is looking into some of these EventSource bugs, but just a heads up we've already got quite a few in the queue that have shown up recently so it may take a little while to get to this one.
@Anipik I have not started looking at this issue yet. Could you please provide me with a full repro and I'll start looking into it. On the other hand, what flavor of Linux are you using?
The original poster of this issue deleted their account and is now a "ghost", and no repro was provided in response to a request, so I'm going to close this issue. Thanks.
Activity
stephentoub commentedon Oct 15, 2018
cc: @brianrob, @vancem
karelz commentedon Oct 16, 2018
@noahfalk
noahfalk commentedon Oct 16, 2018
Adding @jorive
Do you have a repro code for how you are using DiagnosticsSource?
What sort of 'fail' are you seeing exactly? Does the application crash with an unhandled exception? (And if so can you include the stack trace from the exception please) On Windows I can also get a sample app to throw an ArgumentException with that text, but the exception is handled and it doesn't cause the app to crash. If you are seeing different failure behavior I don't know if that is because you used DiagnosticsSource differently, or because Windows vs. Linux difference, or something else.
vancem commentedon Oct 17, 2018
We definitely want to see the repro in more detail (you should be able to make a small one). Note that EventSource DOES support IEnumerable, but the argument type has to be serializable by EventSource (thus a primitive type, or string, or class that was declared with the EventDataAttribute.
What is the type that you are trying to pass? It is an IEnumerable of what?
noahfalk commentedon Oct 17, 2018
I'm not sure if this issue is related to the OP or not, but here is a repro that throws a 1st chance exception and catches it. The issue in this case is that ManifestBuilder has no support for IEnumerable, regardless of what type it is instantiated over.
The exception is:
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
Unsupported type IEnumerable`1 in event source.
At callstack:
vancem commentedon Oct 17, 2018
@noahfalk you need to tweek your example slightly. By default (because of compat), The normal WriteEvent APIs assume you want to emit your events as Manifest-based events, and these do not support IEnumerable. However, if you change the constructor of MyEventSource to this
It tells EventSource that you want to use the self-describing format, which DOES support IEnumerable. Try that. (Note that DiagnosticEventSource does do this). I expect this to to work.
Note you can't pass an arbitrary IEnumerable to the EventSource, it has to be an IEnuemrable of a type that is Serializable (from EventSource's point of view). This means it is either a primitive type, a string (a few other things like Nullable, and DateTime), or a class that has been marked with the EventData attribute and has properties that are in turn serializable.
Note that my strong suspicion is that in the orginal bug report what was passed was an IEnumerable where the element type did not conform to these rules.
vancem commentedon Oct 18, 2018
This case does not even have an IEnumerable. I would have expected it to work.
@noahfalk can you take a look?
@goodvinj - if you can simplify the case even more (e.g remove whatever event does not cause the probem as well as the NonEvent method, and see if removing the [Event] attribute matters, that would be helpful. The smaller the repro the better.
noahfalk commentedon Oct 18, 2018
@jorive is looking into some of these EventSource bugs, but just a heads up we've already got quite a few in the queue that have shown up recently so it may take a little while to get to this one.
Anipik commentedon Feb 22, 2019
@jorive any update on this issue ?
jorive commentedon Feb 22, 2019
@Anipik I have not started looking at this issue yet. Could you please provide me with a full repro and I'll start looking into it. On the other hand, what flavor of Linux are you using?
jorive commentedon Feb 27, 2019
@goodvinj Do you have a repro for this issue?
tommcdon commentedon Apr 17, 2019
load balance to @josalem
stephentoub commentedon May 7, 2020
The original poster of this issue deleted their account and is now a "ghost", and no repro was provided in response to a request, so I'm going to close this issue. Thanks.