Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a source generator for invoking methods on unmanaged vtables #68276

Merged
merged 40 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
de8d813
WIP for generating stubs for manual vtable entrypoints.
jkoritzinsky Apr 13, 2022
4e23511
Fix up some names and actually parse the right attribute.
jkoritzinsky Apr 14, 2022
6b6020a
Update ComInterfaceGenerator to not pass syntax around
jkoritzinsky Apr 14, 2022
ac354c6
Move TestUtils to a shared location and get our first test unit test …
jkoritzinsky Apr 19, 2022
2af787c
Add some tests around calling convention handling.
jkoritzinsky Apr 19, 2022
6d7327b
Add tests for the emitted native interface type shape
jkoritzinsky Apr 19, 2022
b9f3597
Add some basic marshalling tests to give some validation that we set …
jkoritzinsky Apr 19, 2022
7caa3c7
Add design doc, update API name, remove scratch pad
jkoritzinsky Apr 20, 2022
6e7e119
Fix build and run
jkoritzinsky May 13, 2022
f862f15
Fix markdownlint failures
jkoritzinsky May 13, 2022
09dc2c4
infra fixes for ComInterfaceGenerator test runs
jkoritzinsky May 13, 2022
a83b092
Add more tests
jkoritzinsky May 13, 2022
faa674e
Exclude ComInterfaceGenerator on mobile platforms
jkoritzinsky May 16, 2022
a55e337
Add basic runtime tests
jkoritzinsky May 16, 2022
7e92bd4
Remove extraneous diagnostic
jkoritzinsky May 26, 2022
f54bd51
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky May 26, 2022
d95cdac
PR feedback
jkoritzinsky Jun 7, 2022
2e2809a
Merge branch 'main' into vtable-stubs
jkoritzinsky Jun 7, 2022
8fef109
Fix build break
jkoritzinsky Jun 9, 2022
7736687
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky Jul 13, 2022
794c4cf
Get the generator up to date with our newer designs and increase the …
jkoritzinsky Jul 14, 2022
5627e53
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky Aug 24, 2022
a958552
Use static abstracts instead of partial + containing class to define …
jkoritzinsky Aug 24, 2022
7182f4b
Use MarshalDirection type in generators and update design doc
jkoritzinsky Aug 25, 2022
9ca69dd
Use static-abstracts + DIMs to remove the extra shape validation.
jkoritzinsky Aug 25, 2022
5746f8b
Fix JS generator test build
jkoritzinsky Aug 29, 2022
032ebff
Fix exclusions
jkoritzinsky Aug 31, 2022
8ac684c
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky Aug 31, 2022
fbe5edf
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky Sep 2, 2022
d964d0c
Fix exclusions of runtime tests
jkoritzinsky Sep 2, 2022
bf8485a
Disable runtime tests on Mono because Mono doesn't implement an API t…
jkoritzinsky Sep 3, 2022
7fc5e52
Fix test disable to work in the normal runtime pipeline, albeit not p…
jkoritzinsky Sep 6, 2022
2868df2
Merge branch 'main' into vtable-stubs
jkoritzinsky Sep 10, 2022
19a5b01
Merge branch 'main' of github.com:dotnet/runtime into vtable-stubs
jkoritzinsky Sep 23, 2022
3008cd5
Directly pass along target framework kind and version instead of Stub…
jkoritzinsky Sep 24, 2022
1d8bd6a
Use a wrapper struct to make using elementwise equality for immutable…
jkoritzinsky Sep 29, 2022
229f45a
Merge branch 'main' into vtable-stubs
jkoritzinsky Sep 29, 2022
4f89920
Merge branch 'main' into vtable-stubs
jkoritzinsky Oct 7, 2022
d403851
Fix build
jkoritzinsky Oct 7, 2022
1e890d4
Update the generator entry-point and the project file based on change…
jkoritzinsky Oct 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
413 changes: 413 additions & 0 deletions docs/design/libraries/ComInterfaceGenerator/VTableStubs.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eng/testing/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TestRunRequiresLiveRefPack)' == 'true'">
<None Include="$(MicrosoftNetCoreAppRefPackRefDir)**/*.dll" CopyToOutputDirectory="PreserveNewest" LinkBase="live-ref-pack/" Visible="false" />
<None Include="$(MicrosoftNetCoreAppRefPackRefDir)**/*.dll" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" LinkBase="live-ref-pack/" Visible="false" />
</ItemGroup>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal sealed record JSImportCodeContext : JSStubCodeContext
public JSImportCodeContext(JSImportData attributeData, StubCodeContext inner)
{
_inner = inner;
Direction = CustomTypeMarshallingDirection.In;
Direction = MarshalDirection.ManagedToUnmanaged;
AttributeData = attributeData;
}

Expand All @@ -37,7 +37,7 @@ internal sealed record JSExportCodeContext : JSStubCodeContext
public JSExportCodeContext(JSExportData attributeData, StubCodeContext inner)
{
_inner = inner;
Direction = CustomTypeMarshallingDirection.Out;
Direction = MarshalDirection.UnmanagedToManaged;
AttributeData = attributeData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
.Select(a => a.Syntax)
.ToArray();

if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == CustomTypeMarshallingDirection.In && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition)
{
yield return ToManagedMethod(target, source, jsty);
}

if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == CustomTypeMarshallingDirection.Out && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition)
{
yield return ToJSMethod(target, source, jsty);
}
Expand All @@ -68,12 +68,12 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
yield return x;
}

if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == CustomTypeMarshallingDirection.In && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition)
{
yield return ToJSMethod(target, source, jsty);
}

if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == CustomTypeMarshallingDirection.Out && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition)
{
yield return ToManagedMethod(target, source, jsty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
? Argument(IdentifierName(context.GetIdentifiers(info).native))
: _inner.AsArgument(info, context);

if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == CustomTypeMarshallingDirection.In && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition)
{
yield return ToManagedMethod(target, source);
}

if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == CustomTypeMarshallingDirection.Out && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition)
{
yield return ToJSMethod(target, source);
}
Expand All @@ -47,12 +47,12 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
yield return x;
}

if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == CustomTypeMarshallingDirection.In && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition)
{
yield return ToJSMethod(target, source);
}

if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == CustomTypeMarshallingDirection.Out && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition)
{
yield return ToManagedMethod(target, source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
? Argument(IdentifierName(context.GetIdentifiers(info).native))
: _inner.AsArgument(info, context);

if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == CustomTypeMarshallingDirection.In && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.UnmarshalCapture && context.Direction == MarshalDirection.ManagedToUnmanaged && info.IsManagedReturnPosition)
{
yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)
? ToManagedMethodVoid(target, source)
: ToManagedMethod(target, source, jsty.ResultTypeInfo.Syntax);
}

if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == CustomTypeMarshallingDirection.Out && info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Marshal && context.Direction == MarshalDirection.UnmanagedToManaged && info.IsManagedReturnPosition)
{
yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)
? ToJSMethodVoid(target, source)
Expand All @@ -64,14 +64,14 @@ public override IEnumerable<StatementSyntax> Generate(TypePositionInfo info, Stu
yield return x;
}

if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == CustomTypeMarshallingDirection.In && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.PinnedMarshal && context.Direction == MarshalDirection.ManagedToUnmanaged && !info.IsManagedReturnPosition)
{
yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)
? ToJSMethodVoid(target, source)
: ToJSMethod(target, source, jsty.ResultTypeInfo.Syntax);
}

if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == CustomTypeMarshallingDirection.Out && !info.IsManagedReturnPosition)
if (context.CurrentStage == StubCodeContext.Stage.Unmarshal && context.Direction == MarshalDirection.UnmanagedToManaged && !info.IsManagedReturnPosition)
{
yield return jsty.ResultTypeInfo is JSSimpleTypeInfo(KnownManagedType.Void)
? ToManagedMethodVoid(target, source)
Expand Down
Loading