Skip to content

Commit 7f46647

Browse files
committed
feat(ComponentAnalyzer): simplify type name handling and add regex for Nullable<T>
1 parent ca95e1f commit 7f46647

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tools/LlmsDocsGenerator/ComponentAnalyzer.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,29 @@ private string SimplifyDefaultValue(string value)
314314

315315
private string SimplifyTypeName(string typeName)
316316
{
317-
// Simplify common type names
318-
return typeName
317+
// Remove common namespace prefixes
318+
var result = typeName
319319
.Replace("System.", "")
320320
.Replace("Collections.Generic.", "")
321-
.Replace("Threading.Tasks.", "")
322-
.Replace("Nullable<", "")
323-
.Replace(">", "?")
321+
.Replace("Threading.Tasks.", "");
322+
323+
// Handle Nullable<T> -> T? (must be done carefully to not break other generics)
324+
result = NullableRegex().Replace(result, "$1?");
325+
326+
// Simplify primitive type names
327+
result = result
324328
.Replace("Int32", "int")
325329
.Replace("Int64", "long")
326330
.Replace("Boolean", "bool")
327331
.Replace("String", "string")
328332
.Replace("Object", "object");
333+
334+
return result;
329335
}
330336

337+
[GeneratedRegex(@"Nullable<([^>]+)>")]
338+
private static partial Regex NullableRegex();
339+
331340
private bool HasAttribute(MemberDeclarationSyntax member, string attributeName)
332341
{
333342
return member.AttributeLists

0 commit comments

Comments
 (0)