Skip to content

Commit e23bd31

Browse files
committed
Comment out EventSource calls for trimming compatibility
1 parent bf92f19 commit e23bd31

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Microsoft.Azure.Cosmos/src/DocumentClientEventSource.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ private unsafe void WriteEventCoreWithActivityId(Guid activityId, int eventId, i
4141
// must be explicitly be set before writing the event.
4242
CustomTypeExtensions.SetActivityId(ref activityId);
4343

44-
this.WriteEventCore(eventId, eventDataCount, dataDesc);
44+
// COMMENTED OUT FOR TRIMMED AZMCP: The following call to WriteEventCore is commented out to resolve
45+
// IL2026 trim analysis errors when building the trimmed version of azmcp. The error occurs because
46+
// EventSource.WriteEventCore has RequiresUnreferencedCodeAttribute which can break functionality
47+
// when trimming application code, as EventSource serializes the whole object graph and the trimmer
48+
// cannot safely handle this case. This is specific to the trimmed build - the AOT build doesn't
49+
// report this issue due to more aggressive optimizations that trim away unreachable code paths.
50+
// Since the preview trimmed version doesn't rely on EventSource telemetry, this is safe to disable.
51+
// this.WriteEventCore(eventId, eventDataCount, dataDesc);
4552
}
4653

4754
[Event(1,
@@ -266,7 +273,8 @@ private unsafe void Request(
266273
dataDesc[32].DataPointer = (IntPtr)(fixedXDate);
267274
dataDesc[32].Size = (xDate.Length + 1) * UnicodeEncodingCharSize;
268275

269-
this.WriteEventCoreWithActivityId(activityId, 1, eventDataCount, dataDesc);
276+
// COMMENTED OUT FOR TRIMMED AZMCP: See WriteEventCoreWithActivityId method for detailed explanation
277+
// this.WriteEventCoreWithActivityId(activityId, 1, eventDataCount, dataDesc);
270278
}
271279
}
272280

@@ -513,7 +521,8 @@ private unsafe void Response(Guid activityId,
513521
dataDesc[29].DataPointer = (IntPtr)(fixedVersion);
514522
dataDesc[29].Size = (version.Length + 1) * UnicodeEncodingCharSize;
515523

516-
this.WriteEventCoreWithActivityId(activityId, 2, eventDataCount, dataDesc);
524+
// COMMENTED OUT FOR TRIMMED AZMCP: See WriteEventCoreWithActivityId method for detailed explanation
525+
// this.WriteEventCoreWithActivityId(activityId, 2, eventDataCount, dataDesc);
517526
}
518527
}
519528

0 commit comments

Comments
 (0)