simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

[C#] ToString() affects the message state

Open amibar opened this issue 10 months ago • 0 comments

The generated ToString() method of a message affects the state of the message. Since the debugger calls to ToString() to show its data in the watches, it messes up with the state of the program.

Moreover, quoting from the ToString() documents "Notes to Inheritors": https://learn.microsoft.com/en-us/dotnet/api/system.object.tostring

  • Your ToString() override should have no observable side effects to avoid complications in debugging. For example, a call to the ToString() method should not change the value of instance fields.

amibar avatar Apr 25 '24 10:04 amibar