private static void CreateAndAddCharSetFieldArgument(MethodDefinition method, CustomAttribute dllImportAttr)
        {
            System.Runtime.InteropServices.CharSet charSet = System.Runtime.InteropServices.CharSet.None;
            if (method.PInvokeInfo.IsCharSetAnsi)
            {
                charSet = System.Runtime.InteropServices.CharSet.Ansi;
            }
            if (method.PInvokeInfo.IsCharSetUnicode)
            {
                charSet = System.Runtime.InteropServices.CharSet.Unicode;
            }
            if (method.PInvokeInfo.IsCharSetAuto)
            {
                charSet = System.Runtime.InteropServices.CharSet.Auto;
            }

            TypeReference charSetArgumentType = Utilities.GetCorlibTypeReference(typeof(System.Runtime.InteropServices.CharSet), method.DeclaringType.Module);
            //Casted to int, so that it can be resolved to enum member by EnumValueToFieldCombinationMatcher.GetEnumFieldDefinitionByValue
            //invokd in WeiteAttributeNamedArgs
            CustomAttributeArgument      charSetArgument      = new CustomAttributeArgument(charSetArgumentType, (int)(charSet));
            CustomAttributeNamedArgument namedCharSetArgument = new CustomAttributeNamedArgument("CharSet", charSetArgument);

            dllImportAttr.Fields.Add(namedCharSetArgument);
        }
Ejemplo n.º 2
0
 public System.Reflection.Emit.MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] returnTypeRequiredCustomModifiers, System.Type[] returnTypeOptionalCustomModifiers, System.Type[] parameterTypes, System.Type[][] parameterTypeRequiredCustomModifiers, System.Type[][] parameterTypeOptionalCustomModifiers, System.Runtime.InteropServices.CallingConvention nativeCallConv, System.Runtime.InteropServices.CharSet nativeCharSet)
 {
     throw new PlatformNotSupportedException();
 }