From: Stephen Toub Date: Tue, 8 Jan 2019 00:22:14 +0000 (-0500) Subject: Check GenerateGuidForType argument for null (#21851) X-Git-Tag: accepted/tizen/unified/20190422.045933~168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2ac0f95ae6d453634dbe42159ad1f740cbe0958;p=platform%2Fupstream%2Fcoreclr.git Check GenerateGuidForType argument for null (#21851) * Check GenerateGuidForType argument for null * Also check for RuntimeType --- diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index ff9844e..ed3d648 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -1540,7 +1540,19 @@ namespace System.Runtime.InteropServices /// metadata then it is returned otherwise a stable guid is generated based /// on the fully qualified name of the type. /// - public static Guid GenerateGuidForType(Type type) => type.GUID; + public static Guid GenerateGuidForType(Type type) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + if (!(type is RuntimeType)) + { + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); + } + + return type.GUID; + } /// /// This method generates a PROGID for the specified type. If the type has