diff --git a/rules/S4545/csharp/rule-except-see.adoc b/rules/S4545/csharp/rule-except-see.adoc new file mode 100644 index 00000000000..8b317ca2b8b --- /dev/null +++ b/rules/S4545/csharp/rule-except-see.adoc @@ -0,0 +1,35 @@ +The ``++DebuggerDisplayAttribute++`` is used to determine how an object is displayed in the debugger window. + + +The ``++DebuggerDisplayAttribute++`` constructor takes a single 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 field, property, or method. + + +Naming a non-existent field, property or method 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; } +} +---- + diff --git a/rules/S4545/csharp/rule.adoc b/rules/S4545/csharp/rule.adoc index f5db9e87ac5..8901619c83d 100644 --- a/rules/S4545/csharp/rule.adoc +++ b/rules/S4545/csharp/rule.adoc @@ -1,4 +1,4 @@ -include::../rule.adoc[] +include::rule-except-see.adoc[] ifdef::env-github,rspecator-view[] diff --git a/rules/S4545/rule.adoc b/rules/S4545/rule.adoc index 8b317ca2b8b..be32fcbb45d 100644 --- a/rules/S4545/rule.adoc +++ b/rules/S4545/rule.adoc @@ -4,32 +4,7 @@ The ``++DebuggerDisplayAttribute++`` is used to determine how an object is displ The ``++DebuggerDisplayAttribute++`` constructor takes a single 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 field, property, or method. -Naming a non-existent field, property or method 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. +Naming a non-existent field, property or method between curly braces will result in an 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; } -} ----- - diff --git a/rules/S4545/vbnet/rule-except-see.adoc b/rules/S4545/vbnet/rule-except-see.adoc new file mode 100644 index 00000000000..85a2aef69c3 --- /dev/null +++ b/rules/S4545/vbnet/rule-except-see.adoc @@ -0,0 +1,37 @@ +The ``++DebuggerDisplayAttribute++`` is used to determine how an object is displayed in the debugger window. + + +The ``++DebuggerDisplayAttribute++`` constructor takes a single 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 field, property, or method. + + +Naming a non-existent field, property or method 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] +---- + ' Noncompliant - Name doesn't exist in this context +Public Class Person + + Public Property FullName As String + +End Class +---- + + +== Compliant Solution + +[source,vbnet] +---- + +Public Class Person + + Public Property FullName As String + +End Class +---- + diff --git a/rules/S4545/vbnet/rule.adoc b/rules/S4545/vbnet/rule.adoc index f5db9e87ac5..8901619c83d 100644 --- a/rules/S4545/vbnet/rule.adoc +++ b/rules/S4545/vbnet/rule.adoc @@ -1,4 +1,4 @@ -include::../rule.adoc[] +include::rule-except-see.adoc[] ifdef::env-github,rspecator-view[]