I've got an issue where some code in an old win forms app that is using reflection on an object from a web service to get a list of fields. The reflection is calling GetFields(). In my data object in the web service I have fields defined as such:
public string PropertyAddress1;
public string PropertyAddress2;
public string PropertyCity;
public string PropertyCounty;
public string PropertyState;
In the current version of reference.cs that exists in the win forms app the fields look like so.
public string PropertyAddress1;
public string PropertyAddress2;
public string PropertyCity;
public string PropertyCounty;
public string PropertyState;
The same right?
Well, I went in to the web service's class and added another field. I then went into the win forms app, right clicked and hit update web reference. When the code is regenerated the reference.cs looks like this:
private string propertyAddress1Field;
private string propertyAddress2Field;
private string propertyCityField;
private string propertyCountyField;
private string propertyStateField;
public string PropertyAddress1 {
get {
return this.propertyAddress1Field;
}
set {
this.propertyAddress1Field = value;
}
}
/// <remarks/>
public string PropertyAddress2 {
get {
return this.propertyAddress2Field;
}
set {
this.propertyAddress2Field = value;
}
}
/// <remarks/>
public string PropertyCity {
get {
return this.propertyCityField;
}
set {
this.propertyCityField = value;
}
}
/// <remarks/>
public string PropertyCounty {
get {
return this.propertyCountyField;
}
set {
this.propertyCountyField = value;
}
}
/// <remarks/>
public string PropertyState {
get {
return this.propertyStateField;
}
set {
this.propertyStateField = value;
}
}
This is throwing off the behavior of existing code because GetFields() is no longer returning anything. I know I could swap it to GetProperties() but the class already has properties defined that I do not want returned back in the result set. I would like the reference .cs to generate fields as fields and properties as properties instead of converting fields to properties. Is there any way I can put some data annotations or some other sort of flag that prevents this behavior in the auto generated reference.cs for fields?
Aucun commentaire:
Enregistrer un commentaire