Conversation
| // write out each enum value | ||
| FieldInfo[] staticFields = enumType.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static); | ||
|
|
||
| // Empty map entries cause Windows to reject the whole manifest. Avoid ths by only writting the |
| { | ||
| if (data is System.Enum) | ||
| { | ||
| Type underlyingType = Enum.GetUnderlyingType(data.GetType()); |
There was a problem hiding this comment.
The fix in this file was prompted by testing where if you have enums that are not based on int or long, then it will serialize it as a string, but the manifest says it decodes like an enum. This fix basically extends the types recognized to be all the integer types. the 64 bit types are handled specially and all others are cast to int (32 bit case).
|
|
||
| // write out each enum value | ||
| FieldInfo[] staticFields = enumType.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static); | ||
| bool anyValuesWritten = false; |
There was a problem hiding this comment.
This fix allows enums with unsigned underlying types. It also insures that if there are no enum values we add one because the windows ETW manifest parser requires it.
|
I have done some ad-hoc testing to confirm this works. |
| } | ||
| } | ||
|
|
||
| // the OS requrires that bitmaps and valuemaps have at least one value or it reject the whole manifest. |
| else if (underlyingType == typeof(long)) | ||
| data = (long)data; | ||
| else | ||
| data = (int)Convert.ToInt64(data); // This handles all int/uint or below (we treat them like 32 bit ints) |
There was a problem hiding this comment.
Do we need to modify DecodeObject as well to make sure that data types smaller than 4 bytes are properly handled?
We're getting the marshalling size of an enum underlying type - there are not that many of those. I chose not to treat `char` and `bool`, but we could (the only other remaining options). Calling into `Marshal.SizeOf` increases the risk that `EventSource` is going call itself recursively - see the comment at the beginning of the method. This was originally introduced in dotnet/coreclr#19205.
* Avoid Marshal.SizeOf in EventSource We're getting the marshalling size of an enum underlying type - there are not that many of those. I chose not to treat `char` and `bool`, but we could (the only other remaining options). Calling into `Marshal.SizeOf` increases the risk that `EventSource` is going call itself recursively - see the comment at the beginning of the method. This was originally introduced in dotnet/coreclr#19205. * Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs * Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs * Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Fix for https://github.com/dotnet/coreclr/issues/19204.
Need to do some targeted testing before checkin, but wanted to get it out there, so I don't forget it.
@brianrob