json.netcodefluent

CodeFluent Entities Add Runtime Design Attribute to False


Now that the site blog.codefluententities.com is down, there is no place to get answers to frequent questions. Even the FAQ's and blog at their main website is poor and lacks of any search tool. At the "knowledge center" you can try to search some basic questions but you'll need to custom search at google using the website: key. I've finally found a clue about my last failure using this old promising tool at:

https://www.softfluent.com/product/codefluent-entities/knowledge-center/json-serialization-D2715E9D140C-A6080529C80C

but the key link is pointing to a lost domain and that's the end of the road.

My question is solved at:

CodeFluent Entities adds a TypeConverterAttribute that allows to convert an entity to string using the EntityDisplayName property. Json.NET detects this attribute and wrongly uses it to serialize the entity to JSON. There are 2 solutions:

Remove this attribute if you don't use it by setting Add Runtime Design Attribute to False Use the Json.NET aspect to generate specific Json.NET attribute on generated classes and properties

but there's no information about how to do it.

As SoftFluent states, questions can be post to SO adding the tag, but user's community is poor at knowledge of the product and developer team @meziantou is overloaded

I really hope this project does not fail as it was one of my last bets to a hidden-source company and pray at every out-of-date free-license internet connection dependent renewal for their server not being closed.


Solution

  • CodeFluent Entities adds a TypeConverterAttribute that allows to convert an entity to string using the EntityDisplayName property. Json.NET detects this attribute and wrongly uses it to serialize the entity to JSON. There are 2 solutions:

    Remove this attribute if you don't use it by setting Add Runtime Design Attribute to False

    The following configuration will prevent CodeFluent Entities from generating [System.ComponentModel.TypeConverterAttribute(typeof(CodeFluent.Runtime.Design.NameTypeConverter))] on generated classes:

    <cf:producer name="Business Object Model (BOM)" typeName="CodeFluent.Producers.CodeDom.CodeDomProducer, CodeFluent.Producers.CodeDom">
        <cf:configuration addRuntimeDesignAttributes="false" ... />
    </cf:producer>
    

    You can also use the modeler to set this attribute.

    Use the Json.NET aspect to generate specific Json.NET attribute on generated classes and properties

    If you need to preserve the TypeConverter, you can instruct CodeFluent Entities to add custom JSON.Net attributes on generated classes and properties using the following aspect. The code and usage sample is available on GitHub: https://github.com/SoftFluent/CodeFluent-Entities/tree/master/Extensions/SoftFluent.Json.NET/