From 939a4b1186455ae8485f3d0c70e040087c929278 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 23 Nov 2020 01:19:52 +0100 Subject: [PATCH] Fixed source generator with nested namespaces --- .../AutoConstructorAttributeGenerator.cs | 3 ++- tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs b/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs index 25d38475..78716f52 100644 --- a/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/AutoConstructorAttributeGenerator.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Microsoft.CodeAnalysis.SymbolDisplayTypeQualificationStyle; namespace ComputeSharp.SourceGenerators { @@ -51,7 +52,7 @@ namespace ComputeSharp.SourceGenerators INamedTypeSymbol structDeclarationSymbol = semanticModel.GetDeclaredSymbol(structDeclaration)!; // Extract the info on the type to process - var namespaceName = structDeclarationSymbol.ContainingNamespace.Name; + var namespaceName = structDeclarationSymbol.ContainingNamespace.ToDisplayString(new(typeQualificationStyle: NameAndContainingTypesAndNamespaces)); var structName = structDeclaration.Identifier.Text; var structModifiers = structDeclaration.Modifiers; var fields = ( diff --git a/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs b/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs index 266dc6e6..bb4e3b1b 100644 --- a/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs +++ b/tests/ComputeSharp.Tests.Internals/SourceGeneratorTests.cs @@ -27,7 +27,7 @@ namespace ComputeSharp.Tests.Internals } } - namespace MyFancyApp + namespace MyFancyApp.Sample { [AutoConstructor] public readonly partial struct MyShader @@ -38,7 +38,7 @@ namespace ComputeSharp.Tests.Internals }"; string expected = @" - namespace MyFancyApp + namespace MyFancyApp.Sample { public readonly partial struct MyShader {