rspec/rules/S4018/rule.adoc

40 lines
556 B
Plaintext
Raw Normal View History

2020-06-30 12:49:37 +02:00
The best way to determine the type of a generic method is by inference based on the type of argument that is passed to the method. This is not possible when a parameter type is missing from the argument list.
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:49:37 +02:00
----
using System;
namespace MyLibrary
{
public class Foo
{
public void MyMethod<T>() // Noncompliant
{
}
}
}
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:49:37 +02:00
----
using System;
namespace MyLibrary
{
public class Foo
{
public void MyMethod<T>(T param)
{
}
}
}
----