From 0381e08d5854970f7d96d7e63bfb719228813af7 Mon Sep 17 00:00:00 2001 From: tesar-tech Date: Wed, 11 Dec 2024 17:34:22 +0100 Subject: [PATCH 1/2] generic types for component names without --- .../ApiDocsGenerator/ComponentsApiDocsGenerator.cs | 2 +- .../ApiDocsGenerator/Helpers/StringHelpers.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs index 0eeef17817..6ed8912d91 100644 --- a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs +++ b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs @@ -234,7 +234,7 @@ private static string GenerateComponentsApiSource( Compilation compilation, Immu IEnumerable componentsData = components.Select( component => { string componentType = component.Type.ToStringWithGenerics(); - string componentTypeName = StringHelpers.GetSimplifiedTypeName( component.Type ); + string componentTypeName = StringHelpers.GetSimplifiedTypeName( component.Type, withoutGenerics:true ); var propertiesData = component.Properties.Select( property => InfoExtractor.GetPropertyDetails( compilation, property ) ) diff --git a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs index a76b401444..86bfc10d64 100644 --- a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs +++ b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs @@ -113,7 +113,7 @@ private static string GetXmlCommentForInheritdocInterfaces( ISymbol iSymbol, Ext } //just making sure bool is bool and not Boolean... - internal static string GetSimplifiedTypeName( ITypeSymbol typeSymbol ) + internal static string GetSimplifiedTypeName( ITypeSymbol typeSymbol, bool withoutGenerics = false ) { // Mapping for built-in C# types @@ -125,13 +125,11 @@ internal static string GetSimplifiedTypeName( ITypeSymbol typeSymbol ) } // Handle generic types - if ( typeSymbol is INamedTypeSymbol genericType && genericType.IsGenericType - // && - // genericType.ConstructedFrom.Name != "System.Collections.Generic.Dictionary`2" - ) + if ( typeSymbol is INamedTypeSymbol genericType && genericType.IsGenericType ) { var baseName = typeMap.ContainsKey( genericType.Name ) ? typeMap[genericType.Name] : genericType.Name; - var typeArguments = string.Join( ", ", genericType.TypeArguments.Select( GetSimplifiedTypeName ) ); + if ( withoutGenerics ) return baseName; + var typeArguments = string.Join( ", ", genericType.TypeArguments.Select( x => GetSimplifiedTypeName( x ) ) ); return $"{baseName}<{typeArguments}>"; } From a344b8289db19cc80c23a0c2b493ca5089591bdd Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Thu, 12 Dec 2024 11:14:29 +0100 Subject: [PATCH 2/2] Format --- .../ApiDocsGenerator/ComponentsApiDocsGenerator.cs | 2 +- .../ApiDocsGenerator/Helpers/StringHelpers.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs index 6ed8912d91..fd15160b5b 100644 --- a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs +++ b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs @@ -234,7 +234,7 @@ private static string GenerateComponentsApiSource( Compilation compilation, Immu IEnumerable componentsData = components.Select( component => { string componentType = component.Type.ToStringWithGenerics(); - string componentTypeName = StringHelpers.GetSimplifiedTypeName( component.Type, withoutGenerics:true ); + string componentTypeName = StringHelpers.GetSimplifiedTypeName( component.Type, withoutGenerics: true ); var propertiesData = component.Properties.Select( property => InfoExtractor.GetPropertyDetails( compilation, property ) ) diff --git a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs index 86bfc10d64..7e582686de 100644 --- a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs +++ b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/Helpers/StringHelpers.cs @@ -128,7 +128,8 @@ internal static string GetSimplifiedTypeName( ITypeSymbol typeSymbol, bool witho if ( typeSymbol is INamedTypeSymbol genericType && genericType.IsGenericType ) { var baseName = typeMap.ContainsKey( genericType.Name ) ? typeMap[genericType.Name] : genericType.Name; - if ( withoutGenerics ) return baseName; + if ( withoutGenerics ) + return baseName; var typeArguments = string.Join( ", ", genericType.TypeArguments.Select( x => GetSimplifiedTypeName( x ) ) ); return $"{baseName}<{typeArguments}>"; }