118 references to Stage
Microsoft.Interop.ComInterfaceGenerator (7)
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (1)
42if (context.CurrentStage != StubIdentifierContext.Stage.Unmarshal)
Marshallers\KeepAliveThisMarshaller.cs (1)
20if (context.CurrentStage != StubIdentifierContext.Stage.NotifyForSuccessfulInvoke)
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
42if (context.CurrentStage != StubIdentifierContext.Stage.NotifyForSuccessfulInvoke) 70if (context.CurrentStage != StubIdentifierContext.Stage.NotifyForSuccessfulInvoke)
Marshallers\ObjectUnwrapperResolver.cs (1)
38if (context.CurrentStage != StubIdentifierContext.Stage.Unmarshal)
Marshallers\StructAsHResultMarshallerFactory.cs (2)
38case StubIdentifierContext.Stage.Marshal: 56case StubIdentifierContext.Stage.Unmarshal:
Microsoft.Interop.JavaScript.JSImportGenerator (12)
Marshaling\BaseJSGenerator.cs (1)
40if (context.CurrentStage == StubIdentifierContext.Stage.Setup
Marshaling\FuncJSGenerator.cs (4)
30if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) 35if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) 40if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) 45if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Marshaling\ImplicitArgumentGenerator.cs (1)
19if (context.CurrentStage == StubIdentifierContext.Stage.Setup)
Marshaling\PrimitiveJSGenerator.cs (2)
26if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && marshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional) 31if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && marshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional)
Marshaling\TaskJSGenerator.cs (4)
25if (context.CurrentStage == StubIdentifierContext.Stage.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && TypeInfo.IsManagedReturnPosition) 32if (context.CurrentStage == StubIdentifierContext.Stage.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && TypeInfo.IsManagedReturnPosition) 39if (context.CurrentStage == StubIdentifierContext.Stage.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged && !TypeInfo.IsManagedReturnPosition) 46if (context.CurrentStage == StubIdentifierContext.Stage.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged && !TypeInfo.IsManagedReturnPosition)
Microsoft.Interop.SourceGeneration (99)
GeneratedStatements.cs (28)
33Setup = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Setup }), 34Marshal = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Marshal }), 35Pin = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Pin }).Cast<FixedStatementSyntax>().ToImmutableArray(), 36PinnedMarshal = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.PinnedMarshal }), 38Unmarshal = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.UnmarshalCapture }) 39.AddRange(GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Unmarshal })), 40NotifyForSuccessfulInvoke = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.NotifyForSuccessfulInvoke }), 41GuaranteedUnmarshal = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.GuaranteedUnmarshal }), 42CleanupCallerAllocated = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.CleanupCallerAllocated }), 43CleanupCalleeAllocated = GenerateStatementsForStubContext(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.CleanupCalleeAllocated }), 56InvokeStatement = GenerateStatementForNativeInvoke(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Invoke }, expressionToInvoke) 63InvokeStatement = GenerateStatementForManagedInvoke(marshallers, context with { CurrentStage = StubIdentifierContext.Stage.Invoke }, expressionToInvoke) 93if (context.CurrentStage != StubIdentifierContext.Stage.Invoke) 127if (context.CurrentStage != StubIdentifierContext.Stage.Invoke) 165managedExceptionMarshaller.Generate(context with { CurrentStage = StubIdentifierContext.Stage.Marshal })); 167managedExceptionMarshaller.Generate(context with { CurrentStage = StubIdentifierContext.Stage.PinnedMarshal })); 175private static SyntaxTriviaList GenerateStageTrivia(StubIdentifierContext.Stage stage) 179StubIdentifierContext.Stage.Setup => "Perform required setup.", 180StubIdentifierContext.Stage.Marshal => "Convert managed data to native data.", 181StubIdentifierContext.Stage.Pin => "Pin data in preparation for calling the P/Invoke.", 182StubIdentifierContext.Stage.PinnedMarshal => "Convert managed data to native data that requires the managed data to be pinned.", 183StubIdentifierContext.Stage.Invoke => "Call the P/Invoke.", 184StubIdentifierContext.Stage.UnmarshalCapture => "Capture the native data into marshaller instances in case conversion to managed data throws an exception.", 185StubIdentifierContext.Stage.Unmarshal => "Convert native data to managed data.", 186StubIdentifierContext.Stage.CleanupCallerAllocated => "Perform cleanup of caller allocated resources.", 187StubIdentifierContext.Stage.CleanupCalleeAllocated => "Perform cleanup of callee allocated resources.", 188StubIdentifierContext.Stage.NotifyForSuccessfulInvoke => "Keep alive any managed objects that need to stay alive across the call.", 189StubIdentifierContext.Stage.GuaranteedUnmarshal => "Convert native data to managed data even in the case of an exception during the non-cleanup phases.",
Marshalling\BlittableMarshaller.cs (4)
46if (context.CurrentStage == StubIdentifierContext.Stage.Pin) 69case StubIdentifierContext.Stage.Setup: 71case StubIdentifierContext.Stage.Marshal: 82case StubIdentifierContext.Stage.Unmarshal:
Marshalling\BoolMarshaller.cs (3)
56case StubIdentifierContext.Stage.Setup: 58case StubIdentifierContext.Stage.Marshal: 75case StubIdentifierContext.Stage.Unmarshal:
Marshalling\CharMarshaller.cs (4)
53if (context.CurrentStage == StubIdentifierContext.Stage.Pin) 86case StubIdentifierContext.Stage.Setup: 88case StubIdentifierContext.Stage.Marshal: 104case StubIdentifierContext.Stage.Unmarshal:
Marshalling\CustomTypeMarshallingGenerator.cs (10)
33case StubIdentifierContext.Stage.Setup: 35case StubIdentifierContext.Stage.Marshal: 42case StubIdentifierContext.Stage.Pin: 48case StubIdentifierContext.Stage.PinnedMarshal: 54case StubIdentifierContext.Stage.NotifyForSuccessfulInvoke: 60case StubIdentifierContext.Stage.UnmarshalCapture: 66case StubIdentifierContext.Stage.Unmarshal: 73case StubIdentifierContext.Stage.GuaranteedUnmarshal: 80case StubIdentifierContext.Stage.CleanupCallerAllocated: 82case StubIdentifierContext.Stage.CleanupCalleeAllocated:
Marshalling\DelegateMarshaller.cs (4)
36case StubIdentifierContext.Stage.Setup: 38case StubIdentifierContext.Stage.Marshal: 57case StubIdentifierContext.Stage.Unmarshal: 79case StubIdentifierContext.Stage.NotifyForSuccessfulInvoke:
Marshalling\ElementsMarshalling.cs (20)
290StubIdentifierContext.Stage.Marshal)); 316StubIdentifierContext.Stage.UnmarshalCapture, StubIdentifierContext.Stage.Unmarshal)); 361StubIdentifierContext.Stage.UnmarshalCapture, StubIdentifierContext.Stage.Unmarshal)); 445StubIdentifierContext.Stage[] stagesToGenerate; 450stagesToGenerate = [StubIdentifierContext.Stage.Marshal, StubIdentifierContext.Stage.PinnedMarshal]; 454stagesToGenerate = [StubIdentifierContext.Stage.Marshal, StubIdentifierContext.Stage.PinnedMarshal, StubIdentifierContext.Stage.CleanupCallerAllocated, StubIdentifierContext.Stage.CleanupCalleeAllocated]; 472params StubIdentifierContext.Stage[] stagesToGeneratePerElement) 484CurrentStage = StubIdentifierContext.Stage.Setup, 501foreach (StubIdentifierContext.Stage stage in stagesToGeneratePerElement) 513elementStatements.InsertRange(0, elementMarshaller.Generate(identifierContext with { CurrentStage = StubIdentifierContext.Stage.Setup })); 536if (stagesToGeneratePerElement.Any(stage => stage is StubIdentifierContext.Stage.Marshal or StubIdentifierContext.Stage.PinnedMarshal)) 562params StubIdentifierContext.Stage[] stagesToGeneratePerElement) 574if (UsesLastIndexMarshalled(CollectionSource.TypeInfo, CollectionSource.CodeContext) && stagesToGeneratePerElement.Contains(StubIdentifierContext.Stage.Marshal))
Marshalling\MarshallerHelpers.cs (5)
326public static StubIdentifierContext.Stage GetCleanupStage(TypePositionInfo info, StubCodeContext context) 332return StubIdentifierContext.Stage.CleanupCallerAllocated; 336MarshalDirection.UnmanagedToManaged => StubIdentifierContext.Stage.CleanupCalleeAllocated, 337MarshalDirection.ManagedToUnmanaged => StubIdentifierContext.Stage.CleanupCallerAllocated, 338MarshalDirection.Bidirectional => StubIdentifierContext.Stage.CleanupCallerAllocated,
Marshalling\MarshallingGenerator.cs (2)
120/// For <see cref="StubIdentifierContext.Stage.Pin"/>, any statements not of type 229/// For <see cref="StubIdentifierContext.Stage.Pin"/>, any statements not of type
Marshalling\StatefulMarshallingStrategy.cs (4)
27if (MarshallerHelpers.GetCleanupStage(info, stubContext) is not StubIdentifierContext.Stage.CleanupCallerAllocated) 41if (MarshallerHelpers.GetCleanupStage(info, stubContext) is not StubIdentifierContext.Stage.CleanupCalleeAllocated) 481if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCallerAllocated) 498if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCalleeAllocated)
Marshalling\StatelessMarshallingStrategy.cs (6)
259if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCallerAllocated) 278if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCalleeAllocated) 319if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCallerAllocated) 337if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCalleeAllocated) 607if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.Stage.CleanupCallerAllocated) 640if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.Stage.CleanupCallerAllocated)
Marshalling\StaticPinnableManagedValueMarshaller.cs (1)
74if (context.CurrentStage == StubIdentifierContext.Stage.Pin)
Marshalling\UnmanagedToManagedOwnershipTrackingStrategy.cs (6)
80/// in the <see cref="StubIdentifierContext.Stage.CleanupCallerAllocated"/> stage. 94if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCallerAllocated) 107if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.Stage.CleanupCalleeAllocated) 134/// Useful in scenarios where the value is always owned in all code-paths that reach the <see cref="StubIdentifierContext.Stage.CleanupCallerAllocated"/> stage, so additional ownership tracking is extraneous. 151if (context.CurrentStage == StubIdentifierContext.Stage.Setup) 156if (context.CurrentStage == StubIdentifierContext.Stage.CleanupCallerAllocated)
StubIdentifierContext.cs (2)
86public Stage CurrentStage { get; init; } = Stage.Invalid;