Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some properties are never visited by MemberVisitor #184

Closed
bcallaghan-et opened this issue Apr 23, 2020 · 2 comments
Closed

Some properties are never visited by MemberVisitor #184

bcallaghan-et opened this issue Apr 23, 2020 · 2 comments

Comments

@bcallaghan-et
Copy link
Contributor

I am trying to use MemberVisitor to apply additional attributes based on documented rules that are not present in the XSD schema. One roadblock I've run into is that text value properties are not passed into the visitor action. Consider the following schema:

<complexType name="AmountType">
  <simpleContent>
    <extension base="vsi:MonetaryAmount">
      <attribute name="currency" type="vsi:CurrencyType"/>
    </extension>
  </simpleContent>
</complexType>

This generates a C# class with a Currency property and a Value property. I want to add [Column(TypeName = "decimal(12,2)")] on Value because it's type is MonetaryAmount, but I never get the chance.

Also consider the following C# properties that were generated:

[System.ComponentModel.DataAnnotations.Schema.NotMappedAttribute()]
[System.Xml.Serialization.XmlElementAttribute("MyDate", DataType="date")]
public System.DateTime MyDateValue { get; set; }
        
/// <summary>
/// <para xml:lang="de">Ruft einen Wert ab, der angibt, ob die MyDate-Eigenschaft spezifiziert ist, oder legt diesen fest.</para>
/// <para xml:lang="en">Gets or sets a value indicating whether the MyDate property is specified.</para>
/// </summary>
[System.Xml.Serialization.XmlIgnoreAttribute()]
[System.ComponentModel.DataAnnotations.Schema.NotMappedAttribute()]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public bool MyDateValueSpecified { get; set; }
        
[System.Xml.Serialization.XmlIgnoreAttribute()]
public System.Nullable<System.DateTime> MyDate
{
    get
    {
        if (this.MyDateValueSpecified)
        {
            return this.MyDateValue;
        }
        else
        {
           return null;
        }
    }
    set
    {
        this.MyDateValue = value.GetValueOrDefault();
        this.MyDateSpecified = value.HasValue;
    }
}

I would like to add [Column(TypeName = "date")] to MyDate because it's XML type is date and to use it with Entity Framework. However, that property is never passed into the MemberVisitor action. The other two properties are, but EF will (correctly) ignore those properties.

mganss pushed a commit that referenced this issue Apr 24, 2020
@mganss
Copy link
Owner

mganss commented Apr 24, 2020

I've added a few more calls that should allow for your scenario.

@bcallaghan-et
Copy link
Contributor Author

Yes, I can now add the Column attributes that I wanted through MemberVisitor. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants