
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
85 lines
1.4 KiB
Plaintext
85 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
if (string.IsNullOrEmpty(result = str.Substring(index, length))) // Noncompliant
|
|
{
|
|
//...
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
var result = str.Substring(index, length);
|
|
if (string.IsNullOrEmpty(result))
|
|
{
|
|
//...
|
|
}
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
Assignments inside lambda and delegate expressions are allowed.
|
|
|
|
|
|
Furthermore, the following patterns are also accepted:
|
|
|
|
[source,csharp]
|
|
----
|
|
var a = b = c = 10;
|
|
----
|
|
|
|
[source,csharp]
|
|
----
|
|
while ((val = GetNewValue()) > 0)
|
|
{
|
|
...
|
|
}
|
|
----
|
|
|
|
[source,csharp]
|
|
----
|
|
private MyClass instance;
|
|
public MyClass Instance
|
|
{
|
|
get
|
|
{
|
|
return instance ?? (instance = new MyClass());
|
|
}
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
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)
|
|
|
|
=== on 21 Jan 2016, 11:09:06 Dinesh Bolkensteyn wrote:
|
|
This rule doesn't cover the R# compiler warning (which is out of the box in Roslyn).
|
|
|
|
See \https://msdn.microsoft.com/en-us/library/c1sde1ax.aspx for details on how that one behaves.
|
|
|
|
|
|
As this more generalized rule is way more crappy, I'm disabling it by default for C#
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|