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

Fully qualify return type on UnreachableException methods #87661

Merged
merged 3 commits into from
Jun 16, 2023
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 @@ -105,6 +105,7 @@ private MethodDeclarationSyntax CreateUnreachableExceptionStub()
{
// DeclarationCopiedFromBaseDeclaration(<Arguments>) => throw new UnreachableException("This method should not be reached");
jtschuster marked this conversation as resolved.
Show resolved Hide resolved
return MethodInfo.Syntax
.WithReturnType(GenerationContext.SignatureContext.StubReturnType)
.WithModifiers(TokenList())
.WithAttributeLists(List<AttributeListSyntax>())
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,33 @@ partial interface {|#0:IComInterface2|} : IComInterface, IOtherComInterface
}
""";

public string DerivedWithParametersDeclaredInOtherNamespace => $$"""
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using OtherNS;

namespace OtherNS
{
public struct NewType;
}

namespace Test
{
{{GeneratedComInterface()}}
partial interface IComInterface
{
NewType Method(NewType p);
}

{{GeneratedComInterface()}}
partial interface IComInterface2 : IComInterface
{
NewType Method2(NewType p);
}
}
""";

public string DerivedWithStringMarshalling(params
(StringMarshalling StringMarshalling, Type? StringMarshallingCustomType)[] attributeArguments)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
using System.Threading.Tasks;
using Microsoft.Interop.UnitTests;
using Xunit;

using VerifyVTableGenerator = Microsoft.Interop.UnitTests.Verifiers.CSharpSourceGeneratorVerifier<Microsoft.Interop.VtableIndexStubGenerator>;
using VerifyComInterfaceGenerator = Microsoft.Interop.UnitTests.Verifiers.CSharpSourceGeneratorVerifier<Microsoft.Interop.ComInterfaceGenerator>;
using VerifyVTableGenerator = Microsoft.Interop.UnitTests.Verifiers.CSharpSourceGeneratorVerifier<Microsoft.Interop.VtableIndexStubGenerator>;

namespace ComInterfaceGenerator.Unit.Tests
{
Expand Down Expand Up @@ -334,6 +333,7 @@ public static IEnumerable<object[]> ComInterfaceSnippetsToCompile()
{
CodeSnippets codeSnippets = new(new GeneratedComInterfaceAttributeProvider());
yield return new object[] { ID(), codeSnippets.DerivedComInterfaceType };
yield return new object[] { ID(), codeSnippets.DerivedWithParametersDeclaredInOtherNamespace };
yield return new object[] { ID(), codeSnippets.ComInterfaceParameters };
}

Expand Down