Skip to content

jaredpar/UseNameOf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UseNameOf

This is a tool for converting legacy CSharp code bases to use the nameof expression instead of string literals.

Before

void M(string text) 
{
  if (text == null) 
  {
    throw new ArgumentNullException("text");
  }
  ...
}

After

void M(string text) 
{
  if (text == null) 
  {
    throw new ArgumentNullException(nameof(text));
  }
  ...
}

It will only do this transformation when it knows it is correct. Passing in bad names will not result in a conversion

void G(int p)
{
  // "b" isn't a parameter, won't be transformed
  throw new ArgumentException("b");
}

About

Tool to convert C# code to use nameof vs string literals where appropriate.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages