From 56e93ea54254575210e6c027684249b0be2e8690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tesa=C5=99?= <33880579+tesar-tech@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:14:49 +0000 Subject: [PATCH] Docs: Generic types for component names without (#5891) * generic types for component names without * Format --------- Co-authored-by: Mladen Macanovic --- .../ApiDocsGenerator/ComponentsApiDocsGenerator.cs | 2 +- .../ApiDocsGenerator/Helpers/StringHelpers.cs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs b/Documentation/Blazorise.Docs.Compiler/ApiDocsGenerator/ComponentsApiDocsGenerator.cs index 0eeef17817..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 ); + 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..7e582686de 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,12 @@ 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}>"; }