Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -363,7 +363,7 @@ internal static IncrementalMethodStubGenerationContext CalculateStubInformation(

var containingSyntaxContext = new ContainingSyntaxContext(syntax);
var methodSyntaxTemplate = new ContainingSyntax(
new SyntaxTokenList(syntax.Modifiers.Where(static m => !m.IsKind(SyntaxKind.NewKeyword))).StripAccessibilityModifiers(),
new SyntaxTokenList(syntax.Modifiers.Where(static m => !m.IsKind(SyntaxKind.NewKeyword) && !m.IsKind(SyntaxKind.PartialKeyword))).StripAccessibilityModifiers(),
SyntaxKind.MethodDeclaration,
syntax.Identifier,
syntax.TypeParameterList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ internal static SourceAvailableIncrementalMethodStubGenerationContext CalculateS

var containingSyntaxContext = new ContainingSyntaxContext(syntax);

var methodSyntaxTemplate = new ContainingSyntax(syntax.Modifiers.StripAccessibilityModifiers(), SyntaxKind.MethodDeclaration, syntax.Identifier, syntax.TypeParameterList);
var methodSyntaxTemplate = new ContainingSyntax(new SyntaxTokenList(syntax.Modifiers.Where(static m => !m.IsKind(SyntaxKind.PartialKeyword))).StripAccessibilityModifiers(), SyntaxKind.MethodDeclaration, syntax.Identifier, syntax.TypeParameterList);
Comment thread
jtschuster marked this conversation as resolved.
Outdated

ImmutableArray<FunctionPointerUnmanagedCallingConventionSyntax> callConv = VirtualMethodPointerStubGenerator.GenerateCallConvSyntaxFromAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute, defaultCallingConventions: ImmutableArray<FunctionPointerUnmanagedCallingConventionSyntax>.Empty);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,36 @@ public async Task ValidateComInterfaceSnippets(string id, string source)
await VerifyComInterfaceGenerator.VerifySourceGeneratorAsync(source);
}

[Fact]
public async Task PartialMethodModifierOnComInterfaceMethodCompiles()
{
string source = """
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;

[GeneratedComInterface]
[Guid("9D3FD745-3C90-4C10-B140-FAFB01E3541D")]
internal partial interface IComInterface
{
void Method();
public partial void PartialMethod();
}
internal partial interface IComInterface
{
public partial void PartialMethod() { }
}
Comment thread
jtschuster marked this conversation as resolved.
""";

// CS0539 is expected because the partial method's default implementation
Comment thread
jtschuster marked this conversation as resolved.
Outdated
// conflicts with the generated explicit interface implementation.
// The important verification is that no additional errors are produced
// from the 'partial' modifier being incorrectly copied to generated code.
await VerifyComInterfaceGenerator.VerifySourceGeneratorAsync(source,
DiagnosticResult.CompilerError("CS0539")
.WithSpan("Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/IComInterface.cs", 78, 32, 78, 45)
.WithArguments("InterfaceImplementation.PartialMethod()"));
Comment thread
jtschuster marked this conversation as resolved.
Outdated
}

[Fact]
public async Task DocumentedComInterfaceDoesNotProduceCS1591Warnings()
{
Expand Down
Loading