You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
@ -46,6 +46,11 @@ namespace System.Reflection.Emit {
|
||||
public class CustomAttributeBuilder : _CustomAttributeBuilder {
|
||||
ConstructorInfo ctor;
|
||||
byte[] data;
|
||||
object [] args;
|
||||
PropertyInfo [] namedProperties;
|
||||
object [] propertyValues;
|
||||
FieldInfo [] namedFields;
|
||||
object [] fieldValues;
|
||||
|
||||
internal ConstructorInfo Ctor {
|
||||
get {return ctor;}
|
||||
@ -57,7 +62,20 @@ namespace System.Reflection.Emit {
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern byte[] GetBlob(Assembly asmb, ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues);
|
||||
|
||||
|
||||
internal object Invoke ()
|
||||
{
|
||||
object result = ctor.Invoke (args);
|
||||
|
||||
for (int i=0; i < namedFields.Length; i++)
|
||||
namedFields [i].SetValue (result, fieldValues [i]);
|
||||
|
||||
for (int i=0; i < namedProperties.Length; i++)
|
||||
namedProperties [i].SetValue (result, propertyValues [i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal CustomAttributeBuilder( ConstructorInfo con, byte[] binaryAttribute) {
|
||||
if (con == null)
|
||||
throw new ArgumentNullException ("con");
|
||||
@ -140,6 +158,12 @@ namespace System.Reflection.Emit {
|
||||
FieldInfo [] namedFields, object [] fieldValues)
|
||||
{
|
||||
ctor = con;
|
||||
args = constructorArgs;
|
||||
this.namedProperties = namedProperties;
|
||||
this.propertyValues = propertyValues;
|
||||
this.namedFields = namedFields;
|
||||
this.fieldValues = fieldValues;
|
||||
|
||||
if (con == null)
|
||||
throw new ArgumentNullException ("con");
|
||||
if (constructorArgs == null)
|
||||
|
@ -1169,32 +1169,55 @@ namespace System.Reflection.Emit {
|
||||
|
||||
public override object[] GetCustomAttributes (bool inherit)
|
||||
{
|
||||
return base.GetCustomAttributes (inherit);
|
||||
return GetCustomAttributes (null, inherit);
|
||||
}
|
||||
|
||||
public override object[] GetCustomAttributes (Type attributeType, bool inherit)
|
||||
{
|
||||
return base.GetCustomAttributes (attributeType, inherit);
|
||||
if (cattrs == null || cattrs.Length == 0)
|
||||
return Array.Empty<object> ();
|
||||
|
||||
if (attributeType is TypeBuilder)
|
||||
throw new InvalidOperationException ("First argument to GetCustomAttributes can't be a TypeBuilder");
|
||||
|
||||
List<object> results = new List<object> ();
|
||||
for (int i=0; i < cattrs.Length; i++) {
|
||||
Type t = cattrs [i].Ctor.GetType ();
|
||||
|
||||
if (t is TypeBuilder)
|
||||
throw new InvalidOperationException ("Can't construct custom attribute for TypeBuilder type");
|
||||
|
||||
if (attributeType == null || attributeType.IsAssignableFrom (t))
|
||||
results.Add (cattrs [i].Invoke ());
|
||||
}
|
||||
|
||||
return results.ToArray ();
|
||||
}
|
||||
|
||||
public override FieldInfo GetField (string name, BindingFlags bindingAttr)
|
||||
{
|
||||
return base.GetField (name, bindingAttr);
|
||||
if (global_type_created == null)
|
||||
throw new InvalidOperationException ("Module-level fields cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
|
||||
return global_type_created.GetField (name, bindingAttr);
|
||||
}
|
||||
|
||||
public override FieldInfo[] GetFields (BindingFlags bindingFlags)
|
||||
{
|
||||
return base.GetFields (bindingFlags);
|
||||
if (global_type_created == null)
|
||||
throw new InvalidOperationException ("Module-level fields cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
|
||||
return global_type_created.GetFields (bindingFlags);
|
||||
}
|
||||
|
||||
public override MethodInfo[] GetMethods (BindingFlags bindingFlags)
|
||||
{
|
||||
return base.GetMethods (bindingFlags);
|
||||
if (global_type_created == null)
|
||||
throw new InvalidOperationException ("Module-level methods cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
|
||||
return global_type_created.GetMethods (bindingFlags);
|
||||
}
|
||||
|
||||
public override int MetadataToken {
|
||||
get {
|
||||
return base.MetadataToken;
|
||||
return get_MetadataToken (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user