161 references to MethodImportAttributes
Microsoft.CodeAnalysis (40)
MetadataReader\PEModule.cs (2)
3427
MethodImportAttributes
flags = (
MethodImportAttributes
)methodImport.Attributes;
PEWriter\Miscellaneous.cs (1)
236
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.CSharp.Emit3.UnitTests (65)
Attributes\AttributeTests_WellKnownAttributes.cs (65)
2709
MethodImportAttributes
.ExactSpelling |
2710
MethodImportAttributes
.CharSetUnicode |
2711
MethodImportAttributes
.SetLastError |
2712
MethodImportAttributes
.CallingConventionCDecl |
2713
MethodImportAttributes
.BestFitMappingEnable |
2714
MethodImportAttributes
.ThrowOnUnmappableCharEnable, import.Attributes);
2736
MethodImportAttributes
.ExactSpelling |
2737
MethodImportAttributes
.CharSetUnicode |
2738
MethodImportAttributes
.SetLastError |
2739
MethodImportAttributes
.CallingConventionCDecl |
2740
MethodImportAttributes
.BestFitMappingEnable |
2741
MethodImportAttributes
.ThrowOnUnmappableCharEnable, ((Cci.IPlatformInvokeInformation)info).Flags);
2857
new { attr = MakeDllImport(), expected =
MethodImportAttributes
.CallingConventionWinApi}, // M0
2858
new { attr = MakeDllImport(cc: CallingConvention.Cdecl), expected =
MethodImportAttributes
.CallingConventionCDecl }, // M1
2859
new { attr = MakeDllImport(cc: CallingConvention.FastCall), expected =
MethodImportAttributes
.CallingConventionFastCall }, // M2
2860
new { attr = MakeDllImport(cc: CallingConvention.StdCall), expected =
MethodImportAttributes
.CallingConventionStdCall }, // M3
2861
new { attr = MakeDllImport(cc: CallingConvention.ThisCall), expected =
MethodImportAttributes
.CallingConventionThisCall }, // M4
2862
new { attr = MakeDllImport(cc: CallingConvention.Winapi), expected =
MethodImportAttributes
.CallingConventionWinApi }, // M5
2865
new { attr = MakeDllImport(), expected =
MethodImportAttributes
.CallingConventionWinApi }, // M6
2866
new { attr = MakeDllImport(charSet: CharSet.None), expected =
MethodImportAttributes
.CallingConventionWinApi }, // M7
2867
new { attr = MakeDllImport(charSet: CharSet.Ansi), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetAnsi }, // M8
2868
new { attr = MakeDllImport(charSet: CharSet.Unicode), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetUnicode }, // M9
2869
new { attr = MakeDllImport(charSet: CharSet.Auto), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetAuto }, // M10
2871
new { attr = MakeDllImport(exactSpelling: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ExactSpelling }, // M11
2872
new { attr = MakeDllImport(exactSpelling: false), expected =
MethodImportAttributes
.CallingConventionWinApi }, // M12
2874
new { attr = MakeDllImport(charSet: CharSet.Ansi, exactSpelling: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ExactSpelling |
MethodImportAttributes
.CharSetAnsi }, // M13
2875
new { attr = MakeDllImport(charSet: CharSet.Ansi, exactSpelling: false), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetAnsi }, // M14
2876
new { attr = MakeDllImport(charSet: CharSet.Unicode, exactSpelling: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ExactSpelling |
MethodImportAttributes
.CharSetUnicode },// M15
2877
new { attr = MakeDllImport(charSet: CharSet.Unicode, exactSpelling: false), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetUnicode }, // M16
2878
new { attr = MakeDllImport(charSet: CharSet.Auto, exactSpelling: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ExactSpelling |
MethodImportAttributes
.CharSetAuto }, // M17
2879
new { attr = MakeDllImport(charSet: CharSet.Auto, exactSpelling: false), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.CharSetAuto }, // M18
2882
new { attr = MakeDllImport(preserveSig: true), expected =
MethodImportAttributes
.CallingConventionWinApi}, // M19
2883
new { attr = MakeDllImport(preserveSig: false), expected =
MethodImportAttributes
.CallingConventionWinApi}, // M20
2886
new { attr = MakeDllImport(setLastError: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.SetLastError}, // M21
2887
new { attr = MakeDllImport(setLastError: false), expected =
MethodImportAttributes
.CallingConventionWinApi}, // M22
2890
new { attr = MakeDllImport(bestFitMapping: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.BestFitMappingEnable}, // M23
2891
new { attr = MakeDllImport(bestFitMapping: false), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.BestFitMappingDisable}, // M24
2894
new { attr = MakeDllImport(throwOnUnmappableChar: true), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ThrowOnUnmappableCharEnable}, // M23
2895
new { attr = MakeDllImport(throwOnUnmappableChar: false), expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.ThrowOnUnmappableCharDisable}, // M24
2899
expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.SetLastError }, // M25
2903
expected =
MethodImportAttributes
.CallingConventionWinApi |
MethodImportAttributes
.SetLastError }, // M26
3436
Assert.Equal(
MethodImportAttributes
.CharSetAnsi, import.Attributes &
MethodImportAttributes
.CharSetMask);
3468
Assert.Equal(
MethodImportAttributes
.None, import.Attributes &
MethodImportAttributes
.CharSetMask);
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)
968
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,