Skip to content

[C#] ToString() affects the message state #992

Closed
@amibar

Description

@amibar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions