ReSharper 2016.3 Help

Code Inspection: Cannot resolve symbol in text argument

This code inspection validates the argument that you pass to the paramName parameter in constructors of System.ArgumentException and its derivatives (e.g. System.ArgumentNullException, System.ArgumentOutOfRangeException, etc.).

The paramName parameter expects the name of the parameter that caused the exception as it will appear in stack traces to help you quickly find the source of the problem. Therefore, ReSharper issues a warning if the argument corresponds to none of the parameters of the method where the exception is thrown. Moreover, ReSharper is aware of the position of the paramName parameter in different signatures as shown in the example below.

public void Foo(object value) { if(value == null) // Warning for the first argument throw new ArgumentNullException("bad value", "value is null"); if(!(value is string)) // Warning for the second argument throw new ArgumentException("bad value", "value is not string"); // do something }

See Also

Last modified: 12 January 2017