Skip to content

Commit

Permalink
Remove AnonymousType ILLinkTrim entry for EventSource
Browse files Browse the repository at this point in the history
Instead of using an anonymous type to do the logging, just pass the string directly.

Contributes to dotnet#35199
  • Loading branch information
eerhardt committed May 27, 2020
1 parent 6d25c29 commit d33af56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/coreclr/src/System.Private.CoreLib/ILLinkTrim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
<!-- Accessed via private reflection and by native code. -->
<type fullname="System.Diagnostics.Tracing.RuntimeEventSource" />
<type fullname="System.Diagnostics.Tracing.NativeRuntimeEventSource" />
<!-- Accessed via reflection in TraceLogging-style EventSource events. -->
<type fullname="*f__AnonymousType*" />
<type fullname="System.Diagnostics.Tracing.PropertyValue/ReferenceTypeHelper`1">
<!-- Instantiated via reflection -->
<method name=".ctor" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2178,9 +2178,8 @@ private unsafe void WriteEventString(string msgString)
Keywords = (EventKeywords)unchecked(keywords),
Level = level
};
var msg = new { message = msgString };
var tlet = new TraceLoggingEventTypes(EventName, EventTags.None, new Type[] { msg.GetType() });
WriteMultiMergeInner(EventName, ref opt, tlet, null, null, msg);
var tlet = new TraceLoggingEventTypes(EventName, EventTags.None, new Type[] { typeof(string) });
WriteMultiMergeInner(EventName, ref opt, tlet, null, null, msgString);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ public override void WriteMetadata(
string? name,
EventFieldFormat format)
{
collector.AddNullTerminatedString(name!, Statics.MakeDataType(TraceLoggingDataType.Utf16String, format));
// name can be null if the string was used as a top-level object in an event.
// In that case, use 'message' as the name of the field.
name ??= "message";

collector.AddNullTerminatedString(name, Statics.MakeDataType(TraceLoggingDataType.Utf16String, format));
}

public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value)
Expand Down

0 comments on commit d33af56

Please sign in to comment.