WCF custom DataContract/DataMember and CA1811: Avoid uncalled private code
I got a WCF service, and one of the return objects is:
[DataContract]
sealed class Class1
{
[DataMember]
public int Prop1 { get; private set; }
...
}
Incidentially, one of the properties, let's say it's this Prop1
, I 开发者_如何学Conly set within the service, and then read in the client.
This, however, produces CA1811: Avoid uncalled private code
on the .get()
of Prop1
.
Am I doing something wrong, or should I ignore this warning, or should I do something differently?
You are not really doing anything wrong. The warning is raised because the getter is never called on the service side; which is where the analyzed code resides. I think you can safely ignore the warning
精彩评论