Open JeffBarnard opened 11 months ago
I have other code that detects metadata attributes and it basically looks like this:
var metadataType = type.GetCustomAttributes(typeof(MetadataTypeAttribute), true)
.OfType<MetadataTypeAttribute>().FirstOrDefault();
if (metadataType != null)
{
PropertyInfo[] properties = metadataType.MetadataClassType.GetProperties(BindingFlags.Public | ...);
Perhaps there is a workaround, a method that I could override to fetch the metadata properties, then I could apply a similar technique there.
When using the .net ValidationContext to validate our objects, the metadata classes need to be registered in order for that api to detect them. I don't know why they require us to do this, but perhaps this is a useful reference:
foreach (MetadataTypeAttribute attrib in type.GetCustomAttributes(typeof(MetadataTypeAttribute), true))
{
System.ComponentModel.TypeDescriptor.AddProviderTransparent(
new AssociatedMetadataTypeTypeDescriptionProvider(type, attrib.MetadataClassType), type);
}
I want to use a custom JSchemaGenerationProvider to add some properties that aren't supported out of the box, such as "readOnly".
I am using ef-core database first tools to generate portable POCO classes. I am then extending these classes by adding 'buddy classes' to annotate them for the validation rules.
In the above example, my CustomSchemaProvider is not executed.
Even if I do not use an interface and use a local class instead, it still does not work:
It only works if I move the annotation to the origin class definition, but I cannot do this because my base partial POCO classes are generated by tooling (efpt).