diff options
author | Stephen Toub <stoub@microsoft.com> | 2019-01-07 19:22:14 -0500 |
---|---|---|
committer | Aaron Robinson <arobins@microsoft.com> | 2019-01-07 16:22:14 -0800 |
commit | c2ac0f95ae6d453634dbe42159ad1f740cbe0958 (patch) | |
tree | d8c8366c3d2f48af160a253fd14611c0f4ac3ea8 /src | |
parent | 59a2e255348ede17f1b57a88abc9fa04eeb2b556 (diff) | |
download | coreclr-c2ac0f95ae6d453634dbe42159ad1f740cbe0958.tar.gz coreclr-c2ac0f95ae6d453634dbe42159ad1f740cbe0958.tar.bz2 coreclr-c2ac0f95ae6d453634dbe42159ad1f740cbe0958.zip |
Check GenerateGuidForType argument for null (#21851)
* Check GenerateGuidForType argument for null
* Also check for RuntimeType
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs | 14 |
1 files changed, 13 insertions, 1 deletions
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 ff9844e206..ed3d648586 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. /// </summary> - 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; + } /// <summary> /// This method generates a PROGID for the specified type. If the type has |