ReSharper 2026.1 Help

Code inspection: The CallerFilePathAttribute will have no effect because it applies to a member that is used in contexts that do not allow optional arguments

This inspection reports [CallerFilePath] applied where caller info cannot be consumed. One common case is putting the attribute on the implementation part of a partial method instead of on the defining declaration that carries the optional parameter. In that position, the attribute has no effect.

Example

using System.Runtime.CompilerServices; partial class C { public partial void M(string path = ""); } partial class C { public partial void M([CallerFilePath] string path) { } }
using System.Runtime.CompilerServices; partial class C { public partial void M([CallerFilePath] string path = ""); } partial class C { public partial void M(string path) { } }

Quick-fix

When another partial declaration exists, the quick-fix can move the attribute onto the declaration part where it is effective.

21 April 2026