I'm using ReSharper in my C# projects, and generally I love it. However, it keeps adding annotations to the code when I do certain refactoring actions.
For example, it adds [NotNull]
when I use the "Check parameter for null" context action:
// Before context action
public void Foo(object input)
{
}
// After context action
public void Foo([NotNull] object input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
}
Additionally, ReSharper then adds using JetBrains.Annotations
to the file, even though I'm not referencing the JetBrains assembly where the attribute is defined.
I would like to continue using the context actions, as they're very useful, but I can't introduce external annotations in the code. ReSharper provides an option to change the default annotation namespace and to copy the annotation attribute source code into your project, but that also isn't an option for this project.
Is there any way to tell ReSharper to stop adding annotations entirely? I've tried in the options unchecking JetBrains.Annotations as a namespace with code annotation attributes, but that doesn't seem to have any effect on whether the annotations are generated in the first place.
Update: While I wasn't actually referencing JetBrains.Annotations.dll, I was referencing another DLL that re-implemented the same annotation attributes in the same JetBrains.Annotations namespace. Removing that DLL reference will prevent ReSharper from adding the annotations. It'd be nice if there was still an option to turn this off, but the workaround fits for this situation.