From a44d2a19dfcef497333487a531ba5b43b3006e81 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 15 May 2017 16:40:31 -0700 Subject: [PATCH] Merge pull request dotnet/corert#3622 from dotnet/nmirror Merge nmirror to master Signed-off-by: dotnet-bot --- .../System/Diagnostics/Tracing/EventSource.cs | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs index a0f0e1e06d..df3ea163ce 100644 --- a/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/mscorlib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -2197,32 +2197,26 @@ namespace System.Diagnostics.Tracing #endif //!ES_BUILD_PCL } - private int GetParamLenghtIncludingByteArray(ParameterInfo[] parameters) + unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, int eventDataCount, EventSource.EventData* data) { - int sum = 0; - foreach (ParameterInfo info in parameters) + // We represent a byte[] as a integer denoting the length and then a blob of bytes in the data pointer. This causes a spurious + // warning because eventDataCount is off by one for the byte[] case since a byte[] has 2 items associated it. So we want to check + // that the number of parameters is correct against the byte[] case, but also we the args array would be one too long if + // we just used the modifiedParamCount here -- so we need both. + int paramCount = GetParameterCount(m_eventData[eventId]); + int modifiedParamCount = 0; + for (int i = 0; i < paramCount; i++) { - if (info.ParameterType == typeof(byte[])) + Type parameterType = GetDataType(m_eventData[eventId], i); + if (parameterType == typeof(byte[])) { - sum += 2; + modifiedParamCount += 2; } else { - sum++; + modifiedParamCount++; } } - - return sum; - } - - unsafe private void WriteToAllListeners(int eventId, Guid* childActivityID, int eventDataCount, EventSource.EventData* data) - { - // We represent a byte[] as a integer denoting the length and then a blob of bytes in the data pointer. This causes a spurious - // warning because eventDataCount is off by one for the byte[] case since a byte[] has 2 items associated it. So we want to check - // that the number of parameters is correct against the byte[] case, but also we the args array would be one too long if - // we just used the modifiedParamCount here -- so we need both. - int paramCount = m_eventData[eventId].Parameters.Length; - int modifiedParamCount = GetParamLenghtIncludingByteArray(m_eventData[eventId].Parameters); if (eventDataCount != modifiedParamCount) { ReportOutOfBandMessage(Resources.GetResourceString("EventSource_EventParametersMismatch", eventId, eventDataCount, paramCount), true); -- 2.34.1