Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a44d2a1

Browse files
committed
Merge pull request dotnet/corert#3622 from dotnet/nmirror
Merge nmirror to master Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent b14c529 commit a44d2a1

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,32 +2197,26 @@ private void LogEventArgsMismatches(ParameterInfo[] infos, object[] args)
21972197
#endif //!ES_BUILD_PCL
21982198
}
21992199

2200-
private int GetParamLenghtIncludingByteArray(ParameterInfo[] parameters)
2200+
unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, int eventDataCount, EventSource.EventData* data)
22012201
{
2202-
int sum = 0;
2203-
foreach (ParameterInfo info in parameters)
2202+
// We represent a byte[] as a integer denoting the length and then a blob of bytes in the data pointer. This causes a spurious
2203+
// warning because eventDataCount is off by one for the byte[] case since a byte[] has 2 items associated it. So we want to check
2204+
// that the number of parameters is correct against the byte[] case, but also we the args array would be one too long if
2205+
// we just used the modifiedParamCount here -- so we need both.
2206+
int paramCount = GetParameterCount(m_eventData[eventId]);
2207+
int modifiedParamCount = 0;
2208+
for (int i = 0; i < paramCount; i++)
22042209
{
2205-
if (info.ParameterType == typeof(byte[]))
2210+
Type parameterType = GetDataType(m_eventData[eventId], i);
2211+
if (parameterType == typeof(byte[]))
22062212
{
2207-
sum += 2;
2213+
modifiedParamCount += 2;
22082214
}
22092215
else
22102216
{
2211-
sum++;
2217+
modifiedParamCount++;
22122218
}
22132219
}
2214-
2215-
return sum;
2216-
}
2217-
2218-
unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, int eventDataCount, EventSource.EventData* data)
2219-
{
2220-
// We represent a byte[] as a integer denoting the length and then a blob of bytes in the data pointer. This causes a spurious
2221-
// warning because eventDataCount is off by one for the byte[] case since a byte[] has 2 items associated it. So we want to check
2222-
// that the number of parameters is correct against the byte[] case, but also we the args array would be one too long if
2223-
// we just used the modifiedParamCount here -- so we need both.
2224-
int paramCount = m_eventData[eventId].Parameters.Length;
2225-
int modifiedParamCount = GetParamLenghtIncludingByteArray(m_eventData[eventId].Parameters);
22262220
if (eventDataCount != modifiedParamCount)
22272221
{
22282222
ReportOutOfBandMessage(Resources.GetResourceString("EventSource_EventParametersMismatch", eventId, eventDataCount, paramCount), true);

0 commit comments

Comments
 (0)