209 references to MarshalDirection
Microsoft.Interop.ComInterfaceGenerator (64)
Analyzers\ComInterfaceGeneratorDiagnosticsAnalyzer.cs (4)
190if (srcCtx.VtableIndexData.Direction is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 194if (srcCtx.VtableIndexData.Direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (2)
88var managedToUnmanagedFactory = new ByValueContentsMarshalKindValidator(ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged)); 89var unmanagedToManagedFactory = new ByValueContentsMarshalKindValidator(ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags, MarshalDirection.UnmanagedToManaged));
Analyzers\VtableIndexStubDiagnosticsAnalyzer.cs (4)
92if (stubContext.VtableIndexData.Direction is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 99if (stubContext.VtableIndexData.Direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
ComInterfaceGenerator.cs (5)
270var direction = GetDirectionFromOptions(generatedComInterfaceAttributeData.Options); 423private static MarshalDirection GetDirectionFromOptions(ComInterfaceOptions options) 427return MarshalDirection.Bidirectional; 431return MarshalDirection.UnmanagedToManaged; 435return MarshalDirection.ManagedToUnmanaged;
ComInterfaceGeneratorHelpers.cs (10)
11private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling, MarshalDirection.ManagedToUnmanaged); 12private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling, MarshalDirection.UnmanagedToManaged); 13private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None, MarshalDirection.ManagedToUnmanaged); 14private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None, MarshalDirection.UnmanagedToManaged); 16private static IMarshallingGeneratorResolver CreateGeneratorResolver(EnvironmentFlags env, MarshalDirection direction) 24public 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,
ComMethodContext.cs (4)
78if (GenerationContext.VtableIndexData.Direction is not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 98if (GenerationContext.VtableIndexData.Direction is not (MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (1)
17return context.Direction == MarshalDirection.UnmanagedToManaged
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
19MarshalDirection.UnmanagedToManaged => new UnmanagedToManagedMarshaller().Bind(info, context), 20MarshalDirection.ManagedToUnmanaged => new ManagedToUnmanagedMarshaller().Bind(info, context),
Marshallers\ObjectUnwrapperResolver.cs (1)
16return context.Direction == MarshalDirection.UnmanagedToManaged
Marshallers\StructAsHResultMarshallerFactory.cs (4)
34if (MarshallerHelpers.GetMarshalDirection(info, codeContext) is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 40if (MarshallerHelpers.GetMarshalDirection(info, codeContext) is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
VirtualMethodIndexData.cs (2)
15MarshalDirection Direction, 42public MarshalDirection Direction { get; init; }
VirtualMethodPointerStubGenerator.cs (6)
22Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 34generatorResolverCreator(methodStub.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged), 77Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 84generatorResolverCreator(methodStub.EnvironmentFlags, MarshalDirection.UnmanagedToManaged)); 193Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 199generatorResolverCreator(method.EnvironmentFlags, MarshalDirection.UnmanagedToManaged));
VtableIndexStubGenerator.cs (9)
48.Where(data => data.VtableIndexData.Direction is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional); 87.Where(data => data.VtableIndexData.Direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional); 227MarshalDirection direction = MarshalDirection.Bidirectional; 240direction = (MarshalDirection)directionValue.Value!; 347if (!virtualMethodIndexData.ImplicitThisParameter && virtualMethodIndexData.Direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
VtableIndexStubGeneratorHelpers.cs (10)
13private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling, MarshalDirection.ManagedToUnmanaged); 14private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedDisabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.DisableRuntimeMarshalling, MarshalDirection.UnmanagedToManaged); 15private static readonly IMarshallingGeneratorResolver s_managedToUnmanagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None, MarshalDirection.ManagedToUnmanaged); 16private static readonly IMarshallingGeneratorResolver s_unmanagedToManagedEnabledMarshallingGeneratorResolver = CreateGeneratorResolver(EnvironmentFlags.None, MarshalDirection.UnmanagedToManaged); 18private static IMarshallingGeneratorResolver CreateGeneratorResolver(EnvironmentFlags env, MarshalDirection direction) 24public 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 (23)
JSGeneratorFactory.cs (2)
29if (MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.UnmanagedToManaged && info.ManagedIndex == TypePositionInfo.UnsetIndex) 48bool isToJs = MarshallerHelpers.GetMarshalDirection(info, context) == MarshalDirection.ManagedToUnmanaged;
Marshaling\BaseJSGenerator.cs (2)
32MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 34&& marshalDirection == MarshalDirection.ManagedToUnmanaged
Marshaling\FuncJSGenerator.cs (7)
15MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 17if (marshalDirection == MarshalDirection.UnmanagedToManaged 18&& ((context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged) 19|| (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged))) 24if (marshalDirection == MarshalDirection.ManagedToUnmanaged 25&& ((context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged) 26|| (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)))
Marshaling\PrimitiveJSGenerator.cs (5)
17MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 19if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && marshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 24if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && marshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional)
Marshaling\TaskJSGenerator.cs (7)
14MarshalDirection marshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 16if (marshalDirection == MarshalDirection.UnmanagedToManaged 17&& ((context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged) 18|| (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged))) 23if (marshalDirection == MarshalDirection.ManagedToUnmanaged 24&& ((context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged) 25|| (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)))
Microsoft.Interop.LibraryImportGenerator (3)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
150var factory = new ByValueContentsMarshalKindValidator(DefaultMarshallingGeneratorResolver.Create(env.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged, TypeNames.LibraryImportAttribute_ShortName, []));
Analyzers\LibraryImportDiagnosticsAnalyzer.cs (1)
305MarshalDirection.ManagedToUnmanaged,
LibraryImportGenerator.cs (1)
306: DefaultMarshallingGeneratorResolver.Create(pinvokeStub.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged, TypeNames.LibraryImportAttribute_ShortName, []);
Microsoft.Interop.SourceGeneration (119)
BoundGenerators.cs (2)
68if (errorHandlingInfo is not null && context.Direction == MarshalDirection.ManagedToUnmanaged) 94if (errorHandlingInfo is not null && context.Direction == MarshalDirection.UnmanagedToManaged)
DefaultIdentifierContext.cs (5)
14private readonly MarshalDirection _direction; 20MarshalDirection direction, 36&& _direction == MarshalDirection.ManagedToUnmanaged 51&& _direction == MarshalDirection.UnmanagedToManaged) 76&& _direction == MarshalDirection.ManagedToUnmanaged
GeneratedStatements.cs (2)
78MarshalDirection.ManagedToUnmanaged => GenerateStatementForNativeInvoke(marshallers, invokeContext, expressionToInvoke), 79MarshalDirection.UnmanagedToManaged => GenerateStatementForManagedInvoke(marshallers, invokeContext, expressionToInvoke),
ManagedToNativeStubGenerator.cs (2)
53MarshalDirection.ManagedToUnmanaged, 64MarshalDirection.ManagedToUnmanaged,
Marshalling\AttributedMarshallingModelGeneratorResolver.cs (10)
117MarshalDirection elementDirection = MarshallerHelpers.GetMarshalDirection(info, context); 121MarshalDirection.ManagedToUnmanaged => marshallers.GetModeOrDefault(Options.ManagedToUnmanagedMode), 122MarshalDirection.Bidirectional => marshallers.GetModeOrDefault(Options.BidirectionalMode), 123MarshalDirection.UnmanagedToManaged => marshallers.GetModeOrDefault(Options.UnmanagedToManagedMode), 215if (MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.ManagedToUnmanaged) 336if (context.Direction == MarshalDirection.ManagedToUnmanaged) 378MarshalDirection elementDirection = MarshallerHelpers.GetMarshalDirection(info, context); 381if (elementDirection == MarshalDirection.UnmanagedToManaged 391if (elementDirection == MarshalDirection.Bidirectional 401if (elementDirection == MarshalDirection.ManagedToUnmanaged
Marshalling\BlittableMarshaller.cs (5)
47MarshalDirection direction = MarshallerHelpers.GetMarshalDirection(info, codeContext); 54if (direction is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional && info.IsByRef) 61if (direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional && info.IsByRef)
Marshalling\BoolMarshaller.cs (5)
47MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 55if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 62if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
Marshalling\BreakingChangeDetector.cs (1)
27&& context.Direction == MarshalDirection.UnmanagedToManaged)
Marshalling\CharMarshaller.cs (7)
61MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 68if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 80if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 93MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, context); 94return !IsPinningPathSupported(info, context) && (elementMarshalDirection != MarshalDirection.ManagedToUnmanaged || info.IsByRef);
Marshalling\CustomTypeMarshallingGenerator.cs (17)
24MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 33if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional 34|| (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && ShouldGenerateByValueOutMarshalling)) 40if (CodeContext.SingleFrameSpansNativeContext && elementMarshalDirection is MarshalDirection.ManagedToUnmanaged) 46if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 52if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 58if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 64if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional 65|| (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling)) 71if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional 72|| (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling))
Marshalling\DefaultMarshallingGeneratorResolver.cs (4)
23MarshalDirection direction, 63direction == MarshalDirection.ManagedToUnmanaged 66direction == MarshalDirection.ManagedToUnmanaged 69direction == MarshalDirection.ManagedToUnmanaged
Marshalling\DelegateMarshaller.cs (7)
25MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 32if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 39if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 46if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional)
Marshalling\ElementsMarshalling.cs (3)
224string source = MarshallerHelpers.GetMarshalDirection(CollectionSource.TypeInfo, CollectionSource.CodeContext) == MarshalDirection.ManagedToUnmanaged 241if (CollectionSource.CodeContext.Direction is MarshalDirection.UnmanagedToManaged && CollectionSource.TypeInfo.ByValueContentsMarshalKind is ByValueContentsMarshalKind.Out) 350&& MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.UnmanagedToManaged;
Marshalling\IidParameterIndexMarshallerResolver.cs (1)
11|| context.Direction != MarshalDirection.UnmanagedToManaged)
Marshalling\MarshallerHelpers.cs (28)
250public static MarshalDirection GetMarshalDirection(TypePositionInfo info, StubCodeContext context) 252if (context.Direction is not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.UnmanagedToManaged)) 257if (context.Direction == MarshalDirection.ManagedToUnmanaged) 262? MarshalDirection.Bidirectional 263: MarshalDirection.UnmanagedToManaged; 268return MarshalDirection.UnmanagedToManaged; 272return MarshalDirection.ManagedToUnmanaged; 278return MarshalDirection.ManagedToUnmanaged; 280return MarshalDirection.Bidirectional; 282return MarshalDirection.UnmanagedToManaged; 290return MarshalDirection.ManagedToUnmanaged; 294return MarshalDirection.UnmanagedToManaged; 300return MarshalDirection.UnmanagedToManaged; 302return MarshalDirection.Bidirectional; 304return MarshalDirection.ManagedToUnmanaged; 317if (context.Direction is MarshalDirection.UnmanagedToManaged) 322MarshalDirection.UnmanagedToManaged => StubIdentifierContext.Stage.CleanupCalleeAllocated, 323MarshalDirection.ManagedToUnmanaged => StubIdentifierContext.Stage.CleanupCallerAllocated, 324MarshalDirection.Bidirectional => StubIdentifierContext.Stage.CleanupCallerAllocated, 334public static void ValidateCountInfoAvailableAtCall(MarshalDirection stubDirection, TypePositionInfo info, GeneratorDiagnosticsBag generatorDiagnostics, IMethodSymbol symbol, DiagnosticDescriptor outParamDescriptor, DiagnosticDescriptor returnValueDescriptor) 338if (stubDirection is MarshalDirection.ManagedToUnmanaged) 429public static bool IsInStubReturnPosition(TypePositionInfo info, MarshalDirection direction) 433MarshalDirection.ManagedToUnmanaged => info.IsManagedReturnPosition, 434MarshalDirection.UnmanagedToManaged => info.IsNativeReturnPosition, 444public static bool IsInInvocationReturnPosition(TypePositionInfo info, MarshalDirection direction) 448MarshalDirection.ManagedToUnmanaged => info.IsNativeReturnPosition, 449MarshalDirection.UnmanagedToManaged => info.IsManagedReturnPosition,
Marshalling\MarshallingGeneratorExtensions.cs (2)
54if (generator.CodeContext.Direction == MarshalDirection.ManagedToUnmanaged) 60else if (generator.CodeContext.Direction == MarshalDirection.UnmanagedToManaged)
Marshalling\StatefulMarshallingStrategy.cs (5)
209if (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out) 215if (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) 235if (MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext) is not MarshalDirection.ManagedToUnmanaged 252if (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) 257if (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out)
Marshalling\StatelessMarshallingStrategy.cs (8)
182&& MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext) != MarshalDirection.ManagedToUnmanaged) 192&& MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext) != MarshalDirection.ManagedToUnmanaged) 253if (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) 332if (countInfo is NoCountInfo && MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext) == MarshalDirection.ManagedToUnmanaged) 381if (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out) 386if (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) 415if (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out)) 420if (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsByRef && TypeInfo.ByValueContentsMarshalKind == ByValueContentsMarshalKind.Out)
StubCodeContext.cs (3)
29MarshalDirection Direction) 34Direction: MarshalDirection.ManagedToUnmanaged); 39Direction: MarshalDirection.UnmanagedToManaged);
UnmanagedToManagedStubGenerator.cs (2)
27_context = new DefaultIdentifierContext(ReturnIdentifier, $"{ReturnIdentifier}{StubIdentifierContext.GeneratedNativeIdentifierSuffix}", MarshalDirection.UnmanagedToManaged); 31_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier, MarshalDirection.UnmanagedToManaged);