dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.53k stars 4.53k forks source link

`DebuggerDisplayAttribute` in ADO.NET types #31322

Open Logerfo opened 4 years ago

Logerfo commented 4 years ago

Description

As discussed in npgsql/npgsql#2687, some ADO.NET types could benefit from having a DebuggerDisplayAttribute. I could send a PR.

Which types should have it?

Which types should not have it?

Pending questions


I'm putting up a suggestion list below. This list will be updated as new suggestions are made.

Type Attribute Content
DbCommand {CommandText}
DbConnection State = {State}, ConnectionString = {ConnectionString}
DbParameter ParameterName = {ParameterName}, Value = {Value}
DbParameterCollection Count = {Count}
DbDataReader {Command}
YohDeadfall commented 4 years ago

Speaking about debugging info, I would like to see "ParameterName = {ParameterName}, Value = {Value}" for the DbParameter type. The command type could expose the current state.

Logerfo commented 4 years ago

@YohDeadfall I have updated the description in order to include your suggestion for the DbParameter type. About the DbCommand type, I don't know what you mean. As far as I know, there is no State or similar property. It does exist for NpgsqlCommand, you might be mixing them up.

YohDeadfall commented 4 years ago

Sorry, I mean DbConnection.

Logerfo commented 4 years ago

OK, updated.

vcsjones commented 4 years ago

I wonder if there is any security guidance or concerns for using DebuggerDisplayAttribute on information that is sensitive. ConnectionString maybe contain a username and password.

Logerfo commented 4 years ago

@vcsjones I don't think there is any concern, as it probably would for ToString. If someone has access to the value displayed in the debugger through the attribute of a type, it's sure that they also have access to its members values, including private ones.