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

Don't generate Unmanaged-to-Managed stubs with diagnostics #88679

Merged
merged 5 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ private static InterfaceDeclarationSyntax GenerateImplementationVTableMethods(Co
comInterfaceAndMethods.DeclaredMethods
.Select(m => m.UnmanagedToManagedStub)
.OfType<GeneratedStubCodeContext>()
.Where(context => context.Diagnostics.All(diag => diag.Descriptor.DefaultSeverity != DiagnosticSeverity.Error))
.Select(context => context.Stub.Node)));
}

Expand All @@ -436,7 +437,6 @@ private static InterfaceDeclarationSyntax GenerateImplementationVTable(ComInterf

const string vtableLocalName = "vtable";
var interfaceType = interfaceMethods.Interface.Info.Type;
var interfaceMethodStubs = interfaceMethods.DeclaredMethods.Select(m => m.GenerationContext);

// void** vtable = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(<interfaceType>, sizeof(void*) * <max(vtableIndex) + 1>);
var vtableDeclarationStatement =
Expand Down Expand Up @@ -577,7 +577,11 @@ private static InterfaceDeclarationSyntax GenerateImplementationVTable(ComInterf
})))));
}

var vtableSlotAssignments = VirtualMethodPointerStubGenerator.GenerateVirtualMethodTableSlotAssignments(interfaceMethodStubs, vtableLocalName);
var vtableSlotAssignments = VirtualMethodPointerStubGenerator.GenerateVirtualMethodTableSlotAssignments(
interfaceMethods.DeclaredMethods
.Where(context => context.UnmanagedToManagedStub.Diagnostics.All(diag => diag.Descriptor.DefaultSeverity != DiagnosticSeverity.Error))
.Select(context => context.GenerationContext),
vtableLocalName);

return ImplementationInterfaceTemplate
.AddMembers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ public async Task ValidateInvalidUnmanagedToManagedCodeSnippets(string id, strin
{
TestCode = source,
TestBehaviors = TestBehaviors.SkipGeneratedSourcesCheck,
// Our fallback mechanism for invalid code for unmanaged->managed stubs sometimes generates invalid code.
CompilerDiagnostics = CompilerDiagnostics.None,
};
test.ExpectedDiagnostics.AddRange(expectedDiagnostics);
await test.RunAsync();
Expand Down
Loading