JetBrains Rider 2024.3 Help

Code inspection: Cannot resolve symbol in text argument

This code inspection validates identifier names used in string literals according to various .NET Framework contracts — for example, constructor parameters of System.Diagnostics.DebuggerDisplayAttribute or of System.ArgumentException and its inheritors.

Let's take a look at the way it works with System.ArgumentException and its inheritors. The paramName parameter in constructors of System.ArgumentException and its derivatives (for example System.ArgumentNullException, System.ArgumentOutOfRangeException, and so on) 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, JetBrains Rider issues a warning if the literal in the argument corresponds to none of the parameters of the method where the exception is thrown. Moreover, JetBrains Rider 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 unresolved symbol, where paramName is the first argument throw new ArgumentNullException("bad value", "value is null"); if(!(value is string)) // Warning for unresolved symbol, where paramName is the second argument throw new ArgumentException("bad value", "value is not string"); // do something }
Last modified: 11 February 2024