175 references to MarshalDirection
Microsoft.Interop.ComInterfaceGenerator (57)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (2)
84
var managedToUnmanagedFactory = ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags,
MarshalDirection
.ManagedToUnmanaged);
85
var unmanagedToManagedFactory = ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags,
MarshalDirection
.UnmanagedToManaged);
ComInterfaceGenerator.cs (5)
352
var
direction = GetDirectionFromOptions(generatedComInterfaceAttributeData.Options);
395
private static
MarshalDirection
GetDirectionFromOptions(ComInterfaceOptions options)
399
return
MarshalDirection
.Bidirectional;
403
return
MarshalDirection
.UnmanagedToManaged;
407
return
MarshalDirection
.ManagedToUnmanaged;
ComInterfaceGeneratorHelpers.cs (10)
13
private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling,
MarshalDirection
.ManagedToUnmanaged);
14
private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling,
MarshalDirection
.UnmanagedToManaged);
15
private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None,
MarshalDirection
.ManagedToUnmanaged);
16
private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None,
MarshalDirection
.UnmanagedToManaged);
18
private static IMarshallingGeneratorResolver CreateGeneratorResolver(EnvironmentFlags env,
MarshalDirection
direction)
26
public static IMarshallingGeneratorResolver GetGeneratorResolver(EnvironmentFlags env,
MarshalDirection
direction)
29
(true,
MarshalDirection
.ManagedToUnmanaged) => s_managedToUnmanagedDisabledMarshallingGeneratorResolver,
30
(true,
MarshalDirection
.UnmanagedToManaged) => s_unmanagedToManagedDisabledMarshallingGeneratorResolver,
31
(false,
MarshalDirection
.ManagedToUnmanaged) => s_managedToUnmanagedEnabledMarshallingGeneratorResolver,
32
(false,
MarshalDirection
.UnmanagedToManaged) => s_unmanagedToManagedEnabledMarshallingGeneratorResolver,
ComMethodContext.cs (4)
80
if (GenerationContext.VtableIndexData.Direction is not (
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional) || IsHiddenOnDerivedInterface)
94
if (GenerationContext.VtableIndexData.Direction is not (
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional) || IsHiddenOnDerivedInterface)
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (1)
23
return context.Direction ==
MarshalDirection
.UnmanagedToManaged
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
24
MarshalDirection
.UnmanagedToManaged => new UnmanagedToManagedMarshaller().Bind(info, context),
25
MarshalDirection
.ManagedToUnmanaged => new ManagedToUnmanagedMarshaller().Bind(info, context),
Marshallers\ObjectUnwrapperResolver.cs (1)
21
return context.Direction ==
MarshalDirection
.UnmanagedToManaged
Marshallers\StructAsHResultMarshallerFactory.cs (4)
39
if (MarshallerHelpers.GetMarshalDirection(info, codeContext) is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
57
if (MarshallerHelpers.GetMarshalDirection(info, codeContext) is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
VirtualMethodIndexData.cs (2)
15
MarshalDirection
Direction,
42
public
MarshalDirection
Direction { get; init; }
VirtualMethodPointerStubGenerator.cs (7)
25
Func<EnvironmentFlags,
MarshalDirection
, IMarshallingGeneratorResolver> generatorResolverCreator)
41
generatorResolverCreator(methodStub.EnvironmentFlags,
MarshalDirection
.ManagedToUnmanaged),
132
Func<EnvironmentFlags,
MarshalDirection
, IMarshallingGeneratorResolver> generatorResolverCreator)
142
generatorResolverCreator(methodStub.EnvironmentFlags,
MarshalDirection
.UnmanagedToManaged));
237
Func<EnvironmentFlags,
MarshalDirection
, IMarshallingGeneratorResolver> generatorResolverCreator)
262
Func<EnvironmentFlags,
MarshalDirection
, IMarshallingGeneratorResolver> generatorResolverCreator)
269
generatorResolverCreator(method.EnvironmentFlags,
MarshalDirection
.UnmanagedToManaged));
VtableIndexStubGenerator.cs (9)
80
.Where(data => data.VtableIndexData.Direction is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
94
.Where(data => data.VtableIndexData.Direction is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional);
145
MarshalDirection
direction =
MarshalDirection
.Bidirectional;
158
direction = (
MarshalDirection
)directionValue.Value!;
265
if (!virtualMethodIndexData.ImplicitThisParameter && virtualMethodIndexData.Direction is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
VtableIndexStubGeneratorHelpers.cs (10)
13
private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling,
MarshalDirection
.ManagedToUnmanaged);
14
private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling,
MarshalDirection
.UnmanagedToManaged);
15
private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None,
MarshalDirection
.ManagedToUnmanaged);
16
private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None,
MarshalDirection
.UnmanagedToManaged);
18
private static IMarshallingGeneratorResolver CreateGeneratorResolver(EnvironmentFlags env,
MarshalDirection
direction)
24
public static IMarshallingGeneratorResolver GetGeneratorResolver(EnvironmentFlags env,
MarshalDirection
direction)
27
(true,
MarshalDirection
.ManagedToUnmanaged) => s_managedToUnmanagedDisabledMarshallingGeneratorResolver,
28
(true,
MarshalDirection
.UnmanagedToManaged) => s_unmanagedToManagedDisabledMarshallingGeneratorResolver,
29
(false,
MarshalDirection
.ManagedToUnmanaged) => s_managedToUnmanagedEnabledMarshallingGeneratorResolver,
30
(false,
MarshalDirection
.UnmanagedToManaged) => s_unmanagedToManagedEnabledMarshallingGeneratorResolver,
Microsoft.Interop.JavaScript.JSImportGenerator (17)
JSGeneratorFactory.cs (2)
29
if (MarshallerHelpers.GetMarshalDirection(info, context) !=
MarshalDirection
.UnmanagedToManaged && info.ManagedIndex == TypePositionInfo.UnsetIndex)
48
bool isToJs = MarshallerHelpers.GetMarshalDirection(info, context) ==
MarshalDirection
.ManagedToUnmanaged;
Marshaling\BaseJSGenerator.cs (2)
39
MarshalDirection
marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext);
41
&& marshalDirection ==
MarshalDirection
.ManagedToUnmanaged
Marshaling\FuncJSGenerator.cs (4)
30
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition)
35
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition)
40
if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition)
45
if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\PrimitiveJSGenerator.cs (5)
24
MarshalDirection
marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext);
26
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && marshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
31
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && marshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
Marshaling\TaskJSGenerator.cs (4)
25
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition)
32
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition)
39
if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition)
46
if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
150
var factory = DefaultMarshallingGeneratorResolver.Create(env.EnvironmentFlags,
MarshalDirection
.ManagedToUnmanaged, TypeNames.LibraryImportAttribute_ShortName, []);
LibraryImportGenerator.cs (1)
338
: DefaultMarshallingGeneratorResolver.Create(pinvokeStub.EnvironmentFlags,
MarshalDirection
.ManagedToUnmanaged, TypeNames.LibraryImportAttribute_ShortName, []);
Microsoft.Interop.SourceGeneration (99)
DefaultIdentifierContext.cs (2)
14
private readonly
MarshalDirection
_direction;
19
MarshalDirection
direction)
GeneratedStatements.cs (2)
52
if (codeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged)
59
else if (codeContext.Direction ==
MarshalDirection
.UnmanagedToManaged)
ManagedToNativeStubGenerator.cs (2)
66
_context = new DefaultIdentifierContext(ReturnIdentifier, $"{ReturnIdentifier}{StubIdentifierContext.GeneratedNativeIdentifierSuffix}",
MarshalDirection
.ManagedToUnmanaged)
73
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier,
MarshalDirection
.ManagedToUnmanaged)
Marshalling\AttributedMarshallingModelGeneratorResolver.cs (10)
133
MarshalDirection
elementDirection = MarshallerHelpers.GetMarshalDirection(info, context);
137
MarshalDirection
.ManagedToUnmanaged => marshallers.GetModeOrDefault(Options.ManagedToUnmanagedMode),
138
MarshalDirection
.Bidirectional => marshallers.GetModeOrDefault(Options.BidirectionalMode),
139
MarshalDirection
.UnmanagedToManaged => marshallers.GetModeOrDefault(Options.UnmanagedToManagedMode),
231
if (MarshallerHelpers.GetMarshalDirection(info, context) !=
MarshalDirection
.ManagedToUnmanaged)
369
if (context.Direction ==
MarshalDirection
.ManagedToUnmanaged)
419
MarshalDirection
elementDirection = MarshallerHelpers.GetMarshalDirection(info, context);
421
if (elementDirection ==
MarshalDirection
.UnmanagedToManaged
431
if (elementDirection ==
MarshalDirection
.Bidirectional
441
if (elementDirection ==
MarshalDirection
.ManagedToUnmanaged
Marshalling\BlittableMarshaller.cs (5)
65
MarshalDirection
direction = MarshallerHelpers.GetMarshalDirection(info, codeContext);
72
if (direction is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional && info.IsByRef)
83
if (direction is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional && info.IsByRef)
Marshalling\BoolMarshaller.cs (5)
52
MarshalDirection
elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext);
60
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
76
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
Marshalling\BreakingChangeDetector.cs (1)
27
&& context.Direction ==
MarshalDirection
.UnmanagedToManaged)
Marshalling\CharMarshaller.cs (7)
82
MarshalDirection
elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext);
89
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
105
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
125
MarshalDirection
elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, context);
126
return !IsPinningPathSupported(info, context) && (elementMarshalDirection !=
MarshalDirection
.ManagedToUnmanaged || info.IsByRef);
Marshalling\CustomTypeMarshallingGenerator.cs (17)
28
MarshalDirection
elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext);
36
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional
37
|| (CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && ShouldGenerateByValueOutMarshalling))
43
if (CodeContext.SingleFrameSpansNativeContext && elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged)
49
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
55
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
61
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
67
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional
68
|| (CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling))
74
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional
75
|| (CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling))
Marshalling\DefaultMarshallingGeneratorResolver.cs (4)
23
MarshalDirection
direction,
63
direction ==
MarshalDirection
.ManagedToUnmanaged
66
direction ==
MarshalDirection
.ManagedToUnmanaged
69
direction ==
MarshalDirection
.ManagedToUnmanaged
Marshalling\DelegateMarshaller.cs (7)
32
MarshalDirection
elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext);
39
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
58
if (elementMarshalDirection is
MarshalDirection
.UnmanagedToManaged or
MarshalDirection
.Bidirectional)
80
if (elementMarshalDirection is
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.Bidirectional)
Marshalling\MarshallerHelpers.cs (30)
265
/// For example, an out parameter is marshalled in the <see cref="
MarshalDirection
.UnmanagedToManaged"/> direction in a <see cref="
MarshalDirection
.ManagedToUnmanaged"/> stub,
266
/// but from <see cref="
MarshalDirection
.ManagedToUnmanaged"/> in a <see cref="
MarshalDirection
.UnmanagedToManaged"/> stub.
271
public static
MarshalDirection
GetMarshalDirection(TypePositionInfo info, StubCodeContext context)
273
if (context.Direction is not (
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.UnmanagedToManaged))
278
if (context.Direction ==
MarshalDirection
.ManagedToUnmanaged)
282
return
MarshalDirection
.UnmanagedToManaged;
286
return
MarshalDirection
.ManagedToUnmanaged;
292
return
MarshalDirection
.ManagedToUnmanaged;
294
return
MarshalDirection
.Bidirectional;
296
return
MarshalDirection
.UnmanagedToManaged;
304
return
MarshalDirection
.ManagedToUnmanaged;
308
return
MarshalDirection
.UnmanagedToManaged;
314
return
MarshalDirection
.UnmanagedToManaged;
316
return
MarshalDirection
.Bidirectional;
318
return
MarshalDirection
.ManagedToUnmanaged;
331
if (context.Direction is
MarshalDirection
.UnmanagedToManaged)
336
MarshalDirection
.UnmanagedToManaged => StubIdentifierContext.Stage.CleanupCalleeAllocated,
337
MarshalDirection
.ManagedToUnmanaged => StubIdentifierContext.Stage.CleanupCallerAllocated,
338
MarshalDirection
.Bidirectional => StubIdentifierContext.Stage.CleanupCallerAllocated,
348
public static void ValidateCountInfoAvailableAtCall(
MarshalDirection
stubDirection, TypePositionInfo info, GeneratorDiagnosticsBag generatorDiagnostics, IMethodSymbol symbol, DiagnosticDescriptor outParamDescriptor, DiagnosticDescriptor returnValueDescriptor)
352
if (stubDirection is
MarshalDirection
.ManagedToUnmanaged)
444
public static bool IsInStubReturnPosition(TypePositionInfo info,
MarshalDirection
direction)
448
MarshalDirection
.ManagedToUnmanaged => info.IsManagedReturnPosition,
449
MarshalDirection
.UnmanagedToManaged => info.IsNativeReturnPosition,
459
public static bool IsInInvocationReturnPosition(TypePositionInfo info,
MarshalDirection
direction)
463
MarshalDirection
.ManagedToUnmanaged => info.IsNativeReturnPosition,
464
MarshalDirection
.UnmanagedToManaged => info.IsManagedReturnPosition,
Marshalling\MarshallingGeneratorExtensions.cs (2)
67
if (generator.CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged)
73
else if (generator.CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged)
StubCodeContext.cs (3)
29
MarshalDirection
Direction)
34
Direction:
MarshalDirection
.ManagedToUnmanaged);
39
Direction:
MarshalDirection
.UnmanagedToManaged);
UnmanagedToManagedStubGenerator.cs (2)
34
_context = new DefaultIdentifierContext(ReturnIdentifier, $"{ReturnIdentifier}{StubIdentifierContext.GeneratedNativeIdentifierSuffix}",
MarshalDirection
.UnmanagedToManaged);
38
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier,
MarshalDirection
.UnmanagedToManaged);