From da704cd98f6af21282bf2986cc85069b4cb0223a Mon Sep 17 00:00:00 2001 From: Antonio Aversa Date: Thu, 23 Feb 2023 10:37:55 +0100 Subject: [PATCH] Review --- rules/S4545/csharp/rule-except-see.adoc | 35 ----------------------- rules/S4545/csharp/rule.adoc | 35 ++++++++++++++++++++++- rules/S4545/highlighting.adoc | 2 +- rules/S4545/message.adoc | 2 +- rules/S4545/rule.adoc | 10 ------- rules/S4545/vbnet/rule-except-see.adoc | 37 ------------------------- rules/S4545/vbnet/rule.adoc | 37 ++++++++++++++++++++++++- 7 files changed, 72 insertions(+), 86 deletions(-) delete mode 100644 rules/S4545/csharp/rule-except-see.adoc delete mode 100644 rules/S4545/rule.adoc delete mode 100644 rules/S4545/vbnet/rule-except-see.adoc diff --git a/rules/S4545/csharp/rule-except-see.adoc b/rules/S4545/csharp/rule-except-see.adoc deleted file mode 100644 index 8b317ca2b8b..00000000000 --- a/rules/S4545/csharp/rule-except-see.adoc +++ /dev/null @@ -1,35 +0,0 @@ -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 8901619c83d..4ee3f535256 100644 --- a/rules/S4545/csharp/rule.adoc +++ b/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[] diff --git a/rules/S4545/highlighting.adoc b/rules/S4545/highlighting.adoc index 4eb62825db9..a13e737601c 100644 --- a/rules/S4545/highlighting.adoc +++ b/rules/S4545/highlighting.adoc @@ -1,4 +1,4 @@ === Highlighting -text between curly braces +format string parameter of the ``DebuggerDisplayAttribute`` diff --git a/rules/S4545/message.adoc b/rules/S4545/message.adoc index 38d16d65e3b..6a8fa140f1f 100644 --- a/rules/S4545/message.adoc +++ b/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 diff --git a/rules/S4545/rule.adoc b/rules/S4545/rule.adoc deleted file mode 100644 index be32fcbb45d..00000000000 --- a/rules/S4545/rule.adoc +++ /dev/null @@ -1,10 +0,0 @@ -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 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. diff --git a/rules/S4545/vbnet/rule-except-see.adoc b/rules/S4545/vbnet/rule-except-see.adoc deleted file mode 100644 index 85a2aef69c3..00000000000 --- a/rules/S4545/vbnet/rule-except-see.adoc +++ /dev/null @@ -1,37 +0,0 @@ -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 8901619c83d..37c224a653b 100644 --- a/rules/S4545/vbnet/rule.adoc +++ b/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] +---- + ' 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 +---- ifdef::env-github,rspecator-view[]