You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -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
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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);
|
||||
return type.GetProperties(everything);
|
||||
}
|
||||
public static IEnumerable<EventInfo> GetRuntimeEvents(this Type type)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetEvents(everything);
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetRuntimeMethods(this Type type)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetMethods(everything);
|
||||
}
|
||||
|
||||
public static IEnumerable<FieldInfo> GetRuntimeFields(this Type type)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetFields(everything);
|
||||
}
|
||||
|
||||
public static PropertyInfo GetRuntimeProperty(this Type type, string name)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetProperty(name);
|
||||
}
|
||||
public static EventInfo GetRuntimeEvent(this Type type, string name)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetEvent(name);
|
||||
}
|
||||
public static MethodInfo GetRuntimeMethod(this Type type, string name, Type[] parameters)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetMethod(name, parameters);
|
||||
}
|
||||
public static FieldInfo GetRuntimeField(this Type type, string name)
|
||||
{
|
||||
CheckAndThrow(type);
|
||||
return type.GetField(name);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
24bd73651248dc996e096016e27acb8cbb302ef1
|
||||
@@ -0,0 +1,408 @@
|
||||
// ==++==
|
||||
//
|
||||
// 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;}
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_STRONGNAME_MIGRATION
|
||||
[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
|
||||
|
||||
[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; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
/*============================================================
|
||||
**
|
||||
** File: AssemblyNameFlags
|
||||
**
|
||||
** <OWNER>mray</OWNER>
|
||||
** <OWNER>WESU</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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// <OWNER>WESU</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
|
||||
}
|
||||
}
|
||||
@@ -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>WESU</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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CallingConventions is a set of Bits representing the calling conventions
|
||||
//
|
||||
// <OWNER>WESU</OWNER>
|
||||
// in the system.
|
||||
//
|
||||
// <EMAIL>Author: meichint</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
@@ -0,0 +1 @@
|
||||
4dfeb2679fd95961ba9b42be3c6a068dda69bcfe
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
22161806123ada0dd48dfd47d27ddbc42c2354eb
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user