internal DllImportData(string moduleName, string entryPointName, Cci.PInvokeAttributes flags) { this.moduleName = moduleName; this.entryPointName = entryPointName; this.flags = flags; }
internal static Cci.PInvokeAttributes MakeFlags(bool noMangle, CharSet charSet, bool setLastError, CallingConvention callingConvention, bool?useBestFit, bool?throwOnUnmappable) { Cci.PInvokeAttributes result = 0; if (noMangle) { result |= Cci.PInvokeAttributes.NoMangle; } switch (charSet) { default: // Dev10: use default without reporting an error case Cci.Constants.CharSet_None: break; case CharSet.Ansi: result |= Cci.PInvokeAttributes.CharSetAnsi; break; case CharSet.Unicode: result |= Cci.PInvokeAttributes.CharSetUnicode; break; case Cci.Constants.CharSet_Auto: result |= Cci.PInvokeAttributes.CharSetAuto; break; } if (setLastError) { result |= Cci.PInvokeAttributes.SupportsLastError; } switch (callingConvention) { default: // Dev10: uses default without reporting an error case CallingConvention.Winapi: result |= Cci.PInvokeAttributes.CallConvWinapi; break; case CallingConvention.Cdecl: result |= Cci.PInvokeAttributes.CallConvCdecl; break; case CallingConvention.StdCall: result |= Cci.PInvokeAttributes.CallConvStdcall; break; case CallingConvention.ThisCall: result |= Cci.PInvokeAttributes.CallConvThiscall; break; case Cci.Constants.CallingConvention_FastCall: result |= Cci.PInvokeAttributes.CallConvFastcall; break; } if (throwOnUnmappable.HasValue) { if (throwOnUnmappable.Value) { result |= Cci.PInvokeAttributes.ThrowOnUnmappableCharEnabled; } else { result |= Cci.PInvokeAttributes.ThrowOnUnmappableCharDisabled; } } if (useBestFit.HasValue) { if (useBestFit.Value) { result |= Cci.PInvokeAttributes.BestFitEnabled; } else { result |= Cci.PInvokeAttributes.BestFitDisabled; } } return(result); }
// used by DllImportAttribute public void SetDllImport(int attributeIndex, string moduleName, string entryPointName, Cci.PInvokeAttributes flags, bool preserveSig) { VerifySealed(expected: false); Debug.Assert(attributeIndex >= 0); platformInvokeInfo = new DllImportData(moduleName, entryPointName, flags); this.dllImportIndex = attributeIndex; this.dllImportPreserveSig = preserveSig; SetDataStored(); }