121 references to Stage
Microsoft.Interop.ComInterfaceGenerator (7)
Marshallers\ComInterfaceDispatchMarshallingResolver.cs (1)
36
if (context.CurrentStage != StubIdentifierContext.
Stage
.Unmarshal)
Marshallers\KeepAliveThisMarshaller.cs (1)
13
if (context.CurrentStage != StubIdentifierContext.
Stage
.NotifyForSuccessfulInvoke)
Marshallers\ManagedHResultExceptionGeneratorResolver.cs (2)
37
if (context.CurrentStage != StubIdentifierContext.
Stage
.Unmarshal)
62
if (context.CurrentStage != StubIdentifierContext.
Stage
.Unmarshal)
Marshallers\ObjectUnwrapperResolver.cs (1)
33
if (context.CurrentStage != StubIdentifierContext.
Stage
.Unmarshal)
Marshallers\StructAsHResultMarshallerFactory.cs (2)
33
case StubIdentifierContext.
Stage
.Marshal:
39
case StubIdentifierContext.
Stage
.Unmarshal:
Microsoft.Interop.JavaScript.JSImportGenerator (12)
Marshaling\BaseJSGenerator.cs (1)
33
if (context.CurrentStage == StubIdentifierContext.
Stage
.Setup
Marshaling\FuncJSGenerator.cs (4)
18
&& ((context.CurrentStage == StubIdentifierContext.
Stage
.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)
19
|| (context.CurrentStage == StubIdentifierContext.
Stage
.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged)))
25
&& ((context.CurrentStage == StubIdentifierContext.
Stage
.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged)
26
|| (context.CurrentStage == StubIdentifierContext.
Stage
.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)))
Marshaling\ImplicitArgumentGenerator.cs (1)
10
if (context.CurrentStage == StubIdentifierContext.
Stage
.Setup)
Marshaling\PrimitiveJSGenerator.cs (2)
19
if (context.CurrentStage == StubIdentifierContext.
Stage
.UnmarshalCapture && marshalDirection is MarshalDirection.UnmanagedToManaged or MarshalDirection.Bidirectional)
24
if (context.CurrentStage == StubIdentifierContext.
Stage
.Marshal && marshalDirection is MarshalDirection.ManagedToUnmanaged or MarshalDirection.Bidirectional)
Marshaling\TaskJSGenerator.cs (4)
17
&& ((context.CurrentStage == StubIdentifierContext.
Stage
.UnmarshalCapture && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)
18
|| (context.CurrentStage == StubIdentifierContext.
Stage
.Unmarshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged)))
24
&& ((context.CurrentStage == StubIdentifierContext.
Stage
.Marshal && CodeContext.Direction == MarshalDirection.UnmanagedToManaged)
25
|| (context.CurrentStage == StubIdentifierContext.
Stage
.PinnedMarshal && CodeContext.Direction == MarshalDirection.ManagedToUnmanaged)))
Microsoft.Interop.SourceGeneration (102)
GeneratedStatements.cs (33)
33
Setup = GenerateStage(StubIdentifierContext.
Stage
.Setup),
34
Marshal = GenerateStage(StubIdentifierContext.
Stage
.Marshal),
35
Pin = GenerateStage(StubIdentifierContext.
Stage
.Pin),
36
PinnedMarshal = GenerateStage(StubIdentifierContext.
Stage
.PinnedMarshal),
38
ErrorUnmarshalCapture = GenerateStage(StubIdentifierContext.
Stage
.UnmarshalCapture, errorHandlingOnly: true),
39
ErrorUnmarshal = GenerateStage(StubIdentifierContext.
Stage
.Unmarshal, errorHandlingOnly: true),
40
Unmarshal = GenerateStage(StubIdentifierContext.
Stage
.UnmarshalCapture) + GenerateStage(StubIdentifierContext.
Stage
.Unmarshal),
41
NotifyForSuccessfulInvoke = GenerateStage(StubIdentifierContext.
Stage
.NotifyForSuccessfulInvoke),
42
GuaranteedUnmarshal = GenerateStage(StubIdentifierContext.
Stage
.GuaranteedUnmarshal),
43
ErrorCleanupCalleeAllocated = GenerateStage(StubIdentifierContext.
Stage
.CleanupCalleeAllocated, errorHandlingOnly: true),
44
CleanupCallerAllocated = GenerateStage(StubIdentifierContext.
Stage
.CleanupCallerAllocated),
45
CleanupCalleeAllocated = GenerateStage(StubIdentifierContext.
Stage
.CleanupCalleeAllocated),
49
string GenerateStage(StubIdentifierContext.
Stage
stage, bool errorHandlingOnly = false)
55
if (stage is StubIdentifierContext.
Stage
.UnmarshalCapture
56
or StubIdentifierContext.
Stage
.Unmarshal
57
or StubIdentifierContext.
Stage
.CleanupCalleeAllocated
73
StubIdentifierContext invokeContext = context with { CurrentStage = StubIdentifierContext.
Stage
.Invoke };
92
StubIdentifierContext invokeContext = context with { CurrentStage = StubIdentifierContext.
Stage
.Invoke };
148
marshaller.Generate(writer, context with { CurrentStage = StubIdentifierContext.
Stage
.Marshal });
149
marshaller.Generate(writer, context with { CurrentStage = StubIdentifierContext.
Stage
.PinnedMarshal });
154
private static string GetStageDescription(StubIdentifierContext.
Stage
stage)
158
StubIdentifierContext.
Stage
.Setup => "Perform required setup.",
159
StubIdentifierContext.
Stage
.Marshal => "Convert managed data to native data.",
160
StubIdentifierContext.
Stage
.Pin => "Pin data in preparation for calling the P/Invoke.",
161
StubIdentifierContext.
Stage
.PinnedMarshal => "Convert managed data to native data that requires the managed data to be pinned.",
162
StubIdentifierContext.
Stage
.Invoke => "Call the P/Invoke.",
163
StubIdentifierContext.
Stage
.UnmarshalCapture => "Capture the native data into marshaller instances in case conversion to managed data throws an exception.",
164
StubIdentifierContext.
Stage
.Unmarshal => "Convert native data to managed data.",
165
StubIdentifierContext.
Stage
.CleanupCallerAllocated => "Perform cleanup of caller allocated resources.",
166
StubIdentifierContext.
Stage
.CleanupCalleeAllocated => "Perform cleanup of callee allocated resources.",
167
StubIdentifierContext.
Stage
.NotifyForSuccessfulInvoke => "Keep alive any managed objects that need to stay alive across the call.",
168
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)
40
if (context.CurrentStage == StubIdentifierContext.
Stage
.Pin)
51
case StubIdentifierContext.
Stage
.Setup:
53
case StubIdentifierContext.
Stage
.Marshal:
60
case StubIdentifierContext.
Stage
.Unmarshal:
Marshalling\BoolMarshaller.cs (3)
51
case StubIdentifierContext.
Stage
.Setup:
53
case StubIdentifierContext.
Stage
.Marshal:
61
case StubIdentifierContext.
Stage
.Unmarshal:
Marshalling\CharMarshaller.cs (5)
48
if (context.CurrentStage == StubIdentifierContext.
Stage
.Pin)
52
else if (context.CurrentStage == StubIdentifierContext.
Stage
.PinnedMarshal)
65
case StubIdentifierContext.
Stage
.Setup:
67
case StubIdentifierContext.
Stage
.Marshal:
79
case StubIdentifierContext.
Stage
.Unmarshal:
Marshalling\CustomTypeMarshallingGenerator.cs (10)
29
case StubIdentifierContext.
Stage
.Setup:
32
case StubIdentifierContext.
Stage
.Marshal:
39
case StubIdentifierContext.
Stage
.Pin:
45
case StubIdentifierContext.
Stage
.PinnedMarshal:
51
case StubIdentifierContext.
Stage
.NotifyForSuccessfulInvoke:
57
case StubIdentifierContext.
Stage
.UnmarshalCapture:
63
case StubIdentifierContext.
Stage
.Unmarshal:
70
case StubIdentifierContext.
Stage
.GuaranteedUnmarshal:
77
case StubIdentifierContext.
Stage
.CleanupCallerAllocated:
80
case StubIdentifierContext.
Stage
.CleanupCalleeAllocated:
Marshalling\DelegateMarshaller.cs (4)
29
case StubIdentifierContext.
Stage
.Setup:
31
case StubIdentifierContext.
Stage
.Marshal:
38
case StubIdentifierContext.
Stage
.Unmarshal:
45
case StubIdentifierContext.
Stage
.NotifyForSuccessfulInvoke:
Marshalling\ElementsMarshalling.cs (20)
169
GenerateContentsMarshallingStatement(writer, context, $"{managedSpanIdentifier}.Length", elementMarshaller, StubIdentifierContext.
Stage
.Marshal);
183
StubIdentifierContext.
Stage
.UnmarshalCapture, StubIdentifierContext.
Stage
.Unmarshal);
200
StubIdentifierContext.
Stage
.UnmarshalCapture, StubIdentifierContext.
Stage
.Unmarshal);
240
StubIdentifierContext.
Stage
[] stagesToGenerate;
244
stagesToGenerate = [StubIdentifierContext.
Stage
.Marshal, StubIdentifierContext.
Stage
.PinnedMarshal];
248
stagesToGenerate = [StubIdentifierContext.
Stage
.Marshal, StubIdentifierContext.
Stage
.PinnedMarshal, StubIdentifierContext.
Stage
.CleanupCallerAllocated, StubIdentifierContext.
Stage
.CleanupCalleeAllocated];
266
params StubIdentifierContext.
Stage
[] stagesToGeneratePerElement)
278
CurrentStage = StubIdentifierContext.
Stage
.Setup,
293
foreach (StubIdentifierContext.
Stage
stage in stagesToGeneratePerElement)
310
elementMarshaller.Generate(writer, identifierContext with { CurrentStage = StubIdentifierContext.
Stage
.Setup });
314
&& stagesToGeneratePerElement.Any(stage => stage is StubIdentifierContext.
Stage
.Marshal or StubIdentifierContext.
Stage
.PinnedMarshal))
325
params StubIdentifierContext.
Stage
[] stagesToGeneratePerElement)
336
&& stagesToGeneratePerElement.Contains(StubIdentifierContext.
Stage
.Marshal))
Marshalling\IidParameterIndexMarshallerResolver.cs (1)
35
if (context.CurrentStage != StubIdentifierContext.
Stage
.Marshal)
Marshalling\MarshallerHelpers.cs (5)
313
public static StubIdentifierContext.
Stage
GetCleanupStage(TypePositionInfo info, StubCodeContext context)
319
return StubIdentifierContext.
Stage
.CleanupCallerAllocated;
323
MarshalDirection.UnmanagedToManaged => StubIdentifierContext.
Stage
.CleanupCalleeAllocated,
324
MarshalDirection.ManagedToUnmanaged => StubIdentifierContext.
Stage
.CleanupCallerAllocated,
325
MarshalDirection.Bidirectional => StubIdentifierContext.
Stage
.CleanupCallerAllocated,
Marshalling\StatefulMarshallingStrategy.cs (4)
17
if (MarshallerHelpers.GetCleanupStage(info, stubContext) is StubIdentifierContext.
Stage
.CleanupCallerAllocated
26
if (MarshallerHelpers.GetCleanupStage(info, stubContext) is StubIdentifierContext.
Stage
.CleanupCalleeAllocated
289
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCallerAllocated)
298
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCalleeAllocated)
Marshalling\StatelessMarshallingStrategy.cs (6)
139
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.
Stage
.CleanupCallerAllocated)
150
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.
Stage
.CleanupCalleeAllocated)
181
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCallerAllocated
191
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCalleeAllocated
346
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCallerAllocated)
371
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is StubIdentifierContext.
Stage
.CleanupCallerAllocated)
Marshalling\StaticPinnableManagedValueMarshaller.cs (1)
66
if (context.CurrentStage == StubIdentifierContext.
Stage
.Pin)
Marshalling\UnmanagedToManagedOwnershipTrackingStrategy.cs (4)
55
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.
Stage
.CleanupCallerAllocated)
69
if (MarshallerHelpers.GetCleanupStage(TypeInfo, CodeContext) is not StubIdentifierContext.
Stage
.CleanupCalleeAllocated)
105
if (context.CurrentStage == StubIdentifierContext.
Stage
.Setup)
112
inner.Generate(writer, context.CurrentStage == StubIdentifierContext.
Stage
.CleanupCallerAllocated
StubIdentifierContext.cs (2)
86
public
Stage
CurrentStage { get; init; } =
Stage
.Invalid;