RESTier icon indicating copy to clipboard operation
RESTier copied to clipboard

"CanXXX" method lookup skips inlined properties.

Open robertmclaws opened this issue 8 years ago • 3 comments

C# 7.0 shortcuts make it easy to have Restier miss the "CanXXXEntitySet" authorization methods if they were accidentally created as properties..

Assemblies affected

Microsoft.Restier.Core 1.0.0-beta1.

Reproduce steps

C# 7.0 allows you to simplify properties and methods using lambdas. That lets you turn

public bool SomeProperty { get; private set; }

into

public bool SomeProperty => DoSomething();

and

public bool DoSomething()
{
    return DoSomethingElse();
}

into

public bool DoSomething() => return DoSomethingElse();

Now, the issue is, the property and method inlining are virtually the same. The only difference is in parenthesis. So it is extremely easy to mistakenly create a property when you think you're creating a method, and it is not obvious that you've made a mistake. In fact, I didn't realize it until I wrote Breakdance and it wasn't picking up my "CanXXX' methods.

Restier is magical. It should be smart enough to know the difference and do the right thing in either situation.

Expected result

I would expect that Restier would still find my methods.

Actual result

It does not.

robertmclaws avatar May 19 '17 16:05 robertmclaws

I have a fix for this that I'd like to make a pull request for, but my other PR has yet to be accepted, and I don't want to overload it.

robertmclaws avatar May 20 '17 17:05 robertmclaws

We should soon be to the point where we can take your PR for this.

mikepizzo avatar Jun 10 '17 00:06 mikepizzo

Awesome!

robertmclaws avatar Jun 10 '17 00:06 robertmclaws

I'm pretty sure I fixed this already.

robertmclaws avatar Dec 05 '23 19:12 robertmclaws