Skip to content

Commit

Permalink
generic types for component names without <TValue>
Browse files Browse the repository at this point in the history
  • Loading branch information
tesar-tech committed Dec 11, 2024
1 parent 8671799 commit 0381e08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private static string GenerateComponentsApiSource( Compilation compilation, Immu
IEnumerable<ApiDocsForComponent> 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 ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}>";
}

Expand Down

0 comments on commit 0381e08

Please sign in to comment.