public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return Forwarder.__TryGetFieldMarshal(out fieldMarshal); }
internal static bool ReadFieldMarshal(Module module, int token, out FieldMarshal fm) { fm = new FieldMarshal(); foreach (int i in module.FieldMarshal.Filter(token)) { ByteReader blob = module.GetBlob(module.FieldMarshal.records[i].NativeType); fm.UnmanagedType = (UnmanagedType)blob.ReadCompressedUInt(); if (fm.UnmanagedType == UnmanagedType.LPArray) { fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt(); if (fm.ArraySubType == NATIVE_TYPE_MAX) { fm.ArraySubType = null; } if (blob.Length != 0) { fm.SizeParamIndex = (short)blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.SizeConst = blob.ReadCompressedUInt(); if (blob.Length != 0 && blob.ReadCompressedUInt() == 0) { fm.SizeParamIndex = null; } } } } else if (fm.UnmanagedType == UnmanagedType.SafeArray) { if (blob.Length != 0) { fm.SafeArraySubType = (VarEnum)blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.SafeArrayUserDefinedSubType = ReadType(module, blob); } } } else if (fm.UnmanagedType == UnmanagedType.ByValArray) { fm.SizeConst = blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt(); } } else if (fm.UnmanagedType == UnmanagedType.ByValTStr) { fm.SizeConst = blob.ReadCompressedUInt(); } else if (fm.UnmanagedType == UnmanagedType.Interface || fm.UnmanagedType == UnmanagedType.IDispatch || fm.UnmanagedType == UnmanagedType.IUnknown) { if (blob.Length != 0) { fm.IidParameterIndex = blob.ReadCompressedUInt(); } } else if (fm.UnmanagedType == UnmanagedType.CustomMarshaler) { blob.ReadCompressedUInt(); blob.ReadCompressedUInt(); fm.MarshalType = ReadString(blob); fm.MarshalCookie = ReadString(blob); TypeNameParser parser = TypeNameParser.Parse(fm.MarshalType, false); if (!parser.Error) { fm.MarshalTypeRef = parser.GetType(module.universe, module, false, fm.MarshalType, false, false); } } return true; } return false; }
internal static CustomAttributeData CreateMarshalAsPseudoCustomAttribute(Module module, FieldMarshal fm) { Type typeofMarshalAs = module.universe.System_Runtime_InteropServices_MarshalAsAttribute; Type typeofUnmanagedType = module.universe.System_Runtime_InteropServices_UnmanagedType; Type typeofVarEnum = module.universe.System_Runtime_InteropServices_VarEnum; Type typeofType = module.universe.System_Type; List<CustomAttributeNamedArgument> named = new List<CustomAttributeNamedArgument>(); AddNamedArgument(named, typeofMarshalAs, "ArraySubType", typeofUnmanagedType, (int)(fm.ArraySubType ?? 0)); AddNamedArgument(named, typeofMarshalAs, "SizeParamIndex", module.universe.System_Int16, fm.SizeParamIndex ?? 0); AddNamedArgument(named, typeofMarshalAs, "SizeConst", module.universe.System_Int32, fm.SizeConst ?? 0); AddNamedArgument(named, typeofMarshalAs, "IidParameterIndex", module.universe.System_Int32, fm.IidParameterIndex ?? 0); AddNamedArgument(named, typeofMarshalAs, "SafeArraySubType", typeofVarEnum, (int)(fm.SafeArraySubType ?? 0)); if (fm.SafeArrayUserDefinedSubType != null) { AddNamedArgument(named, typeofMarshalAs, "SafeArrayUserDefinedSubType", typeofType, fm.SafeArrayUserDefinedSubType); } if (fm.MarshalType != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalType", module.universe.System_String, fm.MarshalType); } if (fm.MarshalTypeRef != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalTypeRef", module.universe.System_Type, fm.MarshalTypeRef); } if (fm.MarshalCookie != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalCookie", module.universe.System_String, fm.MarshalCookie); } ConstructorInfo constructor = typeofMarshalAs.GetPseudoCustomAttributeConstructor(typeofUnmanagedType); return new CustomAttributeData(module, constructor, new object[] { (int)fm.UnmanagedType }, named); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return parameterInfo.__TryGetFieldMarshal(out fieldMarshal); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return(Forwarder.__TryGetFieldMarshal(out fieldMarshal)); }
public bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return FieldMarshal.ReadFieldMarshal(this.Module, GetCurrentToken(), out fieldMarshal); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { fieldMarshal = new FieldMarshal(); return false; }
internal static bool ReadFieldMarshal(Module module, int token, out FieldMarshal fm) { fm = new FieldMarshal(); foreach (int i in module.FieldMarshal.Filter(token)) { ByteReader blob = module.GetBlob(module.FieldMarshal.records[i].NativeType); fm.UnmanagedType = (UnmanagedType)blob.ReadCompressedUInt(); if (fm.UnmanagedType == UnmanagedType.LPArray) { fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt(); if (fm.ArraySubType == NATIVE_TYPE_MAX) { fm.ArraySubType = null; } if (blob.Length != 0) { fm.SizeParamIndex = (short)blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.SizeConst = blob.ReadCompressedUInt(); if (blob.Length != 0 && blob.ReadCompressedUInt() == 0) { fm.SizeParamIndex = null; } } } } else if (fm.UnmanagedType == UnmanagedType.SafeArray) { if (blob.Length != 0) { fm.SafeArraySubType = (VarEnum)blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.SafeArrayUserDefinedSubType = ReadType(module, blob); } } } else if (fm.UnmanagedType == UnmanagedType.ByValArray) { fm.SizeConst = blob.ReadCompressedUInt(); if (blob.Length != 0) { fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt(); } } else if (fm.UnmanagedType == UnmanagedType.ByValTStr) { fm.SizeConst = blob.ReadCompressedUInt(); } else if (fm.UnmanagedType == UnmanagedType.Interface || fm.UnmanagedType == UnmanagedType.IDispatch || fm.UnmanagedType == UnmanagedType.IUnknown) { if (blob.Length != 0) { fm.IidParameterIndex = blob.ReadCompressedUInt(); } } else if (fm.UnmanagedType == UnmanagedType.CustomMarshaler) { blob.ReadCompressedUInt(); blob.ReadCompressedUInt(); fm.MarshalType = ReadString(blob); fm.MarshalCookie = ReadString(blob); TypeNameParser parser = TypeNameParser.Parse(fm.MarshalType, false); if (!parser.Error) { fm.MarshalTypeRef = parser.GetType(module.universe, module.Assembly, false, fm.MarshalType, false, false); } } return(true); } return(false); }
public abstract bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal);
IUnresolvedAttribute ConvertMarshalInfo(FieldMarshal marshalInfo) { DefaultUnresolvedAttribute attr = new DefaultUnresolvedAttribute(marshalAsAttributeTypeRef, new[] { unmanagedTypeTypeRef }); attr.PositionalArguments.Add(CreateSimpleConstantValue(unmanagedTypeTypeRef, (int)marshalInfo.UnmanagedType)); if (marshalInfo.UnmanagedType ==UnmanagedType.ByValArray) { attr.AddNamedFieldArgument("SizeConst", CreateSimpleConstantValue(KnownTypeReference.Int32, (int)marshalInfo.SizeConst)); if (marshalInfo.ArraySubType.HasValue) attr.AddNamedFieldArgument("ArraySubType", CreateSimpleConstantValue(unmanagedTypeTypeRef, (int)marshalInfo.ArraySubType.Value)); } if (marshalInfo.UnmanagedType ==UnmanagedType.SafeArray) { attr.AddNamedFieldArgument("SafeArraySubType", CreateSimpleConstantValue(typeof(VarEnum).ToTypeReference(), (int)marshalInfo.SafeArraySubType)); } if (marshalInfo.UnmanagedType == UnmanagedType.LPArray) { if (marshalInfo.ArraySubType != null) attr.AddNamedFieldArgument("ArraySubType", CreateSimpleConstantValue(unmanagedTypeTypeRef, (int)marshalInfo.ArraySubType)); if (marshalInfo.SizeConst >= 0) attr.AddNamedFieldArgument("SizeConst", CreateSimpleConstantValue(KnownTypeReference.Int32, (int)marshalInfo.SizeConst)); if (marshalInfo.SizeParamIndex >= 0) attr.AddNamedFieldArgument("SizeParamIndex", CreateSimpleConstantValue(KnownTypeReference.Int16, (short)marshalInfo.SizeParamIndex)); } if (marshalInfo.UnmanagedType == UnmanagedType.CustomMarshaler) { attr.AddNamedFieldArgument("MarshalType", CreateSimpleConstantValue(KnownTypeReference.String, marshalInfo.MarshalTypeRef.FullName)); if (!string.IsNullOrEmpty(marshalInfo.MarshalCookie)) attr.AddNamedFieldArgument("MarshalCookie", CreateSimpleConstantValue(KnownTypeReference.String, marshalInfo.MarshalCookie)); } if (marshalInfo.UnmanagedType == UnmanagedType.ByValTStr) { attr.AddNamedFieldArgument("SizeConst", CreateSimpleConstantValue(KnownTypeReference.Int32, (int)marshalInfo.SizeConst)); } return InterningProvider.Intern(attr); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { fieldMarshal = new FieldMarshal(); return(false); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return(parameterInfo.__TryGetFieldMarshal(out fieldMarshal)); }
internal static CustomAttributeData CreateMarshalAsPseudoCustomAttribute(Module module, FieldMarshal fm) { Type typeofMarshalAs = module.universe.System_Runtime_InteropServices_MarshalAsAttribute; Type typeofUnmanagedType = module.universe.System_Runtime_InteropServices_UnmanagedType; Type typeofVarEnum = module.universe.System_Runtime_InteropServices_VarEnum; Type typeofType = module.universe.System_Type; List <CustomAttributeNamedArgument> named = new List <CustomAttributeNamedArgument>(); AddNamedArgument(named, typeofMarshalAs, "ArraySubType", typeofUnmanagedType, (int)(fm.ArraySubType ?? 0)); AddNamedArgument(named, typeofMarshalAs, "SizeParamIndex", module.universe.System_Int16, fm.SizeParamIndex ?? 0); AddNamedArgument(named, typeofMarshalAs, "SizeConst", module.universe.System_Int32, fm.SizeConst ?? 0); AddNamedArgument(named, typeofMarshalAs, "IidParameterIndex", module.universe.System_Int32, fm.IidParameterIndex ?? 0); AddNamedArgument(named, typeofMarshalAs, "SafeArraySubType", typeofVarEnum, (int)(fm.SafeArraySubType ?? 0)); if (fm.SafeArrayUserDefinedSubType != null) { AddNamedArgument(named, typeofMarshalAs, "SafeArrayUserDefinedSubType", typeofType, fm.SafeArrayUserDefinedSubType); } if (fm.MarshalType != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalType", module.universe.System_String, fm.MarshalType); } if (fm.MarshalTypeRef != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalTypeRef", module.universe.System_Type, fm.MarshalTypeRef); } if (fm.MarshalCookie != null) { AddNamedArgument(named, typeofMarshalAs, "MarshalCookie", module.universe.System_String, fm.MarshalCookie); } ConstructorInfo constructor = typeofMarshalAs.GetPseudoCustomAttributeConstructor(typeofUnmanagedType); return(new CustomAttributeData(module, constructor, new object[] { (int)fm.UnmanagedType }, named)); }
public bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return(FieldMarshal.ReadFieldMarshal(this.Module, GetCurrentToken(), out fieldMarshal)); }