From eee257a7799a92a2b12165f08656fdbd216f9bb8 Mon Sep 17 00:00:00 2001 From: Simon McKenzie <17579442+simonmckenzie@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:37:19 +1000 Subject: [PATCH] Fully qualify type names to prevent types with the same name from being seen as identical A test can't yet be written for this, as the generator can't currently handle same-named types Also updated the test to show that nested generics work correctly --- AutomaticInterface/AutomaticInterface/Builder.cs | 3 ++- AutomaticInterface/Tests/GeneratorTests.cs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AutomaticInterface/AutomaticInterface/Builder.cs b/AutomaticInterface/AutomaticInterface/Builder.cs index 303c07a..bc55fe9 100644 --- a/AutomaticInterface/AutomaticInterface/Builder.cs +++ b/AutomaticInterface/AutomaticInterface/Builder.cs @@ -16,7 +16,8 @@ public static class Builder genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, memberOptions: SymbolDisplayMemberOptions.IncludeParameters, parameterOptions: SymbolDisplayParameterOptions.IncludeType - | SymbolDisplayParameterOptions.IncludeParamsRefOut + | SymbolDisplayParameterOptions.IncludeParamsRefOut, + typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces ); public static string BuildInterfaceFor(ITypeSymbol typeSymbol) diff --git a/AutomaticInterface/Tests/GeneratorTests.cs b/AutomaticInterface/Tests/GeneratorTests.cs index ea312e2..823bfbb 100644 --- a/AutomaticInterface/Tests/GeneratorTests.cs +++ b/AutomaticInterface/Tests/GeneratorTests.cs @@ -2043,9 +2043,9 @@ namespace AutomaticInterfaceExample; [GenerateAutomaticInterface] public class DemoClass { - public void AMethod(Func getValue) {} + public void AMethod(Func> getValue) {} - public void AMethod(Func getValue) {} + public void AMethod(Func> getValue) {} } """; @@ -2068,10 +2068,10 @@ namespace AutomaticInterfaceExample public partial interface IDemoClass { /// - void AMethod(Func getValue); + void AMethod(Func> getValue); /// - void AMethod(Func getValue); + void AMethod(Func> getValue); } }