From bb9a23b80123f5f91f23a94a69641d53868a989b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikul=C3=A1=C5=A1=20Hobl=C3=ADk?= Date: Wed, 25 Oct 2023 17:07:34 +0200 Subject: [PATCH] [doc] HxCalendar doc link to HxInputDate leads to non-generic type instead of component #614 --- .../Model/MemberModel.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Havit.Blazor.Documentation/Model/MemberModel.cs b/Havit.Blazor.Documentation/Model/MemberModel.cs index 5f133e79f..ef61222a2 100644 --- a/Havit.Blazor.Documentation/Model/MemberModel.cs +++ b/Havit.Blazor.Documentation/Model/MemberModel.cs @@ -8,6 +8,7 @@ public abstract class MemberModel private Type enclosingType; private bool generic; + private string genericTypeSuffix; protected string TryFormatComment(string comment, Type enclosingType = null) { @@ -66,6 +67,9 @@ private string PrepareLinkForFullLinkGeneration(string link) generic = IsGeneric(link); // this information is used later to generate a Microsoft documentation link Regex regex = new("`\\d"); + var match = regex.Match(link); + genericTypeSuffix = match.Value; + return regex.Replace(link, ""); } @@ -143,7 +147,8 @@ private string GenerateHavitDocumentationLink(string[] splitLink) } } - isComponent = ApiTypeHelper.GetType(splitLink[^1])?.IsSubclassOf(typeof(ComponentBase)) ?? false; + string className = GetFullGenericTypeName(splitLink[^1]); + isComponent = ApiTypeHelper.GetType(className)?.IsSubclassOf(typeof(ComponentBase)) ?? false; } else if (isProperty) { @@ -227,6 +232,17 @@ private bool IsGeneric(string link) return link.Contains('`'); } + /// The type name including the `1 or `2 suffix if the type is generic. + private string GetFullGenericTypeName(string typeName) + { + if (!generic) + { + return typeName; + } + + return $"{typeName}{genericTypeSuffix}"; + } + private string ConcatenateStringArray(string[] stringArray) { StringBuilder sb = new StringBuilder();