views:

28

answers:

2

When adding a web reference in Visual Studio 2005, I've noticed that every element within the wdsl is duplicated. E.g. for element ItemOne, the interface it generates contains both ItemOne and itemOneField. Both are the same thing, but one is a member and the other is a field. I suspect the field is just a getter for the member.

I can imagine using a field instead of a member for this...but in that case my tendency would have been to make the member private, to avoid clutter. This, despite the fact that the normal motivation for making such a member private is to hide implementation details, which is obviously not applicable in this case.

I realize that changing this now would likely introduce compatibility issues, but I don't see why they did it this way the first time.

Do not point out that such a change would introduce compatibility issues with previous versions of VS. I am interested in the original reasoning behind this.

A: 

It's a property with a backing field. What's the problem? Were you expecting it to generate an automatic property? They didn't exist until recently. Why change what works, especially since ASMX (and WSDL.EXE) is pretty much dead technology.

John Saunders
As I mentioned, I am aware that one needs a backing field. But the field *could* have been private to avoid clutter.
Brian
Please show an example of what you mean. I just looked at a Reference.cs file, and I find that the field is private, just as I expected. You seem to be seeing something else, so please show us what you're seeing.
John Saunders
A: 

"I am interested in the original reasoning behind this"

as everything past 3.0 framework, the only way to create properties were having a private variable and the property name

private string myItemField;

public string myItem() {
  get {
    return myItemField;
  }
  set {
    myItemField = value;
  }
}

but now, there is no need for it...

public string myItem { get; set; }

the thing is, that this last code is compiled as the original one at the top, even if it's easier to write, it is compiled in the same old way, you will end up with a private variable and a property.

Same thing happens when you add a Web Reference, it needs a variable to hold the "stuff" and then the method...

balexandre
As I mentioned, I am aware that one needs a backing field. But the field *could* have been private to avoid clutter.
Brian