diff --git a/examples/Demo/Shared/Components/ApiDocumentation.razor b/examples/Demo/Shared/Components/ApiDocumentation.razor index cb2e482677..cc165dd530 100644 --- a/examples/Demo/Shared/Components/ApiDocumentation.razor +++ b/examples/Demo/Shared/Components/ApiDocumentation.razor @@ -26,7 +26,7 @@ string header = Properties.Any(x => x.IsParameter) ? "Parameters" : "Properties";

@header

- + @context.Name @context.Type @@ -97,4 +97,4 @@
} - \ No newline at end of file + diff --git a/examples/Demo/Shared/Components/ApiDocumentation.razor.cs b/examples/Demo/Shared/Components/ApiDocumentation.razor.cs index 10c0270300..f357b3c676 100644 --- a/examples/Demo/Shared/Components/ApiDocumentation.razor.cs +++ b/examples/Demo/Shared/Components/ApiDocumentation.razor.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; using Microsoft.AspNetCore.Components; +using Microsoft.FluentUI.AspNetCore.Components; namespace FluentUI.Demo.Shared.Components; @@ -109,13 +110,26 @@ private IEnumerable GetMembers(MemberTypes type) // Parameters/properties if (!isEvent) { + var defaultVaue = ""; + if (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType == typeof(string)) + { + defaultVaue = obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj)?.ToString(); + } + else if (propertyInfo.PropertyType == typeof(Icon)) + { + if (obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj) is Icon icon) + { + defaultVaue = $"{icon.Variant}.{icon.Size}.{icon.Name}"; + } + } + members.Add(new MemberDescription() { MemberType = MemberTypes.Property, Name = propertyInfo.Name, Type = propertyInfo.ToTypeNameString(), EnumValues = GetEnumValues(propertyInfo), - Default = propertyInfo.PropertyType.IsValueType ? obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj)?.ToString() : "", + Default = defaultVaue, Description = CodeComments.GetSummary(Component.Name + "." + propertyInfo.Name) ?? CodeComments.GetSummary(Component.BaseType?.Name + "." + propertyInfo.Name), IsParameter = isParameter, });