简体   繁体   中英

What is the difference between “unused parameter” and “unused type parameter” (Resharper)

在此处输入图片说明

What is the difference between them ? can some one please give me an example of "unused parameter" and "unused type parameter" ?

And another question, even i the resharper finds things that are errors, the project still builds, how can i make vs to fail the build if resharper finds errors

Given the below:

void SomeMethod<someTypeParameter>(someType someParameter)
{
  // doing all kinds of things, but not using someTypeParameter and someParameter
}

The unused type parameter would be the generic parameter, someTypeParameter (inside the <> ) and the unused parameter would be someParameter .

Unused parameter:

void Go(string s)
{
    Console.WriteLine("I'm totally ignoring the 's' parameter");
}

Unused type parameter:

public static void Go<T>()
{
    Console.WriteLine("I'm totally ignoring the `T` generic parameter");
}

EDIT

Regarding your second question, looks like that's not possible - but there's a discussion here on making ReSharper part of your build process. It's an old thread, but it continues pretty recently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM