Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,219 @@
// ==++==
//
// Copyright(c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
//
namespace System.Reflection
{
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
internal static class Associates
{
[Flags]
internal enum Attributes
{
ComposedOfAllVirtualMethods = 0x1,
ComposedOfAllPrivateMethods = 0x2,
ComposedOfNoPublicMembers = 0x4,
ComposedOfNoStaticMembers = 0x8,
}
internal static bool IncludeAccessor(MethodInfo associate, bool nonPublic)
{
if ((object)associate == null)
return false;
if (nonPublic)
return true;
if (associate.IsPublic)
return true;
return false;
}
[System.Security.SecurityCritical] // auto-generated
private static unsafe RuntimeMethodInfo AssignAssociates(
int tkMethod,
RuntimeType declaredType,
RuntimeType reflectedType)
{
if (MetadataToken.IsNullToken(tkMethod))
return null;
Contract.Assert(declaredType != null);
Contract.Assert(reflectedType != null);
bool isInherited = declaredType != reflectedType;
IntPtr[] genericArgumentHandles = null;
int genericArgumentCount = 0;
RuntimeType [] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal();
if (genericArguments != null)
{
genericArgumentCount = genericArguments.Length;
genericArgumentHandles = new IntPtr[genericArguments.Length];
for (int i = 0; i < genericArguments.Length; i++)
{
genericArgumentHandles[i] = genericArguments[i].GetTypeHandleInternal().Value;
}
}
RuntimeMethodHandleInternal associateMethodHandle = ModuleHandle.ResolveMethodHandleInternalCore(RuntimeTypeHandle.GetModule(declaredType), tkMethod, genericArgumentHandles, genericArgumentCount, null, 0);
Contract.Assert(!associateMethodHandle.IsNullHandle(), "Failed to resolve associateRecord methodDef token");
if (isInherited)
{
MethodAttributes methAttr = RuntimeMethodHandle.GetAttributes(associateMethodHandle);
// ECMA MethodSemantics: "All methods for a given Property or Event shall have the same accessibility
//(ie the MemberAccessMask subfield of their Flags row) and cannot be CompilerControlled [CLS]"
// Consequently, a property may be composed of public and private methods. If the declared type !=
// the reflected type, the private methods should not be exposed. Note that this implies that the
// identity of a property includes it's reflected type.
// NetCF actually includes private methods from parent classes in Reflection results
// We will mimic that in Mango Compat mode.
if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
{
if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
return null;
}
// Note this is the first time the property was encountered walking from the most derived class
// towards the base class. It would seem to follow that any associated methods would not
// be overriden -- but this is not necessarily true. A more derived class may have overriden a
// virtual method associated with a property in a base class without associating the override with
// the same or any property in the derived class.
if ((methAttr & MethodAttributes.Virtual) != 0)
{
bool declaringTypeIsClass =
(RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class;
// It makes no sense to search for a virtual override of a method declared on an interface.
if (declaringTypeIsClass)
{
int slot = RuntimeMethodHandle.GetSlot(associateMethodHandle);
// Find the override visible from the reflected type
associateMethodHandle = RuntimeTypeHandle.GetMethodAt(reflectedType, slot);
}
}
}
RuntimeMethodInfo associateMethod =
RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo;
// suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle
if (associateMethod == null)
associateMethod = reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo;
return associateMethod;
}
[System.Security.SecurityCritical] // auto-generated
internal static unsafe void AssignAssociates(
MetadataImport scope,
int mdPropEvent,
RuntimeType declaringType,
RuntimeType reflectedType,
out RuntimeMethodInfo addOn,
out RuntimeMethodInfo removeOn,
out RuntimeMethodInfo fireOn,
out RuntimeMethodInfo getter,
out RuntimeMethodInfo setter,
out MethodInfo[] other,
out bool composedOfAllPrivateMethods,
out BindingFlags bindingFlags)
{
addOn = removeOn = fireOn = getter = setter = null;
Attributes attributes =
Attributes.ComposedOfAllPrivateMethods |
Attributes.ComposedOfAllVirtualMethods |
Attributes.ComposedOfNoPublicMembers |
Attributes.ComposedOfNoStaticMembers;
while(RuntimeTypeHandle.IsGenericVariable(reflectedType))
reflectedType = (RuntimeType)reflectedType.BaseType;
bool isInherited = declaringType != reflectedType;
List<MethodInfo> otherList = null;
MetadataEnumResult associatesData;
scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out associatesData);
int cAssociates = associatesData.Length / 2;
for (int i = 0; i < cAssociates; i++)
{
int methodDefToken = associatesData[i * 2];
MethodSemanticsAttributes semantics = (MethodSemanticsAttributes)associatesData[i * 2 + 1];
#region Assign each associate
RuntimeMethodInfo associateMethod =
AssignAssociates(methodDefToken, declaringType, reflectedType);
if (associateMethod == null)
continue;
MethodAttributes methAttr = associateMethod.Attributes;
bool isPrivate =(methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
bool isVirtual =(methAttr & MethodAttributes.Virtual) != 0;
MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask;
bool isPublic = visibility == MethodAttributes.Public;
bool isStatic =(methAttr & MethodAttributes.Static) != 0;
if (isPublic)
{
attributes &= ~Attributes.ComposedOfNoPublicMembers;
attributes &= ~Attributes.ComposedOfAllPrivateMethods;
}
else if (!isPrivate)
{
attributes &= ~Attributes.ComposedOfAllPrivateMethods;
}
if (isStatic)
attributes &= ~Attributes.ComposedOfNoStaticMembers;
if (!isVirtual)
attributes &= ~Attributes.ComposedOfAllVirtualMethods;
#endregion
if (semantics == MethodSemanticsAttributes.Setter)
setter = associateMethod;
else if (semantics == MethodSemanticsAttributes.Getter)
getter = associateMethod;
else if (semantics == MethodSemanticsAttributes.Fire)
fireOn = associateMethod;
else if (semantics == MethodSemanticsAttributes.AddOn)
addOn = associateMethod;
else if (semantics == MethodSemanticsAttributes.RemoveOn)
removeOn = associateMethod;
else
{
if (otherList == null)
otherList = new List<MethodInfo>(cAssociates);
otherList.Add(associateMethod);
}
}
bool isPseudoPublic = (attributes & Attributes.ComposedOfNoPublicMembers) == 0;
bool isPseudoStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0;
bindingFlags = RuntimeType.FilterPreCalculate(isPseudoPublic, isInherited, isPseudoStatic);
composedOfAllPrivateMethods =(attributes & Attributes.ComposedOfAllPrivateMethods) != 0;
other = (otherList != null) ? otherList.ToArray() : null;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
using System.Collections.Generic;
namespace System.Reflection
{
public static class CustomAttributeExtensions
{
#region APIs that return a single attribute
public static Attribute GetCustomAttribute(this Assembly element, Type attributeType)
{
return Attribute.GetCustomAttribute(element, attributeType);
}
public static Attribute GetCustomAttribute(this Module element, Type attributeType)
{
return Attribute.GetCustomAttribute(element, attributeType);
}
public static Attribute GetCustomAttribute(this MemberInfo element, Type attributeType)
{
return Attribute.GetCustomAttribute(element, attributeType);
}
public static Attribute GetCustomAttribute(this ParameterInfo element, Type attributeType)
{
return Attribute.GetCustomAttribute(element, attributeType);
}
public static T GetCustomAttribute<T>(this Assembly element) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T));
}
public static T GetCustomAttribute<T>(this Module element) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T));
}
public static T GetCustomAttribute<T>(this MemberInfo element) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T));
}
public static T GetCustomAttribute<T>(this ParameterInfo element) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T));
}
public static Attribute GetCustomAttribute(this MemberInfo element, Type attributeType, bool inherit)
{
return Attribute.GetCustomAttribute(element, attributeType, inherit);
}
public static Attribute GetCustomAttribute(this ParameterInfo element, Type attributeType, bool inherit)
{
return Attribute.GetCustomAttribute(element, attributeType, inherit);
}
public static T GetCustomAttribute<T>(this MemberInfo element, bool inherit) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T), inherit);
}
public static T GetCustomAttribute<T>(this ParameterInfo element, bool inherit) where T : Attribute
{
return (T)GetCustomAttribute(element, typeof(T), inherit);
}
#endregion
#region APIs that return all attributes
public static IEnumerable<Attribute> GetCustomAttributes(this Assembly element)
{
return Attribute.GetCustomAttributes(element);
}
public static IEnumerable<Attribute> GetCustomAttributes(this Module element)
{
return Attribute.GetCustomAttributes(element);
}
public static IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element)
{
return Attribute.GetCustomAttributes(element);
}
public static IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element)
{
return Attribute.GetCustomAttributes(element);
}
public static IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, bool inherit)
{
return Attribute.GetCustomAttributes(element, inherit);
}
public static IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, bool inherit)
{
return Attribute.GetCustomAttributes(element, inherit);
}
#endregion
#region APIs that return all attributes of a particular type
public static IEnumerable<Attribute> GetCustomAttributes(this Assembly element, Type attributeType)
{
return Attribute.GetCustomAttributes(element, attributeType);
}
public static IEnumerable<Attribute> GetCustomAttributes(this Module element, Type attributeType)
{
return Attribute.GetCustomAttributes(element, attributeType);
}
public static IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, Type attributeType)
{
return Attribute.GetCustomAttributes(element, attributeType);
}
public static IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, Type attributeType)
{
return Attribute.GetCustomAttributes(element, attributeType);
}
public static IEnumerable<T> GetCustomAttributes<T>(this Assembly element) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T));
}
public static IEnumerable<T> GetCustomAttributes<T>(this Module element) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T));
}
public static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T));
}
public static IEnumerable<T> GetCustomAttributes<T>(this ParameterInfo element) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T));
}
public static IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, Type attributeType, bool inherit)
{
return Attribute.GetCustomAttributes(element, attributeType, inherit);
}
public static IEnumerable<Attribute> GetCustomAttributes(this ParameterInfo element, Type attributeType, bool inherit)
{
return Attribute.GetCustomAttributes(element, attributeType, inherit);
}
public static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element, bool inherit) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T), inherit);
}
public static IEnumerable<T> GetCustomAttributes<T>(this ParameterInfo element, bool inherit) where T : Attribute
{
return (IEnumerable<T>)GetCustomAttributes(element, typeof(T), inherit);
}
#endregion
#region IsDefined
public static bool IsDefined(this Assembly element, Type attributeType)
{
return Attribute.IsDefined(element, attributeType);
}
public static bool IsDefined(this Module element, Type attributeType)
{
return Attribute.IsDefined(element, attributeType);
}
public static bool IsDefined(this MemberInfo element, Type attributeType)
{
return Attribute.IsDefined(element, attributeType);
}
public static bool IsDefined(this ParameterInfo element, Type attributeType)
{
return Attribute.IsDefined(element, attributeType);
}
public static bool IsDefined(this MemberInfo element, Type attributeType, bool inherit)
{
return Attribute.IsDefined(element, attributeType, inherit);
}
public static bool IsDefined(this ParameterInfo element, Type attributeType, bool inherit)
{
return Attribute.IsDefined(element, attributeType, inherit);
}
#endregion
}
}

View File

@@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
namespace System.Reflection
{
public static class RuntimeReflectionExtensions
{
private const BindingFlags everything = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
private static void CheckAndThrow(Type t)
{
if (t == null) throw new ArgumentNullException("type");
if (!(t is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
}
private static void CheckAndThrow(MethodInfo m)
{
if (m == null) throw new ArgumentNullException("method");
if (!(m is RuntimeMethodInfo)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"));
}
public static IEnumerable<PropertyInfo> GetRuntimeProperties(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperties(type.GetFullNameForEtw());
}
#endif
IEnumerable<PropertyInfo> properties = type.GetProperties(everything);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperties(type.GetFullNameForEtw());
}
#endif
return properties;
}
public static IEnumerable<EventInfo> GetRuntimeEvents(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvents(type.GetFullNameForEtw());
}
#endif
IEnumerable<EventInfo> events = type.GetEvents(everything);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvents(type.GetFullNameForEtw());
}
#endif
return events;
}
public static IEnumerable<MethodInfo> GetRuntimeMethods(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethods(type.GetFullNameForEtw());
}
#endif
IEnumerable<MethodInfo> methods = type.GetMethods(everything);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethods(type.GetFullNameForEtw());
}
#endif
return methods;
}
public static IEnumerable<FieldInfo> GetRuntimeFields(this Type type)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeFields(type.GetFullNameForEtw());
}
#endif
IEnumerable<FieldInfo> fields = type.GetFields(everything);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeFields(type.GetFullNameForEtw());
}
#endif
return fields;
}
public static PropertyInfo GetRuntimeProperty(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeProperty(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
PropertyInfo pi = type.GetProperty(name);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeProperty(type.GetFullNameForEtw(), pi != null ? pi.GetFullNameForEtw() : "");
}
#endif
return pi;
}
public static EventInfo GetRuntimeEvent(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeEvent(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
EventInfo ei = type.GetEvent(name);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeEvent(type.GetFullNameForEtw(), ei != null ? ei.GetFullNameForEtw() : "");
}
#endif
return ei;
}
public static MethodInfo GetRuntimeMethod(this Type type, string name, Type[] parameters)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeMethod(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
MethodInfo mi = type.GetMethod(name, parameters);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeMethod(type.GetFullNameForEtw(), mi != null ? mi.GetFullNameForEtw() : "");
}
#endif
return mi;
}
public static FieldInfo GetRuntimeField(this Type type, string name)
{
CheckAndThrow(type);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.BeginGetRuntimeField(type.GetFullNameForEtw(), name != null ? name : "");
}
#endif
FieldInfo fi = type.GetField(name);
#if !FEATURE_CORECLR
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
{
FrameworkEventSource.Log.EndGetRuntimeField(type.GetFullNameForEtw(), fi != null ? fi.GetFullNameForEtw() : "");
}
#endif
return fi;
}
public static MethodInfo GetRuntimeBaseDefinition(this MethodInfo method){
CheckAndThrow(method);
return method.GetBaseDefinition();
}
public static InterfaceMapping GetRuntimeInterfaceMap(this TypeInfo typeInfo, Type interfaceType)
{
if (typeInfo == null) throw new ArgumentNullException("typeInfo");
if (!(typeInfo is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
return typeInfo.GetInterfaceMap(interfaceType);
}
public static MethodInfo GetMethodInfo(this Delegate del)
{
if (del == null) throw new ArgumentNullException("del");
return del.Method;
}
}
}

View File

@@ -0,0 +1,72 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// <OWNER>[....]</OWNER>
//
// This class defines the delegate methods for the COM+ implemented filters.
// This is the reflection version of these. There is also a _Filters class in
// runtime which is related to this.
//
//
//
//
namespace System.Reflection {
using System;
using System.Globalization;
//<
[Serializable]
internal class __Filters {
// FilterTypeName
// This method will filter the class based upon the name. It supports
// a trailing wild card.
public virtual bool FilterTypeName(Type cls,Object filterCriteria)
{
// Check that the criteria object is a String object
if (filterCriteria == null || !(filterCriteria is String))
throw new InvalidFilterCriteriaException(System.Environment.GetResourceString("RFLCT.FltCritString"));
String str = (String) filterCriteria;
//str = str.Trim();
// Check to see if this is a prefix or exact match requirement
if (str.Length > 0 && str[str.Length - 1] == '*') {
str = str.Substring(0, str.Length - 1);
return cls.Name.StartsWith(str, StringComparison.Ordinal);
}
return cls.Name.Equals(str);
}
// FilterFieldNameIgnoreCase
// This method filter the Type based upon name, it ignores case.
public virtual bool FilterTypeNameIgnoreCase(Type cls, Object filterCriteria)
{
// Check that the criteria object is a String object
if(filterCriteria == null || !(filterCriteria is String))
throw new InvalidFilterCriteriaException(System.Environment.GetResourceString("RFLCT.FltCritString"));
String str = (String) filterCriteria;
//str = str.Trim();
// Check to see if this is a prefix or exact match requirement
if (str.Length > 0 && str[str.Length - 1] == '*') {
str = str.Substring(0, str.Length - 1);
String name = cls.Name;
if (name.Length >= str.Length)
return (String.Compare(name,0,str,0,str.Length, StringComparison.OrdinalIgnoreCase)==0);
else
return false;
}
return (String.Compare(str,cls.Name, StringComparison.OrdinalIgnoreCase) == 0);
}
}
}

View File

@@ -0,0 +1,44 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// AmbiguousMatchException is thrown when binding to a method results in more
//
// <OWNER>[....]</OWNER>
// than one method matching the binding criteria. This exception is thrown in
// general when something is Ambiguous.
//
//
//
//
namespace System.Reflection {
using System;
using SystemException = System.SystemException;
using System.Runtime.Serialization;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AmbiguousMatchException : SystemException
{
public AmbiguousMatchException()
: base(Environment.GetResourceString("RFLCT.Ambiguous")) {
SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
}
public AmbiguousMatchException(String message) : base(message) {
SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
}
public AmbiguousMatchException(String message, Exception inner) : base(message, inner) {
SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
}
internal AmbiguousMatchException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
}
}

View File

@@ -0,0 +1 @@
c6cd6858af471f75758f30ba87295e7fae83cd52

View File

@@ -0,0 +1,411 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*=============================================================================
**
** File: AssemblyAttributes
**
** <OWNER>[....]</OWNER>
**
**
** Purpose: For Assembly-related custom attributes.
**
**
=============================================================================*/
namespace System.Reflection {
using System;
using System.Configuration.Assemblies;
using System.Diagnostics.Contracts;
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCopyrightAttribute : Attribute
{
private String m_copyright;
public AssemblyCopyrightAttribute(String copyright)
{
m_copyright = copyright;
}
public String Copyright
{
get { return m_copyright; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyTrademarkAttribute : Attribute
{
private String m_trademark;
public AssemblyTrademarkAttribute(String trademark)
{
m_trademark = trademark;
}
public String Trademark
{
get { return m_trademark; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyProductAttribute : Attribute
{
private String m_product;
public AssemblyProductAttribute(String product)
{
m_product = product;
}
public String Product
{
get { return m_product; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCompanyAttribute : Attribute
{
private String m_company;
public AssemblyCompanyAttribute(String company)
{
m_company = company;
}
public String Company
{
get { return m_company; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDescriptionAttribute : Attribute
{
private String m_description;
public AssemblyDescriptionAttribute(String description)
{
m_description = description;
}
public String Description
{
get { return m_description; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyTitleAttribute : Attribute
{
private String m_title;
public AssemblyTitleAttribute(String title)
{
m_title = title;
}
public String Title
{
get { return m_title; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyConfigurationAttribute : Attribute
{
private String m_configuration;
public AssemblyConfigurationAttribute(String configuration)
{
m_configuration = configuration;
}
public String Configuration
{
get { return m_configuration; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDefaultAliasAttribute : Attribute
{
private String m_defaultAlias;
public AssemblyDefaultAliasAttribute(String defaultAlias)
{
m_defaultAlias = defaultAlias;
}
public String DefaultAlias
{
get { return m_defaultAlias; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyInformationalVersionAttribute : Attribute
{
private String m_informationalVersion;
public AssemblyInformationalVersionAttribute(String informationalVersion)
{
m_informationalVersion = informationalVersion;
}
public String InformationalVersion
{
get { return m_informationalVersion; }
}
}
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyFileVersionAttribute : Attribute
{
private String _version;
public AssemblyFileVersionAttribute(String version)
{
if (version == null)
throw new ArgumentNullException("version");
Contract.EndContractBlock();
_version = version;
}
public String Version {
get { return _version; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyCultureAttribute : Attribute
{
private String m_culture;
public AssemblyCultureAttribute(String culture)
{
m_culture = culture;
}
public String Culture
{
get { return m_culture; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyVersionAttribute : Attribute
{
private String m_version;
public AssemblyVersionAttribute(String version)
{
m_version = version;
}
public String Version
{
get { return m_version; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyFileAttribute : Attribute
{
private String m_keyFile;
public AssemblyKeyFileAttribute(String keyFile)
{
m_keyFile = keyFile;
}
public String KeyFile
{
get { return m_keyFile; }
}
}
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDelaySignAttribute : Attribute
{
private bool m_delaySign;
public AssemblyDelaySignAttribute(bool delaySign)
{
m_delaySign = delaySign;
}
public bool DelaySign
{ get
{ return m_delaySign; }
}
}
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyAlgorithmIdAttribute : Attribute
{
private uint m_algId;
public AssemblyAlgorithmIdAttribute(AssemblyHashAlgorithm algorithmId)
{
m_algId = (uint) algorithmId;
}
[CLSCompliant(false)]
public AssemblyAlgorithmIdAttribute(uint algorithmId)
{
m_algId = algorithmId;
}
[CLSCompliant(false)]
public uint AlgorithmId
{
get { return m_algId; }
}
}
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyFlagsAttribute : Attribute
{
private AssemblyNameFlags m_flags;
[Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[CLSCompliant(false)]
public AssemblyFlagsAttribute(uint flags)
{
m_flags = (AssemblyNameFlags)flags;
}
[Obsolete("This property has been deprecated. Please use AssemblyFlags instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[CLSCompliant(false)]
public uint Flags
{
get { return (uint)m_flags; }
}
// This, of course, should be typed as AssemblyNameFlags. The compat police don't allow such changes.
public int AssemblyFlags
{
get { return (int)m_flags; }
}
[Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute(int assemblyFlags)
{
m_flags = (AssemblyNameFlags)assemblyFlags;
}
public AssemblyFlagsAttribute(AssemblyNameFlags assemblyFlags)
{
m_flags = assemblyFlags;
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true, Inherited=false)]
public sealed class AssemblyMetadataAttribute : Attribute
{
private String m_key;
private String m_value;
public AssemblyMetadataAttribute(string key, string value)
{
m_key = key;
m_value = value;
}
public string Key
{
get { return m_key; }
}
public string Value
{
get { return m_value;}
}
}
// We don't support key migration on Silverlight, as libraries should all be distributed with the application.
#if FEATURE_STRONGNAME_MIGRATION || FEATURE_NETCORE
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple=false)]
public sealed class AssemblySignatureKeyAttribute : Attribute
{
private String _publicKey;
private String _countersignature;
public AssemblySignatureKeyAttribute(String publicKey, String countersignature)
{
_publicKey = publicKey;
_countersignature = countersignature;
}
public String PublicKey
{
get { return _publicKey; }
}
public String Countersignature
{
get { return _countersignature; }
}
}
#endif
#if FEATURE_CORECLR || !FEATURE_PAL
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyNameAttribute : Attribute
{
private String m_keyName;
public AssemblyKeyNameAttribute(String keyName)
{
m_keyName = keyName;
}
public String KeyName
{
get { return m_keyName; }
}
}
#endif // FEATURE_CORECLR || !FEATURE_PAL
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: AssemblyNameFlags
**
** <OWNER>[....]</OWNER>
** <OWNER>[....]</OWNER>
**
**
** Purpose: Flags controlling how an AssemblyName is used
** during binding
**
**
===========================================================*/
namespace System.Reflection {
using System;
[Serializable]
[FlagsAttribute()]
[System.Runtime.InteropServices.ComVisible(true)]
public enum AssemblyNameFlags
{
None = 0x0000,
// Flag used to indicate that an assembly ref contains the full public key, not the compressed token.
// Must match afPublicKey in CorHdr.h.
PublicKey = 0x0001,
//ProcArchMask = 0x00F0, // Bits describing the processor architecture
// Accessible via AssemblyName.ProcessorArchitecture
EnableJITcompileOptimizer = 0x4000,
EnableJITcompileTracking = 0x8000,
Retargetable = 0x0100,
//ContentType = 0x0E00, // Bits describing the ContentType are accessible via AssemblyName.ContentType
}
[Serializable]
[System.Runtime.InteropServices.ComVisible(false)]
public enum AssemblyContentType
{
Default = 0x0000,
WindowsRuntime = 0x0001
}
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ProcessorArchitecture
{
None = 0x0000,
MSIL = 0x0001,
X86 = 0x0002,
IA64 = 0x0003,
Amd64 = 0x0004,
Arm = 0x0005
}
}

View File

@@ -0,0 +1,32 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** File: AssemblyNameProxy
**
** <OWNER>[....]</OWNER>
** <OWNER>[....]</OWNER>
**
**
** Purpose: Remotable version the AssemblyName
**
**
===========================================================*/
namespace System.Reflection {
using System;
using System.Runtime.Versioning;
[System.Runtime.InteropServices.ComVisible(true)]
public class AssemblyNameProxy : MarshalByRefObject
{
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
public AssemblyName GetAssemblyName(String assemblyFile)
{
return AssemblyName.GetAssemblyName(assemblyFile);
}
}
}

View File

@@ -0,0 +1,64 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
//
// <OWNER>[....]</OWNER>
//
// This interface defines a set of methods which interact with reflection
// during the binding process. This control allows systems to apply language
// specific semantics to the binding and invocation process.
//
// <EMAIL>Author: darylo</EMAIL>
// Date: June 98
//
namespace System.Reflection {
using System;
using System.Runtime.InteropServices;
using CultureInfo = System.Globalization.CultureInfo;
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDual)]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Binder
{
// Given a set of methods that match the basic criteria, select a method to
// invoke. When this method is finished, we should have
public abstract MethodBase BindToMethod(BindingFlags bindingAttr,MethodBase[] match,ref Object[] args,
ParameterModifier[] modifiers,CultureInfo culture,String[] names, out Object state);
// Given a set of methods that match the basic criteria, select a method to
// invoke. When this method is finished, we should have
public abstract FieldInfo BindToField(BindingFlags bindingAttr,FieldInfo[] match,
Object value,CultureInfo culture);
// Given a set of methods that match the base criteria, select a method based
// upon an array of types. This method should return null if no method matchs
// the criteria.
public abstract MethodBase SelectMethod(BindingFlags bindingAttr,MethodBase[] match,
Type[] types,ParameterModifier[] modifiers);
// Given a set of propreties that match the base criteria, select one.
public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr,PropertyInfo[] match,
Type returnType,Type[] indexes,ParameterModifier[] modifiers);
// ChangeType
// This method will convert the value into the property type.
// It throws a cast exception if this fails.
public abstract Object ChangeType(Object value,Type type,CultureInfo culture);
public abstract void ReorderArgumentArray(ref Object[] args, Object state);
#if !FEATURE_COMINTEROP
// CanChangeType
// This method checks whether the value can be converted into the property type.
public virtual bool CanChangeType(Object value,Type type,CultureInfo culture)
{
return false;
}
#endif
}
}

View File

@@ -0,0 +1,68 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// BindingFlags are a set of flags that control the binding and invocation process
//
// <OWNER>[....]</OWNER>
// in Reflection. There are two processes. The first is selection of a Member which
// is the binding phase. The second, is invocation. These flags control how this
// process works.
//
// <EMAIL>Author: darylo</EMAIL>
// Date: June 99
//
namespace System.Reflection {
using System;
[Serializable]
[Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum BindingFlags
{
// NOTES: We have lookup masks defined in RuntimeType and Activator. If we
// change the lookup values then these masks may need to change also.
// a place holder for no flag specifed
Default = 0x00,
// These flags indicate what to search for when binding
IgnoreCase = 0x01, // Ignore the case of Names while searching
DeclaredOnly = 0x02, // Only look at the members declared on the Type
Instance = 0x04, // Include Instance members in search
Static = 0x08, // Include Static members in search
Public = 0x10, // Include Public members in search
NonPublic = 0x20, // Include Non-Public members in search
FlattenHierarchy = 0x40, // Rollup the statics into the class.
// These flags are used by InvokeMember to determine
// what type of member we are trying to Invoke.
// BindingAccess = 0xFF00;
InvokeMethod = 0x0100,
CreateInstance = 0x0200,
GetField = 0x0400,
SetField = 0x0800,
GetProperty = 0x1000,
SetProperty = 0x2000,
// These flags are also used by InvokeMember but they should only
// be used when calling InvokeMember on a COM object.
PutDispProperty = 0x4000,
PutRefDispProperty = 0x8000,
ExactBinding = 0x010000, // Bind with Exact Type matching, No Change type
SuppressChangeType = 0x020000,
// DefaultValueBinding will return the set of methods having ArgCount or
// more parameters. This is used for default values, etc.
OptionalParamBinding = 0x040000,
// These are a couple of misc attributes used
IgnoreReturn = 0x01000000, // This is used in COM Interop
}
}

View File

@@ -0,0 +1,33 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// CallingConventions is a set of Bits representing the calling conventions
//
// <OWNER>[....]</OWNER>
// in the system.
//
// <EMAIL>Author: [....]</EMAIL>
// Date: Aug 99
//
namespace System.Reflection {
using System.Runtime.InteropServices;
using System;
[Serializable]
[Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
{
//NOTE: If you change this please update COMMember.cpp. These
// are defined there.
Standard = 0x0001,
VarArgs = 0x0002,
Any = Standard | VarArgs,
HasThis = 0x0020,
ExplicitThis = 0x0040,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
a5689babc0b607e4a222569a7ec1e81582c4db20

View File

@@ -0,0 +1,42 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// CustomAttributeFormatException is thrown when the binary format of a
//
// <OWNER>[....]</OWNER>
// custom attribute is invalid.
//
// <EMAIL>Author: darylo</EMAIL>
// Date: [....] 98
//
namespace System.Reflection {
using System;
using ApplicationException = System.ApplicationException;
using System.Runtime.Serialization;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class CustomAttributeFormatException : FormatException {
public CustomAttributeFormatException()
: base(Environment.GetResourceString("Arg_CustomAttributeFormatException")) {
SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
}
public CustomAttributeFormatException(String message) : base(message) {
SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
}
public CustomAttributeFormatException(String message, Exception inner) : base(message, inner) {
SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
}
protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
}
}

View File

@@ -0,0 +1,42 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// DefaultMemberAttribute is defines the Member of a Type that is the "default"
//
// <OWNER>[....]</OWNER>
// member used by Type.InvokeMember. The default member is simply a name given
// to a type.
//
//
//
//
namespace System.Reflection {
using System;
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DefaultMemberAttribute : Attribute
{
// The name of the member
private String m_memberName;
// You must provide the name of the member, this is required
public DefaultMemberAttribute(String memberName) {
m_memberName = memberName;
}
// A get accessor to return the name from the attribute.
// NOTE: There is no setter because the name must be provided
// to the constructor. The name is not optional.
public String MemberName {
get {return m_memberName;}
}
}
}

View File

@@ -0,0 +1,224 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Runtime.InteropServices;
using System.Security;
namespace System.Reflection.Emit
{
// TypeNameBuilder is NOT thread safe NOR reliable
internal class TypeNameBuilder
{
internal enum Format
{
ToString,
FullName,
AssemblyQualifiedName,
}
#region QCalls
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern IntPtr CreateTypeNameBuilder();
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void ReleaseTypeNameBuilder(IntPtr pAQN);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void OpenGenericArguments(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void CloseGenericArguments(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void OpenGenericArgument(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void CloseGenericArgument(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddName(IntPtr tnb, string name);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddPointer(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddByRef(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddSzArray(IntPtr tnb);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddArray(IntPtr tnb, int rank);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void AddAssemblySpec(IntPtr tnb, string assemblySpec);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void ToString(IntPtr tnb, StringHandleOnStack retString);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void Clear(IntPtr tnb);
#endregion
#region Static Members
// TypeNameBuilder is NOT thread safe NOR reliable
[System.Security.SecuritySafeCritical] // auto-generated
internal static string ToString(Type type, Format format)
{
if (format == Format.FullName || format == Format.AssemblyQualifiedName)
{
if (!type.IsGenericTypeDefinition && type.ContainsGenericParameters)
return null;
}
TypeNameBuilder tnb = new TypeNameBuilder(CreateTypeNameBuilder());
tnb.Clear();
tnb.ConstructAssemblyQualifiedNameWorker(type, format);
string toString = tnb.ToString();
tnb.Dispose();
return toString;
}
#endregion
#region Private Data Members
private IntPtr m_typeNameBuilder;
#endregion
#region Constructor
private TypeNameBuilder(IntPtr typeNameBuilder) { m_typeNameBuilder = typeNameBuilder; }
[System.Security.SecurityCritical] // auto-generated
internal void Dispose() { ReleaseTypeNameBuilder(m_typeNameBuilder); }
#endregion
#region private Members
[System.Security.SecurityCritical] // auto-generated
private void AddElementType(Type elementType)
{
if (elementType.HasElementType)
AddElementType(elementType.GetElementType());
if (elementType.IsPointer)
AddPointer();
else if (elementType.IsByRef)
AddByRef();
else if (elementType.IsSzArray)
AddSzArray();
else if (elementType.IsArray)
AddArray(elementType.GetArrayRank());
}
[System.Security.SecurityCritical] // auto-generated
private void ConstructAssemblyQualifiedNameWorker(Type type, Format format)
{
Type rootType = type;
while (rootType.HasElementType)
rootType = rootType.GetElementType();
// Append namespace + nesting + name
List<Type> nestings = new List<Type>();
for (Type t = rootType; t != null; t = t.IsGenericParameter ? null : t.DeclaringType)
nestings.Add(t);
for (int i = nestings.Count - 1; i >= 0; i--)
{
Type enclosingType = nestings[i];
string name = enclosingType.Name;
if (i == nestings.Count - 1 && enclosingType.Namespace != null && enclosingType.Namespace.Length != 0)
name = enclosingType.Namespace + "." + name;
AddName(name);
}
// Append generic arguments
if (rootType.IsGenericType && (!rootType.IsGenericTypeDefinition || format == Format.ToString))
{
Type[] genericArguments = rootType.GetGenericArguments();
OpenGenericArguments();
for (int i = 0; i < genericArguments.Length; i++)
{
Format genericArgumentsFormat = format == Format.FullName ? Format.AssemblyQualifiedName : format;
OpenGenericArgument();
ConstructAssemblyQualifiedNameWorker(genericArguments[i], genericArgumentsFormat);
CloseGenericArgument();
}
CloseGenericArguments();
}
// Append pointer, byRef and array qualifiers
AddElementType(type);
if (format == Format.AssemblyQualifiedName)
AddAssemblySpec(type.Module.Assembly.FullName);
}
[System.Security.SecurityCritical] // auto-generated
private void OpenGenericArguments() { OpenGenericArguments(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void CloseGenericArguments() { CloseGenericArguments(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void OpenGenericArgument() { OpenGenericArgument(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void CloseGenericArgument() { CloseGenericArgument(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void AddName(string name) { AddName(m_typeNameBuilder, name); }
[System.Security.SecurityCritical] // auto-generated
private void AddPointer() { AddPointer(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void AddByRef() { AddByRef(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void AddSzArray() { AddSzArray(m_typeNameBuilder); }
[System.Security.SecurityCritical] // auto-generated
private void AddArray(int rank) { AddArray(m_typeNameBuilder, rank); }
[System.Security.SecurityCritical] // auto-generated
private void AddAssemblySpec(string assemblySpec) { AddAssemblySpec(m_typeNameBuilder, assemblySpec); }
[System.Security.SecuritySafeCritical] // auto-generated
public override string ToString() { string ret = null; ToString(m_typeNameBuilder, JitHelpers.GetStringHandleOnStack(ref ret)); return ret; }
[System.Security.SecurityCritical] // auto-generated
private void Clear() { Clear(m_typeNameBuilder); }
#endregion
}
}

View File

@@ -0,0 +1 @@
371ef4aaa659cd8880046348782cbfe41a11b15c

Some files were not shown because too many files have changed in this diff Show More