I want to modify how some code in Visual Studio 22 is generated.
For instance, in methods I can generate null check on using the Add null check
(MS docs link) for arguments in the following way.
public void MyMethod(object parameter)
{
if (object is null)
{
throw new ArgumentNullException(nameof(parameter));
}
// rest of the method
// ...
}
What I would like to be generated is this:
public void MyMethod(object parameter)
{
if (object is null) throw new ArgumentNullException(nameof(parameter));
// rest of the method
// ...
}
I was looking at code snippet settings and refactoring settings but I can not find the Add null check
option anywhere. Let alone change it.
The best option I came up with is to create a code snippet (MS docs link) but that does not serve my purpose fully.
Is there an option I can modify to say how is the code generated?