Azure / azure-amqp

AMQP C# library
Other
94 stars 70 forks source link

Consider applying DebuggerBrowsable[Never] to lazily initialized properties of AmqpMessage #239

Closed JoshLove-msft closed 1 year ago

JoshLove-msft commented 1 year ago

So I was finally able to reproduce this, but only while debugging. It seems that the SerializedMessageSize is changed after looking at the AmqpMessage under the debugger. What seems to be happening is that several properties of AmqpMessage are initialized in their getters, so when looking at the properties in the debugger, the getters are invoked triggering the initialization, and increasing the size of the message - e.g. ApplicationProperties.

I will file an issue in the AMQP repo to consider adding the DebuggerBrowsableAttribute to the properties that are lazily initialized.

Given that this is a side-effect of attaching the debugger, and not a production issue, I will mark this issue as addressed. Thanks for working through this one with me @stabzs and @DavidAtImpactCubed!

Originally posted by @JoshLove-msft in https://github.com/Azure/azure-sdk-for-net/issues/33636#issuecomment-1406082282

xinchen10 commented 1 year ago

The lazy initialization is also done for received messages. If we hide them in debugger, user will see all null sections of a received message which may be confusing.