You've already forked linux-packaging-mono
Imported Upstream version 5.20.0.180
Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
parent
0e2d47d1c8
commit
0510252385
@ -33,6 +33,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using InteropServicesCallingConvention = System.Runtime.InteropServices.CallingConvention;
|
||||
using System.Runtime.Serialization;
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using System.Reflection.Emit;
|
||||
@ -106,9 +107,9 @@ namespace System.Reflection {
|
||||
|
||||
static internal ParameterInfo GetReturnParameterInfo (MonoMethod method)
|
||||
{
|
||||
return ParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
|
||||
return MonoParameterInfo.New (GetReturnType (method.mhandle), method, get_retval_marshal (method.mhandle));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
abstract class RuntimeMethodInfo : MethodInfo, ISerializable
|
||||
{
|
||||
@ -143,7 +144,7 @@ namespace System.Reflection {
|
||||
sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, format));
|
||||
|
||||
sbName.Append("(");
|
||||
ParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
|
||||
MonoParameterInfo.FormatParameters (sbName, GetParametersNoCopy (), CallingConvention, serialization);
|
||||
sbName.Append(")");
|
||||
|
||||
return sbName.ToString();
|
||||
@ -220,6 +221,9 @@ namespace System.Reflection {
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal static extern MonoMethod get_base_method (MonoMethod method, bool definition);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal static extern int get_metadata_token (MonoMethod method);
|
||||
|
||||
public override MethodInfo GetBaseDefinition ()
|
||||
{
|
||||
return get_base_method (this, true);
|
||||
@ -246,6 +250,12 @@ namespace System.Reflection {
|
||||
return MonoMethodInfo.GetReturnParameterInfo (this);
|
||||
}
|
||||
}
|
||||
|
||||
public override int MetadataToken {
|
||||
get {
|
||||
return get_metadata_token (this);
|
||||
}
|
||||
}
|
||||
|
||||
public override MethodImplAttributes GetMethodImplementationFlags ()
|
||||
{
|
||||
@ -287,6 +297,15 @@ namespace System.Reflection {
|
||||
[DebuggerStepThrough]
|
||||
public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
|
||||
{
|
||||
if (!IsStatic) {
|
||||
if (!DeclaringType.IsInstanceOfType (obj)) {
|
||||
if (obj == null)
|
||||
throw new TargetException ("Non-static method requires a target.");
|
||||
else
|
||||
throw new TargetException ("Object does not match target type.");
|
||||
}
|
||||
}
|
||||
|
||||
if (binder == null)
|
||||
binder = Type.DefaultBinder;
|
||||
|
||||
@ -309,6 +328,8 @@ namespace System.Reflection {
|
||||
} catch (MethodAccessException) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (OverflowException) {
|
||||
throw;
|
||||
} catch (Exception e) {
|
||||
throw new TargetInvocationException (e);
|
||||
}
|
||||
@ -446,18 +467,96 @@ namespace System.Reflection {
|
||||
|
||||
if ((info.iattrs & MethodImplAttributes.PreserveSig) != 0)
|
||||
attrsData [count++] = new CustomAttributeData ((typeof (PreserveSigAttribute)).GetConstructor (Type.EmptyTypes));
|
||||
if ((info.attrs & MethodAttributes.PinvokeImpl) != 0) {
|
||||
this.GetPInvoke (out PInvokeAttributes flags, out string entryPoint, out string dllName);
|
||||
var ctorArgs = new CustomAttributeTypedArgument[] { new CustomAttributeTypedArgument(typeof(string), dllName) };
|
||||
attrsData [count++] = new CustomAttributeData (
|
||||
(typeof (FieldOffsetAttribute)).GetConstructor (new[] { typeof (string) }),
|
||||
ctorArgs,
|
||||
EmptyArray<CustomAttributeNamedArgument>.Value); //FIXME Get named params
|
||||
}
|
||||
if ((info.attrs & MethodAttributes.PinvokeImpl) != 0)
|
||||
attrsData [count++] = GetDllImportAttributeData ();
|
||||
|
||||
return attrsData;
|
||||
}
|
||||
|
||||
private CustomAttributeData GetDllImportAttributeData ()
|
||||
{
|
||||
if ((Attributes & MethodAttributes.PinvokeImpl) == 0)
|
||||
return null;
|
||||
|
||||
string entryPoint, dllName = null;
|
||||
PInvokeAttributes flags = 0;
|
||||
|
||||
GetPInvoke (out flags, out entryPoint, out dllName);
|
||||
|
||||
CharSet charSet;
|
||||
|
||||
switch (flags & PInvokeAttributes.CharSetMask) {
|
||||
case PInvokeAttributes.CharSetNotSpec:
|
||||
charSet = CharSet.None;
|
||||
break;
|
||||
case PInvokeAttributes.CharSetAnsi:
|
||||
charSet = CharSet.Ansi;
|
||||
break;
|
||||
case PInvokeAttributes.CharSetUnicode:
|
||||
charSet = CharSet.Unicode;
|
||||
break;
|
||||
case PInvokeAttributes.CharSetAuto:
|
||||
charSet = CharSet.Auto;
|
||||
break;
|
||||
// Invalid: default to CharSet.None
|
||||
default:
|
||||
charSet = CharSet.None;
|
||||
break;
|
||||
}
|
||||
|
||||
InteropServicesCallingConvention callingConvention;
|
||||
|
||||
switch (flags & PInvokeAttributes.CallConvMask) {
|
||||
case PInvokeAttributes.CallConvWinapi:
|
||||
callingConvention = InteropServicesCallingConvention.Winapi;
|
||||
break;
|
||||
case PInvokeAttributes.CallConvCdecl:
|
||||
callingConvention = InteropServicesCallingConvention.Cdecl;
|
||||
break;
|
||||
case PInvokeAttributes.CallConvStdcall:
|
||||
callingConvention = InteropServicesCallingConvention.StdCall;
|
||||
break;
|
||||
case PInvokeAttributes.CallConvThiscall:
|
||||
callingConvention = InteropServicesCallingConvention.ThisCall;
|
||||
break;
|
||||
case PInvokeAttributes.CallConvFastcall:
|
||||
callingConvention = InteropServicesCallingConvention.FastCall;
|
||||
break;
|
||||
// Invalid: default to CallingConvention.Cdecl
|
||||
default:
|
||||
callingConvention = InteropServicesCallingConvention.Cdecl;
|
||||
break;
|
||||
}
|
||||
|
||||
bool exactSpelling = (flags & PInvokeAttributes.NoMangle) != 0;
|
||||
bool setLastError = (flags & PInvokeAttributes.SupportsLastError) != 0;
|
||||
bool bestFitMapping = (flags & PInvokeAttributes.BestFitMask) == PInvokeAttributes.BestFitEnabled;
|
||||
bool throwOnUnmappableChar = (flags & PInvokeAttributes.ThrowOnUnmappableCharMask) == PInvokeAttributes.ThrowOnUnmappableCharEnabled;
|
||||
bool preserveSig = (GetMethodImplementationFlags () & MethodImplAttributes.PreserveSig) != 0;
|
||||
|
||||
var ctorArgs = new CustomAttributeTypedArgument [] {
|
||||
new CustomAttributeTypedArgument (typeof (string), dllName),
|
||||
};
|
||||
|
||||
var attrType = typeof (DllImportAttribute);
|
||||
|
||||
var namedArgs = new CustomAttributeNamedArgument [] {
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("EntryPoint"), entryPoint),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("CharSet"), charSet),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("ExactSpelling"), exactSpelling),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("SetLastError"), setLastError),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("PreserveSig"), preserveSig),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("CallingConvention"), callingConvention),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("BestFitMapping"), bestFitMapping),
|
||||
new CustomAttributeNamedArgument (attrType.GetField ("ThrowOnUnmappableChar"), throwOnUnmappableChar)
|
||||
};
|
||||
|
||||
return new CustomAttributeData (
|
||||
attrType.GetConstructor (new[] { typeof (string) }),
|
||||
ctorArgs,
|
||||
namedArgs);
|
||||
}
|
||||
|
||||
public override MethodInfo MakeGenericMethod (Type [] methodInstantiation)
|
||||
{
|
||||
if (methodInstantiation == null)
|
||||
@ -560,6 +659,8 @@ namespace System.Reflection {
|
||||
public override bool IsSecuritySafeCritical {
|
||||
get { return get_core_clr_security_level () == 1; }
|
||||
}
|
||||
|
||||
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoMethod> (other);
|
||||
}
|
||||
|
||||
|
||||
@ -700,6 +801,8 @@ namespace System.Reflection {
|
||||
} catch (MethodAccessException) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (OverflowException) {
|
||||
throw;
|
||||
} catch (Exception e) {
|
||||
throw new TargetInvocationException (e);
|
||||
}
|
||||
@ -809,6 +912,8 @@ namespace System.Reflection {
|
||||
public extern int get_core_clr_security_level ();
|
||||
#endif
|
||||
|
||||
public sealed override bool HasSameMetadataDefinitionAs (MemberInfo other) => HasSameMetadataDefinitionAsCore<MonoCMethod> (other);
|
||||
|
||||
public override bool IsSecurityTransparent {
|
||||
get { return get_core_clr_security_level () == 0; }
|
||||
}
|
||||
@ -820,5 +925,14 @@ namespace System.Reflection {
|
||||
public override bool IsSecuritySafeCritical {
|
||||
get { return get_core_clr_security_level () == 1; }
|
||||
}
|
||||
|
||||
public override int MetadataToken {
|
||||
get {
|
||||
return get_metadata_token (this);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal static extern int get_metadata_token (MonoCMethod method);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user