From b31ec9f95956e8ef7cdd906bece2faf15bf9a7ec Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 23 Nov 2020 02:01:51 +0100 Subject: [PATCH] Stripped info on parent types in source generator --- .../AutoConstructorAttributeGenerator.cs | 6 +++++- tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs b/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs index 070777ec..972a7e15 100644 --- a/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs @@ -87,7 +87,11 @@ namespace ComputeSharp.SourceGenerators // Add all parent types in ascending order, if any foreach (var parentType in structDeclaration.Ancestors().OfType()) { - typeDeclarationSyntax = parentType.WithMembers(SingletonList(typeDeclarationSyntax)); + typeDeclarationSyntax = parentType + .WithMembers(SingletonList(typeDeclarationSyntax)) + .WithConstraintClauses(List()) + .WithBaseList(null) + .WithoutTrivia(); } // Create the compilation unit with the namespace and target member. diff --git a/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs b/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs index 23e526c0..8ac59224 100644 --- a/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs +++ b/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs @@ -25,11 +25,16 @@ namespace ComputeSharp.Tests.Internals public class Buffer { } + + public interface IFluff + { + } } namespace MyFancyApp.Sample { - public partial interface IFoo + public partial interface IFoo : IFluff + where T : notnull, new() { public partial class Foo {