175 references to MarshalDirection
Microsoft.Interop.ComInterfaceGenerator (59)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (2)
84var managedToUnmanagedFactory = ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged); 85var unmanagedToManagedFactory = ComInterfaceGeneratorHelpers.GetGeneratorResolver(env.EnvironmentFlags, MarshalDirection.UnmanagedToManaged);
ComInterfaceGenerator.cs (5)
352var direction = GetDirectionFromOptions(generatedComInterfaceAttributeData.Options); 395private static MarshalDirection GetDirectionFromOptions(ComInterfaceOptions options) 399return MarshalDirection.Bidirectional; 403return MarshalDirection.UnmanagedToManaged; 407return MarshalDirection.ManagedToUnmanaged;
ComInterfaceGeneratorHelpers.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) 26public 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)
80if (GenerationContext.VtableIndexData.Direction is not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) || IsHiddenOnDerivedInterface) 94if (GenerationContext.VtableIndexData.Direction is not (MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) || IsHiddenOnDerivedInterface)
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (1)
23return context.Direction == MarshalDirection.UnmanagedToManaged
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
24MarshalDirection.UnmanagedToManaged => new UnmanagedToManagedMarshaller().Bind(info, context), 25MarshalDirection.ManagedToUnmanaged => new ManagedToUnmanagedMarshaller().Bind(info, context),
Marshallers\ObjectUnwrapperResolver.cs (1)
21return context.Direction == MarshalDirection.UnmanagedToManaged
Marshallers\StructAsHResultMarshallerFactory.cs (4)
39if (MarshallerHelpers.GetMarshalDirection(info, codeContext) is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 57if (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)
15MarshalDirection Direction, 42public MarshalDirection Direction { get; init; }
VirtualMethodPointerStubGenerator.cs (7)
25Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 41generatorResolverCreator(methodStub.EnvironmentFlags, MarshalDirection.ManagedToUnmanaged), 132Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 142generatorResolverCreator(methodStub.EnvironmentFlags, MarshalDirection.UnmanagedToManaged)); 237Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 262Func<EnvironmentFlags, MarshalDirection, IMarshallingGeneratorResolver> generatorResolverCreator) 269generatorResolverCreator(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); 145MarshalDirection direction = MarshalDirection.Bidirectional; 158direction = (MarshalDirection)directionValue.Value!; 265if (!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 (17)
JSExportCodeGenerator.cs (2)
40_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnNativeIdentifier, MarshalDirection.UnmanagedToManaged) 47_context = new DefaultIdentifierContext(ReturnIdentifier, ReturnIdentifier, MarshalDirection.UnmanagedToManaged)
JSGeneratorFactory.cs (1)
36bool 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)
48if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) 53if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) 63if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) 68if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\PrimitiveJSGenerator.cs (4)
36if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) 41if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) 51if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) 56if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\TaskJSGenerator.cs (4)
49if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) 56if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) 68if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) 75if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
150var 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)
14private readonly MarshalDirection _direction; 19MarshalDirection direction)
GeneratedStatements.cs (2)
52if (codeContext.Direction == MarshalDirection.ManagedToUnmanaged) 59else 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)
133MarshalDirection elementDirection = MarshallerHelpers.GetMarshalDirection(info, context); 137MarshalDirection.ManagedToUnmanaged => marshallers.GetModeOrDefault(Options.ManagedToUnmanagedMode), 138MarshalDirection.Bidirectional => marshallers.GetModeOrDefault(Options.BidirectionalMode), 139MarshalDirection.UnmanagedToManaged => marshallers.GetModeOrDefault(Options.UnmanagedToManagedMode), 231if (MarshallerHelpers.GetMarshalDirection(info, context) != MarshalDirection.ManagedToUnmanaged) 369if (context.Direction == MarshalDirection.ManagedToUnmanaged) 419MarshalDirection elementDirection = MarshallerHelpers.GetMarshalDirection(info, context); 421if (elementDirection == MarshalDirection.UnmanagedToManaged 431if (elementDirection == MarshalDirection.Bidirectional 441if (elementDirection == MarshalDirection.ManagedToUnmanaged
Marshalling\BlittableMarshaller.cs (5)
65MarshalDirection direction = MarshallerHelpers.GetMarshalDirection(info, codeContext); 72if (direction is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional && info.IsByRef) 83if (direction is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional && info.IsByRef)
Marshalling\BoolMarshaller.cs (5)
52MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 60if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 76if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
Marshalling\BreakingChangeDetector.cs (1)
27&& context.Direction == MarshalDirection.UnmanagedToManaged)
Marshalling\CharMarshaller.cs (7)
82MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 89if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 105if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 125MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, context); 126return !IsPinningPathSupported(info, context) && (elementMarshalDirection != MarshalDirection.ManagedToUnmanaged || info.IsByRef);
Marshalling\CustomTypeMarshallingGenerator.cs (17)
28MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(TypeInfo, CodeContext); 36if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional 37|| (CodeContext.Direction == MarshalDirection.UnmanagedToManaged && ShouldGenerateByValueOutMarshalling)) 43if (CodeContext.SingleFrameSpansNativeContext && elementMarshalDirection is MarshalDirection.ManagedToUnmanaged) 49if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 55if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 61if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 67if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional 68|| (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling)) 74if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional 75|| (CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && ShouldGenerateByValueOutMarshalling))
Marshalling\DefaultMarshallingGeneratorResolver.cs (4)
23MarshalDirection direction, 63direction == MarshalDirection.ManagedToUnmanaged 66direction == MarshalDirection.ManagedToUnmanaged 69direction == MarshalDirection.ManagedToUnmanaged
Marshalling\DelegateMarshaller.cs (7)
32MarshalDirection elementMarshalDirection = MarshallerHelpers.GetMarshalDirection(info, codeContext); 39if (elementMarshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional) 58if (elementMarshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 80if (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. 298public static MarshalDirection GetMarshalDirection(TypePositionInfo info, StubCodeContext context) 300if (context.Direction is not (MarshalDirection.ManagedToUnmanaged or MarshalDirection.UnmanagedToManaged)) 305if (context.Direction == MarshalDirection.ManagedToUnmanaged) 309return MarshalDirection.UnmanagedToManaged; 313return MarshalDirection.ManagedToUnmanaged; 319return MarshalDirection.ManagedToUnmanaged; 321return MarshalDirection.Bidirectional; 323return MarshalDirection.UnmanagedToManaged; 331return MarshalDirection.ManagedToUnmanaged; 335return MarshalDirection.UnmanagedToManaged; 341return MarshalDirection.UnmanagedToManaged; 343return MarshalDirection.Bidirectional; 345return MarshalDirection.ManagedToUnmanaged; 358if (context.Direction is MarshalDirection.UnmanagedToManaged) 363MarshalDirection.UnmanagedToManaged => StubIdentifierContext.Stage.CleanupCalleeAllocated, 364MarshalDirection.ManagedToUnmanaged => StubIdentifierContext.Stage.CleanupCallerAllocated, 365MarshalDirection.Bidirectional => StubIdentifierContext.Stage.CleanupCallerAllocated, 375public static void ValidateCountInfoAvailableAtCall(MarshalDirection stubDirection, TypePositionInfo info, GeneratorDiagnosticsBag generatorDiagnostics, IMethodSymbol symbol, DiagnosticDescriptor outParamDescriptor, DiagnosticDescriptor returnValueDescriptor) 379if (stubDirection is MarshalDirection.ManagedToUnmanaged) 471public static bool IsInStubReturnPosition(TypePositionInfo info, MarshalDirection direction) 475MarshalDirection.ManagedToUnmanaged => info.IsManagedReturnPosition, 476MarshalDirection.UnmanagedToManaged => info.IsNativeReturnPosition, 486public static bool IsInInvocationReturnPosition(TypePositionInfo info, MarshalDirection direction) 490MarshalDirection.ManagedToUnmanaged => info.IsNativeReturnPosition, 491MarshalDirection.UnmanagedToManaged => info.IsManagedReturnPosition,
Marshalling\MarshallingGeneratorExtensions.cs (2)
67if (generator.CodeContext.Direction == MarshalDirection.ManagedToUnmanaged) 73else if (generator.CodeContext.Direction == MarshalDirection.UnmanagedToManaged)
StubCodeContext.cs (3)
29MarshalDirection Direction) 34Direction: MarshalDirection.ManagedToUnmanaged); 39Direction: MarshalDirection.UnmanagedToManaged);