diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs index c81b37a4db7286..5bd6cc25797352 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs @@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; +using System.Runtime.Versioning; using StackCrawlMark = System.Threading.StackCrawlMark; namespace System @@ -89,6 +90,7 @@ public bool IsInterface // param progID: the progID of the class to retrieve // returns: the class object associated to the progID //// + [SupportedOSPlatform("windows")] public static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError) { return RuntimeType.GetTypeFromProgIDImpl(progID, server, throwOnError); @@ -101,6 +103,7 @@ public bool IsInterface // param CLSID: the CLSID of the class to retrieve // returns: the class object associated to the CLSID //// + [SupportedOSPlatform("windows")] public static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError) { return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, throwOnError); diff --git a/src/libraries/System.Private.CoreLib/src/System/Type.cs b/src/libraries/System.Private.CoreLib/src/System/Type.cs index 4e32856efd48d5..743d3142605318 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Type.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Type.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Threading; namespace System @@ -399,12 +400,18 @@ protected virtual TypeCode GetTypeCodeImpl() public abstract Guid GUID { get; } + [SupportedOSPlatform("windows")] public static Type? GetTypeFromCLSID(Guid clsid) => GetTypeFromCLSID(clsid, null, throwOnError: false); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromCLSID(Guid clsid, bool throwOnError) => GetTypeFromCLSID(clsid, null, throwOnError: throwOnError); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromCLSID(Guid clsid, string? server) => GetTypeFromCLSID(clsid, server, throwOnError: false); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromProgID(string progID) => GetTypeFromProgID(progID, null, throwOnError: false); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromProgID(string progID, bool throwOnError) => GetTypeFromProgID(progID, null, throwOnError: throwOnError); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromProgID(string progID, string? server) => GetTypeFromProgID(progID, server, throwOnError: false); public abstract Type? BaseType { get; } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 43d7e040a7e107..9e739b2298f151 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4325,14 +4325,22 @@ protected Type() { } public static System.Type[] GetTypeArray(object[] args) { throw null; } public static System.TypeCode GetTypeCode(System.Type? type) { throw null; } protected virtual System.TypeCode GetTypeCodeImpl() { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromCLSID(System.Guid clsid) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromCLSID(System.Guid clsid, bool throwOnError) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromCLSID(System.Guid clsid, string? server) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromCLSID(System.Guid clsid, string? server, bool throwOnError) { throw null; } public static System.Type GetTypeFromHandle(System.RuntimeTypeHandle handle) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromProgID(string progID) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromProgID(string progID, bool throwOnError) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromProgID(string progID, string? server) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static System.Type? GetTypeFromProgID(string progID, string? server, bool throwOnError) { throw null; } public static System.RuntimeTypeHandle GetTypeHandle(object o) { throw null; } protected abstract bool HasElementTypeImpl(); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs index 268d23b04fa3d5..ac3c8052fa896c 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Type.Mono.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using System.Runtime.Versioning; using System.Threading; namespace System @@ -96,8 +97,10 @@ public static Type GetTypeFromHandle(RuntimeTypeHandle handle) return internal_from_handle(handle.Value); } + [SupportedOSPlatform("windows")] public static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError) => throw new PlatformNotSupportedException(); + [SupportedOSPlatform("windows")] public static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError) => throw new PlatformNotSupportedException(); internal virtual Type InternalResolve()