Is this nameof () really recursive?

I am doing ConfigurationSection in C # right now. I decided to take advantage of some C # 6 features using the name (PropertyName) instead of hard-coded strings.

However, I get a weird result from Resharper regarding a recursive call.

Here is an example:

Recursive warning

I can understand why this might give this warning, since the property is referenced internally. However, I'm not sure if this is actually recursive.

Is there anything I should worry about in this call?

+4
source share
1 answer

If this[string]called CoreApiRootUrl, then it is not recursive.

, nameof(...) .

, ( R # 10.0.1) :

public class Bug
{
    public string this[string x] => "";

    public string Foo
    {
        get { return this[nameof(Foo)]; } // Warning here
    }
}

, Foo expression-bodied:

public string Foo => this[nameof(Foo)];

.

R # - Jetbrains.

+6

All Articles