141 references to MethodImportAttributes
ILAssembler (21)
EntityRegistry.cs (1)
1308
public (ModuleReferenceEntity ModuleName, string? EntryPointName,
MethodImportAttributes
Attributes)? MethodImportInformation { get; set; }
GrammarVisitor.cs (20)
3911
(EntityRegistry.ModuleReferenceEntity Module, string? EntryPoint,
MethodImportAttributes
Attributes)? pInvokeInformation = null;
4458
public GrammarResult.Flag<
MethodImportAttributes
> VisitPinvAttr(CILParser.PinvAttrContext context)
4462
return new((
MethodImportAttributes
)VisitInt32(int32).Value, ShouldAppend: false);
4467
return new(
MethodImportAttributes
.ExactSpelling);
4469
return new(
MethodImportAttributes
.CharSetAnsi);
4471
return new(
MethodImportAttributes
.CharSetUnicode);
4473
return new(
MethodImportAttributes
.CharSetAuto);
4475
return new(
MethodImportAttributes
.SetLastError);
4477
return new(
MethodImportAttributes
.CallingConventionWinApi);
4479
return new(
MethodImportAttributes
.CallingConventionCDecl);
4481
return new(
MethodImportAttributes
.CallingConventionStdCall);
4483
return new(
MethodImportAttributes
.CallingConventionThisCall);
4485
return new(
MethodImportAttributes
.CallingConventionFastCall);
4487
return new(
MethodImportAttributes
.BestFitMappingEnable);
4489
return new(
MethodImportAttributes
.BestFitMappingDisable);
4491
return new(
MethodImportAttributes
.ThrowOnUnmappableCharEnable);
4493
return new(
MethodImportAttributes
.ThrowOnUnmappableCharDisable);
4500
public GrammarResult.Literal<(string? ModuleName, string? EntryPointName,
MethodImportAttributes
Attributes)> VisitPinvImpl(CILParser.PinvImplContext context)
4502
MethodImportAttributes
attrs =
MethodImportAttributes
.None;
ILCompiler.TypeSystem (24)
src\runtime\src\coreclr\tools\Common\TypeSystem\Ecma\EcmaMethod.cs (24)
478
MethodImportAttributes
importAttributes = import.Attributes;
482
if ((importAttributes &
MethodImportAttributes
.BestFitMappingMask) == 0 ||
483
(importAttributes &
MethodImportAttributes
.ThrowOnUnmappableCharMask) == 0)
488
MethodImportAttributes
fromCA = GetImportAttributesFromBestFitMappingAttribute(declaringType.GetCustomAttributes());
489
if ((importAttributes &
MethodImportAttributes
.BestFitMappingMask) == 0)
490
importAttributes |= fromCA &
MethodImportAttributes
.BestFitMappingMask;
491
if ((importAttributes &
MethodImportAttributes
.ThrowOnUnmappableCharMask) == 0)
492
importAttributes |= fromCA &
MethodImportAttributes
.ThrowOnUnmappableCharMask;
495
if ((importAttributes &
MethodImportAttributes
.BestFitMappingMask) == 0 ||
496
(importAttributes &
MethodImportAttributes
.ThrowOnUnmappableCharMask) == 0)
499
if ((importAttributes &
MethodImportAttributes
.BestFitMappingMask) == 0)
500
importAttributes |= fromCA &
MethodImportAttributes
.BestFitMappingMask;
501
if ((importAttributes &
MethodImportAttributes
.ThrowOnUnmappableCharMask) == 0)
502
importAttributes |= fromCA &
MethodImportAttributes
.ThrowOnUnmappableCharMask;
507
Debug.Assert((int)
MethodImportAttributes
.CallingConventionStdCall == (int)PInvokeAttributes.CallingConventionStdCall);
508
Debug.Assert((int)
MethodImportAttributes
.CharSetAuto == (int)PInvokeAttributes.CharSetAuto);
509
Debug.Assert((int)
MethodImportAttributes
.CharSetUnicode == (int)PInvokeAttributes.CharSetUnicode);
510
Debug.Assert((int)
MethodImportAttributes
.SetLastError == (int)PInvokeAttributes.SetLastError);
520
private
MethodImportAttributes
GetImportAttributesFromBestFitMappingAttribute(CustomAttributeHandleCollection attributeHandles)
525
MethodImportAttributes
result = 0;
539
result |=
MethodImportAttributes
.BestFitMappingEnable;
541
result |=
MethodImportAttributes
.BestFitMappingDisable;
550
result |=
MethodImportAttributes
.ThrowOnUnmappableCharEnable;
552
result |=
MethodImportAttributes
.ThrowOnUnmappableCharDisable;
Microsoft.CodeAnalysis (40)
MetadataReader\PEModule.cs (2)
3449
MethodImportAttributes
flags = (
MethodImportAttributes
)methodImport.Attributes;
PEWriter\Miscellaneous.cs (1)
237
MethodImportAttributes
Flags { get; }
Symbols\Attributes\CommonMethodWellKnownAttributeData.cs (1)
65
public void SetDllImport(int attributeIndex, string? moduleName, string? entryPointName,
MethodImportAttributes
flags, bool preserveSig)
Symbols\PlatformInvokeInformation.cs (36)
18
private readonly
MethodImportAttributes
_flags;
20
internal DllImportData(string? moduleName, string? entryPointName,
MethodImportAttributes
flags)
43
MethodImportAttributes
Cci.IPlatformInvokeInformation.Flags
56
return (_flags &
MethodImportAttributes
.ExactSpelling) != 0;
67
switch (_flags &
MethodImportAttributes
.CharSetMask)
69
case
MethodImportAttributes
.CharSetAnsi:
72
case
MethodImportAttributes
.CharSetUnicode:
75
case
MethodImportAttributes
.CharSetAuto:
93
return (_flags &
MethodImportAttributes
.SetLastError) != 0;
104
switch (_flags &
MethodImportAttributes
.CallingConventionMask)
109
case
MethodImportAttributes
.CallingConventionCDecl:
112
case
MethodImportAttributes
.CallingConventionStdCall:
115
case
MethodImportAttributes
.CallingConventionThisCall:
118
case
MethodImportAttributes
.CallingConventionFastCall:
132
switch (_flags &
MethodImportAttributes
.BestFitMappingMask)
134
case
MethodImportAttributes
.BestFitMappingEnable:
137
case
MethodImportAttributes
.BestFitMappingDisable:
154
switch (_flags &
MethodImportAttributes
.ThrowOnUnmappableCharMask)
156
case
MethodImportAttributes
.ThrowOnUnmappableCharEnable:
159
case
MethodImportAttributes
.ThrowOnUnmappableCharDisable:
168
internal static
MethodImportAttributes
MakeFlags(bool exactSpelling, CharSet charSet, bool setLastError, CallingConvention callingConvention, bool? useBestFit, bool? throwOnUnmappable)
170
MethodImportAttributes
result = 0;
173
result |=
MethodImportAttributes
.ExactSpelling;
179
result |=
MethodImportAttributes
.CharSetAnsi;
183
result |=
MethodImportAttributes
.CharSetUnicode;
187
result |=
MethodImportAttributes
.CharSetAuto;
195
result |=
MethodImportAttributes
.SetLastError;
201
result |=
MethodImportAttributes
.CallingConventionWinApi;
205
result |=
MethodImportAttributes
.CallingConventionCDecl;
209
result |=
MethodImportAttributes
.CallingConventionStdCall;
213
result |=
MethodImportAttributes
.CallingConventionThisCall;
217
result |=
MethodImportAttributes
.CallingConventionFastCall;
225
result |=
MethodImportAttributes
.ThrowOnUnmappableCharEnable;
229
result |=
MethodImportAttributes
.ThrowOnUnmappableCharDisable;
237
result |=
MethodImportAttributes
.BestFitMappingEnable;
241
result |=
MethodImportAttributes
.BestFitMappingDisable;
Microsoft.CodeAnalysis.VisualBasic (9)
Symbols\Source\SourceMethodSymbol.vb (9)
286
Private Shared Function GetPInvokeAttributes(syntax As DeclareStatementSyntax) As
MethodImportAttributes
287
Dim result As
MethodImportAttributes
290
result =
MethodImportAttributes
.CharSetAnsi Or
MethodImportAttributes
.ExactSpelling
293
result =
MethodImportAttributes
.CharSetUnicode Or
MethodImportAttributes
.ExactSpelling
296
result =
MethodImportAttributes
.CharSetAuto
299
Return result Or
MethodImportAttributes
.CallingConventionWinApi Or
MethodImportAttributes
.SetLastError
System.Reflection.Emit (24)
System\Reflection\Emit\ModuleBuilderImpl.cs (1)
955
MethodImportAttributes
attributes, ModuleReferenceHandle moduleHandle) =>
System\Reflection\Emit\PseudoCustomAttributesData.cs (23)
14
private readonly
MethodImportAttributes
_flags;
16
internal DllImportData(string moduleName, string? entryPoint,
MethodImportAttributes
flags)
27
public
MethodImportAttributes
Flags => _flags;
37
MethodImportAttributes
importAttributes =
MethodImportAttributes
.None;
61
importAttributes |=
MethodImportAttributes
.ExactSpelling;
67
importAttributes |=
MethodImportAttributes
.SetLastError;
73
importAttributes |=
MethodImportAttributes
.BestFitMappingEnable;
77
importAttributes |=
MethodImportAttributes
.BestFitMappingDisable;
83
importAttributes |=
MethodImportAttributes
.ThrowOnUnmappableCharEnable;
87
importAttributes |=
MethodImportAttributes
.ThrowOnUnmappableCharDisable;
103
MethodImportAttributes
importAttributes = MatchNativeCallingConvention(nativeCallConv);
109
private static
MethodImportAttributes
MatchNativeCharSet(CharSet nativeCharSet) =>
112
CharSet.Ansi =>
MethodImportAttributes
.CharSetAnsi,
113
CharSet.Auto =>
MethodImportAttributes
.CharSetAuto,
114
CharSet.Unicode =>
MethodImportAttributes
.CharSetUnicode,
115
_ =>
MethodImportAttributes
.CharSetAuto
118
private static
MethodImportAttributes
MatchNativeCallingConvention(CallingConvention nativeCallConv) =>
121
CallingConvention.Cdecl =>
MethodImportAttributes
.CallingConventionCDecl,
122
CallingConvention.FastCall =>
MethodImportAttributes
.CallingConventionFastCall,
123
CallingConvention.StdCall =>
MethodImportAttributes
.CallingConventionStdCall,
124
CallingConvention.ThisCall =>
MethodImportAttributes
.CallingConventionThisCall,
125
_ =>
MethodImportAttributes
.CallingConventionWinApi // Roslyn defaults with this
System.Reflection.Metadata (6)
System\Reflection\Metadata\Ecma335\MetadataBuilder.Tables.cs (1)
1023
MethodImportAttributes
attributes,
System\Reflection\Metadata\Internal\Tables.cs (2)
1756
var
pInvokeMapFlags = (
MethodImportAttributes
)Block.PeekUInt16(rowOffset + _FlagsOffset);
System\Reflection\Metadata\TypeSystem\MethodImport.cs (3)
8
private readonly
MethodImportAttributes
_attributes;
12
internal MethodImport(
MethodImportAttributes
attributes, StringHandle name, ModuleReferenceHandle module)
19
public
MethodImportAttributes
Attributes { get { return _attributes; } }
System.Reflection.MetadataLoadContext (17)
System\Reflection\TypeLoading\MethodBase\Ecma\EcmaMethodDecoder.cs (17)
123
MethodImportAttributes
a = mi.Attributes;
124
CharSet charSet = (a &
MethodImportAttributes
.CharSetMask) switch
126
MethodImportAttributes
.CharSetAnsi => CharSet.Ansi,
127
MethodImportAttributes
.CharSetAuto => CharSet.Auto,
128
MethodImportAttributes
.CharSetUnicode => CharSet.Unicode,
131
CallingConvention callConv = (a &
MethodImportAttributes
.CallingConventionMask) switch
133
MethodImportAttributes
.CallingConventionCDecl => CallingConvention.Cdecl,
134
MethodImportAttributes
.CallingConventionFastCall => CallingConvention.FastCall,
135
MethodImportAttributes
.CallingConventionStdCall => CallingConvention.StdCall,
136
MethodImportAttributes
.CallingConventionThisCall => CallingConvention.ThisCall,
137
MethodImportAttributes
.CallingConventionWinApi => CallingConvention.Winapi,
143
ExactSpelling = (a &
MethodImportAttributes
.ExactSpelling) != 0,
147
SetLastError = (a &
MethodImportAttributes
.SetLastError) != 0,
148
BestFitMapping = (a &
MethodImportAttributes
.BestFitMappingMask) ==
MethodImportAttributes
.BestFitMappingEnable,
149
ThrowOnUnmappableChar = (a &
MethodImportAttributes
.ThrowOnUnmappableCharMask) ==
MethodImportAttributes
.ThrowOnUnmappableCharEnable,