summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs14
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