
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
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 field or property, or any complex expression 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,csharp]
|
|
----
|
|
[DebuggerDisplay("Name: {Name}")] // Noncompliant - Name doesn't exist in this context
|
|
public class Person
|
|
{
|
|
public string FullName { get; private set; }
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
[DebuggerDisplay("Name: {FullName}")]
|
|
public class Person
|
|
{
|
|
public string FullName { get; private set; }
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|