Skip to content

Commit

Permalink
#803 [doc] Eventcallbacks with generic type parameter - wrong API doc…
Browse files Browse the repository at this point in the history
…umentation section - cleanup
  • Loading branch information
hakenr committed May 15, 2024
1 parent d26fe1d commit afec5a3
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using Havit.Blazor.Documentation.Model;
using LoxSmoke.DocXml;
using Microsoft.JSInterop;
Expand Down Expand Up @@ -265,16 +266,20 @@ private bool ShouldIncludeMethod(MethodInfo methodInfo)
return true;
}

// ...

private bool IsEventCallback(PropertyModel property)
{
// If the EventCallback is used to bind a parameter, then it should be placed in the Parameters section.
if (property.PropertyInfo.Name.EndsWith("Changed"))
string propertyName = property.PropertyInfo.Name;

// SomethingChanged should be treated as regular property
// OnSomethingChanged should be treated as event-callback
if (propertyName.EndsWith("Changed") && !Regex.IsMatch(propertyName, @"^On[A-Z]"))
{
return false;
}

return
(property.PropertyInfo.PropertyType.IsGenericType && (property.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(EventCallback<>)))
return (property.PropertyInfo.PropertyType.IsGenericType && (property.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(EventCallback<>)))
|| property.PropertyInfo.PropertyType == typeof(EventCallback);
}
}

0 comments on commit afec5a3

Please sign in to comment.