rspec/rules/S1905/csharp/rule.adoc

46 lines
759 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
public int Example(int i)
{
return (int) (i + 42); // Noncompliant
}
public IEnumerable<int> ExampleCollection(IEnumerable<int> coll)
{
return coll.Reverse().OfType<int>(); // Noncompliant
}
----
== Compliant Solution
----
public int Example(int i)
{
return i + 42;
}
public IEnumerable<int> ExampleCollection(IEnumerable<int> coll)
{
return coll.Reverse();
}
----
== Exceptions
2021-02-08 19:11:39 +01:00
Issues are not raised against C# 7.1 ``++default++`` literal.
2020-06-30 12:47:33 +02:00
----
bool b = (bool)default; // Doesn't raise an issue
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]