One of the really cool features of Visual Studio is the ability to create
typed-DataSets based on XSD using a designer. A typed-DataSet gives you
strongly-typed access to columns such as a person's name being a String or
person's age being an Int32. You also get "null checking" and the ability to set
values to "null."

PersonDataSet personData = new PersonDataSet();
PersonDataSet.PersonRow person = personData.Person[0];
person.Name = "blah";
person.Age = 33;
person.IsAgeNull();
person.IsNameNull();
I wish there were the same kind of designer available for custom classes. Not
everyone likes using DataSet, and not everyone can use DataSets. And with DLINQ
on its way, you can't tell me that DataSets are the future either. Now
before you mention using xsd.exe /c, that really doesn't give me the formatting
I'm looking for. The same is true using the class designer in Visual Studio. If
you add properties in the class designer, you end up with ugly code like this:
public class Person {
public string Name {
get {
throw new System.NotImplementedException();
}
set {
}
}
public int Age {
get {
throw new System.NotImplementedException();
}
set {
}
}
}
The alternative is to use the prop expansion to get what I really want - a
private field to go with my property by default:
private string _name;
public string Name {
get { return _name; }
set { _name = value; }
}
However, the prop expansion does a couple of goofy things - it places the
private field declaration right above the property procedure code instead of at
the top of the class. You can of course work around this by using the prop
expansion at the top of your class (if you are like me, you prefer having your
field declarations at the top of your class). That leaves us with being able to
check for "dirty" field values (similar to the typed-DataSet IsSomethingNull()
and SetSomethingNull() methods). It also leaves us with the fact that if I have
a large number of properties, who wants to deal with using the prop expansion
when we could have a perfectly good designer available like the typed-DataSet
folks get to enjoy? I don't want to have to tweak xsd.exe or buy a CodeSmith
license. This is something that could easily be included with Visual Studio IMO. What I would like to see
included with Visual Studio is something similar to a very lame mock-up utility I made in
a few minutes illustrated below, or better yet, the same kind of typed-DataSet
designer for custom classes & collections.
