You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
public partial class Model
{
public string Name { get; set; }
}
[MetadataType(typeof(IModelMeta))]
public partial class Model : IModelMeta
{
}
public interface IModelMeta
{
[JSchemaGenerationProvider(typeof(CustomSchemaProvider))]
[ReadOnly(true)] // "readOnly": true
string Name { get; set; }
}
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:
[MetadataType(typeof(ModelMeta))]
public partial class Model
{
public class ModelMeta
{
[JSchemaGenerationProvider(typeof(CustomSchemaProvider))]
[ReadOnly(true)] // "readOnly": true
public string Name { get; set; }
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).
The text was updated successfully, but these errors were encountered:
JeffBarnard
changed the title
JSchemaGenerationProvider for MemberProperty not executed if annotation exist on metadatatype buddy class
JSchemaGenerationProvider for MemberProperty not executed if annotation exists on metadatatype buddy class
Oct 12, 2023
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).
The text was updated successfully, but these errors were encountered: