Simon Fell > Its just code > .NET 2.0 WSDL

Wednesday, July 7, 2004

Just got the VS C# Express beta 1 installed so I can checkout what improvements to wsdl.exe they've been. I've been hoping for a long time that this release would fix the hokeyness around the fooSpecified fields on generated classes, have looked at what it generates I can't believe how they got so close yet decided not to fix it, are we to be saddled with every dodgy .NET 1.0 decision until Indigo ships when we get to start over again ?

Here's an example, for an complex type that contains an element defined as

<s:element minOccurs="0" name="SystemModstamp" nillable="true" type="s:dateTime" />
it generates this property (yay, properties at last, at least if you run the command line version, for some reason VS.NET sets the flag to get the old fields approach)

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Nullable<System.DateTime> SystemModstamp {
        get {
            return this.systemModstampField;
        }
        set {
            this.systemModstampField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool SystemModstampSpecified {
        get {
            return this.systemModstampFieldSpecified;
        }
        set {
            this.systemModstampFieldSpecified = value;
        }
    }

So, now that it generates Nullable<DateTime> for the property why do we even need the Specified field, string properties don't get one. I'm assuming its for backwards compatibility with previously code gen'd classes. But why oh why couldn't they of gone the extra couple of inches and had the setter for the value set the Specified property as well ???