All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.csharp.S4018.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

Type inference enables the call of a generic method without explicitly specifying its type arguments. This is not possible when a parameter type is missing from the argument list.

Noncompliant code example

using System;

namespace MyLibrary
{
  public class Foo
  {
    public void MyMethod<T>()  // Noncompliant
    {
        // this method can only be invoked by providing the type argument e.g. 'MyMethod<int>()'
    }
  }
}

Compliant solution

using System;

namespace MyLibrary
{
  public class Foo
  {
    public void MyMethod<T>(T param)
    {
        // type inference allows this to be invoked 'MyMethod(arg)'
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy