Closed GoogleCodeExporter closed 9 years ago
Interesting. There's a comment in MessageGenerator (just before we write that
line):
"// Make sure we've computed the serialized length, so that packed fields are
generated correctly."
Will need to investigate more closely. Aside from anything else, we could
either suppress the warning or create a method to return the serialized size as
well as just the property. (The reason for the variable is that a property
access on its own isn't a valid statement.)
Original comment by jonathan.skeet
on 11 Apr 2014 at 5:22
This is indeed a required line/operation. We should suppress this manually by
adding 168 (219?) to the generated line:
#pragma warning disable 1591, 0612
Another possibility is to change it's usage from:
int size = SerializedSize;
to something like:
if (SerializedSize < 0) { throw new ....Exception() }
In the mean time, you can add 168 to project's list of ignored warnings if you
are seeing this warning. I'm surprised you see this as the '#region Designer
generated code' should disable warnings within the region.
What version of Visual Studio/compiler are you using? As I do not see CS0219,
but rather CS0168.
Original comment by Grig...@gmail.com
on 15 Sep 2014 at 8:21
Fixed by moving the logic of the SerializedSize getter into a new private
method CalcSerializedSize(). This avoids the use of the fetching the property
into an unused variable generating the error above.
Original comment by Grig...@gmail.com
on 7 Feb 2015 at 9:36
Original issue reported on code.google.com by
garrynewman@gmail.com
on 11 Apr 2014 at 10:17