summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Type.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Type.cs')
-rw-r--r--src/mscorlib/src/System/Type.cs144
1 files changed, 48 insertions, 96 deletions
diff --git a/src/mscorlib/src/System/Type.cs b/src/mscorlib/src/System/Type.cs
index 730003307a..2d30c4c7f2 100644
--- a/src/mscorlib/src/System/Type.cs
+++ b/src/mscorlib/src/System/Type.cs
@@ -9,8 +9,8 @@
//
// ======================================================================================
-namespace System {
-
+namespace System
+{
using System;
using System.Reflection;
using System.Threading;
@@ -154,7 +154,6 @@ namespace System {
// param progID: the progID of the class to retrieve
// returns: the class object associated to the progID
////
- [System.Security.SecurityCritical] // auto-generated_required
public static Type GetTypeFromProgID(String progID)
{
return RuntimeType.GetTypeFromProgIDImpl(progID, null, false);
@@ -169,19 +168,16 @@ namespace System {
// param progID: the progID of the class to retrieve
// returns: the class object associated to the progID
////
- [System.Security.SecurityCritical] // auto-generated_required
public static Type GetTypeFromProgID(String progID, bool throwOnError)
{
return RuntimeType.GetTypeFromProgIDImpl(progID, null, throwOnError);
}
- [System.Security.SecurityCritical] // auto-generated_required
public static Type GetTypeFromProgID(String progID, String server)
{
return RuntimeType.GetTypeFromProgIDImpl(progID, server, false);
}
- [System.Security.SecurityCritical] // auto-generated_required
public static Type GetTypeFromProgID(String progID, String server, bool throwOnError)
{
return RuntimeType.GetTypeFromProgIDImpl(progID, server, throwOnError);
@@ -194,25 +190,21 @@ namespace System {
// param CLSID: the CLSID of the class to retrieve
// returns: the class object associated to the CLSID
////
- [System.Security.SecuritySafeCritical] // auto-generated
public static Type GetTypeFromCLSID(Guid clsid)
{
return RuntimeType.GetTypeFromCLSIDImpl(clsid, null, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public static Type GetTypeFromCLSID(Guid clsid, bool throwOnError)
{
return RuntimeType.GetTypeFromCLSIDImpl(clsid, null, throwOnError);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public static Type GetTypeFromCLSID(Guid clsid, String server)
{
return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, false);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public static Type GetTypeFromCLSID(Guid clsid, String server, bool throwOnError)
{
return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, throwOnError);
@@ -338,12 +330,10 @@ namespace System {
}
// Given a class handle, this will return the class for that handle.
- [System.Security.SecurityCritical]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern RuntimeType GetTypeFromHandleUnsafe(IntPtr handle);
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern Type GetTypeFromHandle(RuntimeTypeHandle handle);
@@ -395,11 +385,11 @@ namespace System {
{
// Must provide some types (Type[0] for nothing)
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i=0;i<types.Length;i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetConstructorImpl(bindingAttr, binder, callConvention, types, modifiers);
}
@@ -407,11 +397,11 @@ namespace System {
public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
{
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i=0;i<types.Length;i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetConstructorImpl(bindingAttr, binder, CallingConventions.Any, types, modifiers);
}
@@ -464,13 +454,13 @@ namespace System {
ParameterModifier[] modifiers)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i = 0; i < types.Length; i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
}
@@ -481,46 +471,46 @@ namespace System {
ParameterModifier[] modifiers)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i = 0; i < types.Length; i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetMethodImpl(name, bindingAttr, binder, CallingConventions.Any, types, modifiers);
}
public MethodInfo GetMethod(String name, Type[] types, ParameterModifier[] modifiers)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i=0;i<types.Length;i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetMethodImpl(name, Type.DefaultLookup, null, CallingConventions.Any, types, modifiers);
}
public MethodInfo GetMethod(String name,Type[] types)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
for (int i=0;i<types.Length;i++)
if (types[i] == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
return GetMethodImpl(name, Type.DefaultLookup, null, CallingConventions.Any, types, null);
}
public MethodInfo GetMethod(String name, BindingFlags bindingAttr)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
return GetMethodImpl(name, bindingAttr, null, CallingConventions.Any, null, null);
}
@@ -528,7 +518,7 @@ namespace System {
public MethodInfo GetMethod(String name)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
return GetMethodImpl(name, Type.DefaultLookup, null, CallingConventions.Any, null, null);
}
@@ -584,7 +574,7 @@ namespace System {
public virtual Type[] FindInterfaces(TypeFilter filter,Object filterCriteria)
{
if (filter == null)
- throw new ArgumentNullException("filter");
+ throw new ArgumentNullException(nameof(filter));
Contract.EndContractBlock();
Type[] c = GetInterfaces();
int cnt = 0;
@@ -631,9 +621,9 @@ namespace System {
Type returnType, Type[] types, ParameterModifier[] modifiers)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
return GetPropertyImpl(name,bindingAttr,binder,returnType,types,modifiers);
}
@@ -641,9 +631,9 @@ namespace System {
public PropertyInfo GetProperty(String name, Type returnType, Type[] types,ParameterModifier[] modifiers)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
return GetPropertyImpl(name,Type.DefaultLookup,null,returnType,types,modifiers);
}
@@ -651,7 +641,7 @@ namespace System {
public PropertyInfo GetProperty(String name, BindingFlags bindingAttr)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
return GetPropertyImpl(name,bindingAttr,null,null,null,null);
}
@@ -659,9 +649,9 @@ namespace System {
public PropertyInfo GetProperty(String name, Type returnType, Type[] types)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
return GetPropertyImpl(name,Type.DefaultLookup,null,returnType,types,null);
}
@@ -669,9 +659,9 @@ namespace System {
public PropertyInfo GetProperty(String name, Type[] types)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (types == null)
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
Contract.EndContractBlock();
return GetPropertyImpl(name,Type.DefaultLookup,null,null,types,null);
}
@@ -679,9 +669,9 @@ namespace System {
public PropertyInfo GetProperty(String name, Type returnType)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (returnType == null)
- throw new ArgumentNullException("returnType");
+ throw new ArgumentNullException(nameof(returnType));
Contract.EndContractBlock();
return GetPropertyImpl(name,Type.DefaultLookup,null,returnType,null,null);
}
@@ -689,9 +679,9 @@ namespace System {
internal PropertyInfo GetProperty(String name, BindingFlags bindingAttr, Type returnType)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (returnType == null)
- throw new ArgumentNullException("returnType");
+ throw new ArgumentNullException(nameof(returnType));
Contract.EndContractBlock();
return GetPropertyImpl(name, bindingAttr, null, returnType, null, null);
}
@@ -699,7 +689,7 @@ namespace System {
public PropertyInfo GetProperty(String name)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
Contract.EndContractBlock();
return GetPropertyImpl(name,Type.DefaultLookup,null,null,null,null);
}
@@ -716,8 +706,7 @@ namespace System {
{
return GetProperties(Type.DefaultLookup);
}
-#if !FEATURE_CORECLR
-#endif
+
// GetNestedTypes()
// This set of method will return any nested types that are found inside
// of the type.
@@ -728,9 +717,6 @@ namespace System {
abstract public Type[] GetNestedTypes(BindingFlags bindingAttr);
-#if !FEATURE_CORECLR
- // GetNestedType()
-#endif
public Type GetNestedType(String name)
{
return GetNestedType(name,Type.DefaultLookup);
@@ -1050,7 +1036,6 @@ namespace System {
public bool IsInterface {
[Pure]
- [System.Security.SecuritySafeCritical] // auto-generated
get
{
RuntimeType rt = this as RuntimeType;
@@ -1076,11 +1061,7 @@ namespace System {
get {return ((GetAttributeFlagsImpl() & TypeAttributes.Sealed) != 0);}
}
-#if FEATURE_CORECLR
- public bool IsEnum {
-#else
public virtual bool IsEnum {
-#endif
[Pure]
get
{
@@ -1305,14 +1286,15 @@ namespace System {
// Protected routine to determine if this class is contextful
- protected virtual bool IsContextfulImpl(){
- return typeof(ContextBoundObject).IsAssignableFrom(this);
+ protected virtual bool IsContextfulImpl()
+ {
+ return false;
}
-
// Protected routine to determine if this class is marshaled by ref
- protected virtual bool IsMarshalByRefImpl(){
- return typeof(MarshalByRefObject).IsAssignableFrom(this);
+ protected virtual bool IsMarshalByRefImpl()
+ {
+ return false;
}
internal virtual bool HasProxyAttributeImpl()
@@ -1362,7 +1344,7 @@ namespace System {
return rootElementType;
}
- #region Enum methods
+#region Enum methods
// Default implementations of GetEnumNames, GetEnumValues, and GetEnumUnderlyingType
// Subclass of types can override these methods.
@@ -1465,7 +1447,7 @@ namespace System {
public virtual bool IsEnumDefined(object value)
{
if (value == null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
if (!IsEnum)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
@@ -1513,7 +1495,7 @@ namespace System {
public virtual string GetEnumName(object value)
{
if (value == null)
- throw new ArgumentNullException("value");
+ throw new ArgumentNullException(nameof(value));
if (!IsEnum)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
@@ -1522,7 +1504,7 @@ namespace System {
Type valueType = value.GetType();
if (!(valueType.IsEnum || Type.IsIntegerType(valueType)))
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), "value");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), nameof(value));
Array values = GetEnumRawConstantValues();
int index = BinarySearch(values, value);
@@ -1561,7 +1543,7 @@ namespace System {
t == typeof(char) ||
t == typeof(bool));
}
- #endregion
+#endregion
public virtual bool IsSecurityCritical { [Pure] get { throw new NotImplementedException(); } }
@@ -1743,7 +1725,7 @@ namespace System {
// types.
public static Type[] GetTypeArray(Object[] args) {
if (args == null)
- throw new ArgumentNullException("args");
+ throw new ArgumentNullException(nameof(args));
Contract.EndContractBlock();
Type[] cls = new Type[args.Length];
for (int i = 0;i < cls.Length;i++)
@@ -1766,11 +1748,7 @@ namespace System {
// _Type.Equals(Type)
[Pure]
-#if !FEATURE_CORECLR
public virtual bool Equals(Type o)
-#else
- public bool Equals(Type o)
-#endif
{
if ((object)o == null)
return false;
@@ -1778,12 +1756,10 @@ namespace System {
return (Object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType));
}
- [System.Security.SecuritySafeCritical]
[Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool operator ==(Type left, Type right);
- [System.Security.SecuritySafeCritical]
[Pure]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern bool operator !=(Type left, Type right);
@@ -1814,30 +1790,6 @@ namespace System {
return base.GetType();
}
-#if !FEATURE_CORECLR
- void _Type.GetTypeInfoCount(out uint pcTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Type.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _Type.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
- {
- throw new NotImplementedException();
- }
-
- // If you implement this method, make sure to include _Type.Invoke in VM\DangerousAPIs.h and
- // include _Type in SystemDomain::IsReflectionInvocationMethod in AppDomain.cpp.
- void _Type.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
- {
- throw new NotImplementedException();
- }
-#endif
-
// private convenience data
private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
internal const BindingFlags DeclaredOnlyLookup = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;