diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2019-08-16 16:30:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-16 16:30:53 -0700 |
commit | cca2f13d35a93b7b545868843dffa261949c084b (patch) | |
tree | 20689fbfc9364b20b2bc99090c254dd8b446565f /src | |
parent | 3d24ceef049e486e994e8a3e7c3f2d03d3f2a3ec (diff) | |
download | coreclr-cca2f13d35a93b7b545868843dffa261949c084b.tar.gz coreclr-cca2f13d35a93b7b545868843dffa261949c084b.tar.bz2 coreclr-cca2f13d35a93b7b545868843dffa261949c084b.zip |
Allow for interface implementations in EventSource.WriteEventVarArgs (#25844) (#26056)
* Allow for interface implementations in EventSource.WriteEventVarArgs
* Also account null ref types and nullable types
* fix error in comment and simplify first part of boolean logic
* Update src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
Co-Authored-By: Noah Falk <noahfalk@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index b03011c10e..745836d3aa 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -2067,12 +2067,13 @@ namespace System.Diagnostics.Tracing { Type pType = infos[i].ParameterType; + Type? argType = args[i]?.GetType(); + // Checking to see if the Parameter types (from the Event method) match the supplied argument types. - // Fail if one of two things hold : either the argument type is not equal to the parameter type, or the - // argument is null and the parameter type is non-nullable. - if ((args[i] != null && (args[i]!.GetType() != pType)) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644) - || (args[i] == null && (!(pType.IsGenericType && pType.GetGenericTypeDefinition() == typeof(Nullable<>)))) - ) + // Fail if one of two things hold : either the argument type is not equal or assignable to the parameter type, or the + // argument is null and the parameter type is a non-Nullable<T> value type. + if ((args[i] != null && !pType.IsAssignableFrom(argType)) + || (args[i] == null && !((pType.IsGenericType && pType.GetGenericTypeDefinition() == typeof(Nullable<>)) || !pType.IsValueType))) { typesMatch = false; break; |