This project is read-only.

getting rid of "Field" suffix

Feb 21, 2014 at 11:49 PM
Example:

Attribute declaration in XSD:
<xs:attribute name="loanID" type="xs:long" use="required" />
Code generated by WSCF.blue via Generate Data Contract Code:
    private long loanIDField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute(AttributeName="loanID")]
    public long LoanID
    {
        get
        {
            return this.loanID;
        }
        set
        {
            this.loanID = value;
        }
    }
Code generation options selected: "Public properties", Adjust casing", and List<T>.

Question: is it possible to tell WSCF.blue to NOT append "Field" suffix to private field names? If so, how?

The reason I'm asking: XSDs are part of data contract for a web service that can be consumed as either XML of JSON. XML serializers generate attribute names based on XMLAttribute decoration (in this case, "loanID") - which is exactly how it should be. JSON serializers apparently look at the private field name and generate "loanIDField" attribute name - which is a problem.

Thank you!
Ian Kogan
May 21, 2014 at 1:24 PM
I am struggling with the same issue and have concluded that there is no way to change this behavior other than to untick public properties. It seems that the name used is generated from the metadata of the private variable which is returned by the public property, wscf.blue could possibly be amended to use an attribute which specifies the name to be used.

I have also found another issue in that wscf.blue renames some elements in the generated code, so I have a manual step to change the name back after re-generation, you may also find this.