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 14:49:38 +02:00
|
|
|
|
2020-06-30 12:47:33 +02:00
|
|
|
----
|
|
|
|
bool b = (bool)default; // Doesn't raise an issue
|
|
|
|
----
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|