xsd.exe does not handle default values for xs:decimal correctly

Bug #966506 reported by Stefan Tauner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mono (Ubuntu)
New
Undecided
Unassigned

Bug Description

when xsd.exe is used with the /c switch to generate c# code from an existing xml schema (.xsd), it handles attributes like the following incorrectly:
<xs:attribute name="setup" type="xs:decimal" default="123"/>

this will generate:
[System.ComponentModel.DefaultValue(123m)]
        [System.Xml.Serialization.XmlAttributeAttribute(Namespace="")]
        public decimal setup {
            get {
                return this.setupField;
            }
            set {
                this.setupField = value;
            }
        }

the important thing is the parameter for the DefaultValue constructor: '123m' is added without quotes. i am not entirely sure that it should actually be quoted, but if it is not then the compiler bails out with:
error CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression
defaults for other types (e.g. integer) are quoted correctly.

this is with the latest mono stuff from 12.04
i.e. 2.10.8.1-1ubuntu1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.