summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs')
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs52
1 files changed, 12 insertions, 40 deletions
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs b/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
index 7d3670d877..0105866415 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/RegistrationServices.cs
@@ -29,6 +29,7 @@ namespace System.Runtime.InteropServices {
using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.Versioning;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
[Flags]
@@ -91,12 +92,11 @@ namespace System.Runtime.InteropServices {
#region IRegistrationServices
- [System.Security.SecurityCritical] // auto-generated_required
public virtual bool RegisterAssembly(Assembly assembly, AssemblyRegistrationFlags flags)
{
// Validate the arguments.
if (assembly == null)
- throw new ArgumentNullException("assembly");
+ throw new ArgumentNullException(nameof(assembly));
if (assembly.ReflectionOnly)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsmLoadedForReflectionOnly"));
@@ -154,12 +154,11 @@ namespace System.Runtime.InteropServices {
return false;
}
- [System.Security.SecurityCritical] // auto-generated_required
public virtual bool UnregisterAssembly(Assembly assembly)
{
// Validate the arguments.
if (assembly == null)
- throw new ArgumentNullException("assembly");
+ throw new ArgumentNullException(nameof(assembly));
if (assembly.ReflectionOnly)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsmLoadedForReflectionOnly"));
@@ -214,16 +213,15 @@ namespace System.Runtime.InteropServices {
return false;
}
- [System.Security.SecurityCritical] // auto-generated_required
public virtual Type[] GetRegistrableTypesInAssembly(Assembly assembly)
{
// Validate the arguments.
if (assembly == null)
- throw new ArgumentNullException("assembly");
+ throw new ArgumentNullException(nameof(assembly));
Contract.EndContractBlock();
if (!(assembly is RuntimeAssembly))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), "assembly");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly"), nameof(assembly));
// Retrieve the list of types in the assembly.
Type[] aTypes = assembly.GetExportedTypes();
@@ -246,23 +244,21 @@ namespace System.Runtime.InteropServices {
return RetArray;
}
- [System.Security.SecurityCritical] // auto-generated_required
public virtual String GetProgIdForType(Type type)
{
return Marshal.GenerateProgIdForType(type);
}
- [System.Security.SecurityCritical] // auto-generated_required
public virtual void RegisterTypeForComClients(Type type, ref Guid g)
{
#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
if(type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
if((type as RuntimeType) == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),"type");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),nameof(type));
if(!TypeRequiresRegistration(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),"type");
+ throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),nameof(type));
// Call the native method to do CoRegisterClassObject
RegisterTypeForComClientsNative(type, ref g);
@@ -276,13 +272,11 @@ namespace System.Runtime.InteropServices {
return s_ManagedCategoryGuid;
}
- [System.Security.SecurityCritical] // auto-generated_required
public virtual bool TypeRequiresRegistration(Type type)
{
return TypeRequiresRegistrationHelper(type);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public virtual bool TypeRepresentsComType(Type type)
{
// If the type is not a COM import, then it does not represent a COM type.
@@ -296,7 +290,7 @@ namespace System.Runtime.InteropServices {
// If the type is derived from a tdImport class and has the same GUID as the
// imported class, then it represents a COM type.
Type baseComImportType = GetBaseComImportType(type);
- Contract.Assert(baseComImportType != null, "baseComImportType != null");
+ Debug.Assert(baseComImportType != null, "baseComImportType != null");
if (Marshal.GenerateGuidForType(type) == Marshal.GenerateGuidForType(baseComImportType))
return true;
@@ -307,18 +301,17 @@ namespace System.Runtime.InteropServices {
#region Public methods not on IRegistrationServices
- [System.Security.SecurityCritical] // auto-generated_required
[ComVisible(false)]
public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
{
#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
if (type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
if ((type as RuntimeType) == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),"type");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"),nameof(type));
if (!TypeRequiresRegistration(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),"type");
+ throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"),nameof(type));
// Call the native method to do CoRegisterClassObject
return RegisterTypeForComClientsExNative(type, classContext, flags);
@@ -327,7 +320,6 @@ namespace System.Runtime.InteropServices {
#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
}
- [System.Security.SecurityCritical] // auto-generated_required
[ComVisible(false)]
public virtual void UnregisterTypeForComClients(int cookie)
{
@@ -340,7 +332,6 @@ namespace System.Runtime.InteropServices {
#region Internal helpers
- [System.Security.SecurityCritical] // auto-generated_required
internal static bool TypeRequiresRegistrationHelper(Type type)
{
// If the type is not a class or a value class, then it does not get registered.
@@ -365,7 +356,6 @@ namespace System.Runtime.InteropServices {
#region Private helpers
- [System.Security.SecurityCritical] // auto-generated
private void RegisterValueType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
{
// Retrieve some information that will be used during the registration process.
@@ -397,7 +387,6 @@ namespace System.Runtime.InteropServices {
}
}
- [System.Security.SecurityCritical] // auto-generated
private void RegisterManagedType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
{
//
@@ -483,7 +472,6 @@ namespace System.Runtime.InteropServices {
EnsureManagedCategoryExists();
}
- [System.Security.SecurityCritical] // auto-generated
private void RegisterComImportedType(Type type, String strAsmName, String strAsmVersion, String strAsmCodeBase, String strRuntimeVersion)
{
// Retrieve some information that will be used during the registration process.
@@ -525,7 +513,6 @@ namespace System.Runtime.InteropServices {
}
}
- [System.Security.SecurityCritical] // auto-generated
private bool UnregisterValueType(Type type, String strAsmVersion)
{
bool bAllVersionsGone = true;
@@ -582,7 +569,6 @@ namespace System.Runtime.InteropServices {
// Return :
// true: All versions are gone.
// false: Some versions are still left in registry
- [System.Security.SecurityCritical] // auto-generated
private bool UnregisterManagedType(Type type,String strAsmVersion)
{
bool bAllVersionsGone = true;
@@ -776,7 +762,6 @@ namespace System.Runtime.InteropServices {
// Return:
// true: All version information are gone.
// false: There are still some version left in registry
- [System.Security.SecurityCritical] // auto-generated
private bool UnregisterComImportedType(Type type, String strAsmVersion)
{
bool bAllVersionsGone = true;
@@ -846,7 +831,6 @@ namespace System.Runtime.InteropServices {
return bAllVersionsGone;
}
- [System.Security.SecurityCritical] // auto-generated
private void RegisterPrimaryInteropAssembly(RuntimeAssembly assembly, String strAsmCodeBase, PrimaryInteropAssemblyAttribute attr)
{
// Validate that the PIA has a strong name.
@@ -874,7 +858,6 @@ namespace System.Runtime.InteropServices {
}
}
- [System.Security.SecurityCritical] // auto-generated
private void UnregisterPrimaryInteropAssembly(Assembly assembly, PrimaryInteropAssemblyAttribute attr)
{
String strTlbId = "{" + Marshal.GetTypeLibGuidForAssembly(assembly).ToString().ToUpper(CultureInfo.InvariantCulture) + "}";
@@ -937,20 +920,12 @@ namespace System.Runtime.InteropServices {
private static bool ManagedCategoryExists()
{
using (RegistryKey componentCategoryKey = Registry.ClassesRoot.OpenSubKey(strComponentCategorySubKey,
-#if FEATURE_MACL
- RegistryKeyPermissionCheck.ReadSubTree))
-#else
false))
-#endif
{
if (componentCategoryKey == null)
return false;
using (RegistryKey managedCategoryKey = componentCategoryKey.OpenSubKey(strManagedCategoryGuid,
-#if FEATURE_MACL
- RegistryKeyPermissionCheck.ReadSubTree))
-#else
false))
-#endif
{
if (managedCategoryKey == null)
return false;
@@ -966,7 +941,6 @@ namespace System.Runtime.InteropServices {
return true;
}
- [System.Security.SecurityCritical] // auto-generated
private void CallUserDefinedRegistrationMethod(Type type, bool bRegister)
{
bool bFunctionCalled = false;
@@ -1069,13 +1043,11 @@ namespace System.Runtime.InteropServices {
#if FEATURE_COMINTEROP_MANAGED_ACTIVATION
// GUID versioning can be controlled by using the GuidAttribute or
// letting the runtime generate it based on type and assembly strong name.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void RegisterTypeForComClientsNative(Type type,ref Guid g);
// GUID versioning can be controlled by using the GuidAttribute or
// letting the runtime generate it based on type and assembly strong name.
- [System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int RegisterTypeForComClientsExNative(Type t, RegistrationClassContext clsContext, RegistrationConnectionType flags);
#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION