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