175 references to MarshalDirection
Microsoft.Interop.ComInterfaceGenerator (59)
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)
UnmanagedToManagedStubGenerator.cs (2)
34
_context = new DefaultIdentifierContext(ReturnIdentifier, $"{ReturnIdentifier}{StubIdentifierContext.GeneratedNativeIdentifierSuffix}",
MarshalDirection
.UnmanagedToManaged);
38
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier,
MarshalDirection
.UnmanagedToManaged);
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)
JSExportCodeGenerator.cs (2)
40
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnNativeIdentifier,
MarshalDirection
.UnmanagedToManaged)
47
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier,
MarshalDirection
.UnmanagedToManaged)
JSGeneratorFactory.cs (1)
36
bool isToJs = info.ManagedIndex != TypePositionInfo.ReturnIndex ^ context.Direction ==
MarshalDirection
.UnmanagedToManaged;
JSImportCodeGenerator.cs (2)
47
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnNativeIdentifier,
MarshalDirection
.ManagedToUnmanaged)
54
_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier,
MarshalDirection
.ManagedToUnmanaged)
Marshaling\FuncJSGenerator.cs (4)
48
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition)
53
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition)
63
if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition)
68
if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\PrimitiveJSGenerator.cs (4)
36
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition)
41
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition)
51
if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition)
56
if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\TaskJSGenerator.cs (4)
49
if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition)
56
if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction ==
MarshalDirection
.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition)
68
if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction ==
MarshalDirection
.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition)
75
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 (97)
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)
292
/// For example, an out parameter is marshalled in the <see cref="
MarshalDirection
.UnmanagedToManaged"/> direction in a <see cref="
MarshalDirection
.ManagedToUnmanaged"/> stub,
293
/// but from <see cref="
MarshalDirection
.ManagedToUnmanaged"/> in a <see cref="
MarshalDirection
.UnmanagedToManaged"/> stub.
298
public static
MarshalDirection
GetMarshalDirection(TypePositionInfo info, StubCodeContext context)
300
if (context.Direction is not (
MarshalDirection
.ManagedToUnmanaged or
MarshalDirection
.UnmanagedToManaged))
305
if (context.Direction ==
MarshalDirection
.ManagedToUnmanaged)
309
return
MarshalDirection
.UnmanagedToManaged;
313
return
MarshalDirection
.ManagedToUnmanaged;
319
return
MarshalDirection
.ManagedToUnmanaged;
321
return
MarshalDirection
.Bidirectional;
323
return
MarshalDirection
.UnmanagedToManaged;
331
return
MarshalDirection
.ManagedToUnmanaged;
335
return
MarshalDirection
.UnmanagedToManaged;
341
return
MarshalDirection
.UnmanagedToManaged;
343
return
MarshalDirection
.Bidirectional;
345
return
MarshalDirection
.ManagedToUnmanaged;
358
if (context.Direction is
MarshalDirection
.UnmanagedToManaged)
363
MarshalDirection
.UnmanagedToManaged => StubIdentifierContext.Stage.CleanupCalleeAllocated,
364
MarshalDirection
.ManagedToUnmanaged => StubIdentifierContext.Stage.CleanupCallerAllocated,
365
MarshalDirection
.Bidirectional => StubIdentifierContext.Stage.CleanupCallerAllocated,
375
public static void ValidateCountInfoAvailableAtCall(
MarshalDirection
stubDirection, TypePositionInfo info, GeneratorDiagnosticsBag generatorDiagnostics, IMethodSymbol symbol, DiagnosticDescriptor outParamDescriptor, DiagnosticDescriptor returnValueDescriptor)
379
if (stubDirection is
MarshalDirection
.ManagedToUnmanaged)
471
public static bool IsInStubReturnPosition(TypePositionInfo info,
MarshalDirection
direction)
475
MarshalDirection
.ManagedToUnmanaged => info.IsManagedReturnPosition,
476
MarshalDirection
.UnmanagedToManaged => info.IsNativeReturnPosition,
486
public static bool IsInInvocationReturnPosition(TypePositionInfo info,
MarshalDirection
direction)
490
MarshalDirection
.ManagedToUnmanaged => info.IsNativeReturnPosition,
491
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);