Skip to content

Commit

Permalink
Docs: Generic types for component names without <TValue> (#5891)
Browse files Browse the repository at this point in the history
* generic types for component names without <TValue>

* Format

---------

Co-authored-by: Mladen Macanovic <[email protected]>
  • Loading branch information
tesar-tech and stsrki authored Dec 12, 2024
1 parent 8671799 commit 56e93ea
Show file tree
Hide file tree
Showing 2 changed files with 6 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,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}>";
}

Expand Down

0 comments on commit 56e93ea

Please sign in to comment.