Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioaversa committed Feb 23, 2023
1 parent 4e53785 commit da704cd
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 86 deletions.
35 changes: 0 additions & 35 deletions rules/S4545/csharp/rule-except-see.adoc

This file was deleted.

35 changes: 34 additions & 1 deletion rules/S4545/csharp/rule.adoc
@@ -1,4 +1,37 @@
include::rule-except-see.adoc[]
The ``DebuggerDisplayAttribute`` is used to determine how an object is displayed in the debugger window.


The ``DebuggerDisplayAttribute`` constructor takes a single mandatory argument: the string to be displayed in the value column for instances of the type. Any text within curly braces is evaluated as the name of a member, or any complex expression converted to a string value, containing method calls and operators.


Naming a non-existent member between curly braces will result in a CS0103 error in the debug window when debugging objects. Although there is no impact on the production code, providing a wrong value can lead to difficulties when debugging the application.


This rule raises an issue when text specified between curly braces refers to members that don't exist in the current context.


== Noncompliant Code Example

[source,text]
----
[DebuggerDisplay("Name: {Name}")] // Noncompliant - Name doesn't exist in this context
public class Person
{
public string FullName { get; private set; }
}
----


== Compliant Solution

[source,text]
----
[DebuggerDisplay("Name: {FullName}")]
public class Person
{
public string FullName { get; private set; }
}
----

ifdef::env-github,rspecator-view[]

Expand Down
2 changes: 1 addition & 1 deletion rules/S4545/highlighting.adoc
@@ -1,4 +1,4 @@
=== Highlighting

text between curly braces
format string parameter of the ``DebuggerDisplayAttribute``

2 changes: 1 addition & 1 deletion rules/S4545/message.adoc
@@ -1,4 +1,4 @@
=== Message

Fix the name between the curly braces so that it matches a field, property or method of this object
Fix the name between the curly braces so that it matches a field or property of this object

10 changes: 0 additions & 10 deletions rules/S4545/rule.adoc

This file was deleted.

37 changes: 0 additions & 37 deletions rules/S4545/vbnet/rule-except-see.adoc

This file was deleted.

37 changes: 36 additions & 1 deletion rules/S4545/vbnet/rule.adoc
@@ -1,4 +1,39 @@
include::rule-except-see.adoc[]
The ``DebuggerDisplayAttribute`` is used to determine how an object is displayed in the debugger window.


The ``DebuggerDisplayAttribute`` constructor takes a single mandatory argument: the string to be displayed in the value column for instances of the type. Any text within curly braces is evaluated as the name of member, or any complex expression converted to a string value, containing method calls and operators.


Naming a non-existent member between curly braces will result in a BC30451 error in the debug window when debugging objects. Although there is no impact on the production code, providing a wrong value can lead to difficulties when debugging the application.


This rule raises an issue when text specified between curly braces refers to members that don't exist in the current context.


== Noncompliant Code Example

[source,vbnet]
----
<DebuggerDisplay("Name: {Name}")> ' Noncompliant - Name doesn't exist in this context
Public Class Person
Public Property FullName As String
End Class
----


== Compliant Solution

[source,vbnet]
----
<DebuggerDisplay("Name: {FullName}")>
Public Class Person
Public Property FullName As String
End Class
----

ifdef::env-github,rspecator-view[]

Expand Down

0 comments on commit da704cd

Please sign in to comment.