UseNamedArgs 0.0.2

dotnet add package UseNamedArgs --version 0.0.2                
NuGet\Install-Package UseNamedArgs -Version 0.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UseNamedArgs" Version="0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UseNamedArgs --version 0.0.2                
#r "nuget: UseNamedArgs, 0.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UseNamedArgs as a Cake Addin
#addin nuget:?package=UseNamedArgs&version=0.0.2

// Install UseNamedArgs as a Cake Tool
#tool nuget:?package=UseNamedArgs&version=0.0.2                

Suggest method calls that can benefit from using named arguments

This project contains a Roslyn code analyzer and an accompanying code-fix provider that suggest using named arguments when calling a method having successive parameters of the same type.

How to use it?

Simply install this nuget package. The analyzer is going to look for method invocations that can benefit from named arguments across the project.

public static void IntroduceCharacter(string name, string powerLevel) {}

// Elsewhere in your code:
// if `IntroduceCharacter` method is called with positional arguments,
// the analyzer emits a warning, as the the method has two parameters 
// of the same type following one another.
IntroduceCharacter(name: "Goku", powerLevel: "Over 9000!");

Supported method kinds

The analyzer supports suggesting named arguments for the following method kinds

  • Regular instance and static methods
  • Extension methods
  • Regular constructors
  • Attribute constructors
  • Primary constructors

Download and install

Install the UseNamedArgs nuget package. For example, run the following command in the NuGet Package Manager Console.

Install-Package UseNamedArgs

This will download all the binaries, and add necessary analyzer references to your project.

Configuration

Starting in Visual Studio 2019 version 16.3, you can configure the severity of analyzer rules, or diagnostics, in an EditorConfig file, from the light bulb menu, and the error list.

You can add the following to the [*.cs] section of your .editorconfig.

[*.cs]
dotnet_diagnostic.UseNamedArgs.severity = suggestion

The possible severity values are:

  • error
  • warning
  • suggestion
  • silent
  • none
  • default (in case of this analyzer, it's equal to warning)

Please take a look at the documentation for a detailed description.

Thank you!

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.2 1,732 1/23/2024
0.0.1 865 8/16/2018

Support additional call kinds, such as primary constructors