
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.
42 lines
902 B
Plaintext
42 lines
902 B
Plaintext
== Why is this an issue?
|
|
|
|
Method for creating empty arrays ``++Array.Empty<TElement>()++`` was introduced in .NET 4.6 to optimize object instantiation and memory allocation. It also improves code readability by making developer's intent more explicit. This new method should be preferred over empty array declaration.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
public void Method()
|
|
{
|
|
var zero_length = new int[0]; // Noncompliant
|
|
var empty_array = new string[] { }; // Noncompliant
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
public void Method()
|
|
{
|
|
var zero_length = Array.Empty<int>();
|
|
var empty_array = Array.Empty<string>();
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Replace this empty array with Array.Empty<TElement>().
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|