MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Analyzer: Ensure DP Operations Return Void #184

Closed JasonBock closed 4 years ago

JasonBock commented 8 years ago

At a client, someone decided to define DataPortal_Execute() like this:

private string DataPortal_Execute() ...

They thought they'd be able to return a string from a DataPortal.Execute() call, which, of course, didn't work.

This got me to thinking....should I create an analyzer that ensures that any DP operation has a return of void? I'm thinking that this would be an error condition.

What cases am I missing if I do this?

rockfordlhotka commented 8 years ago

They can return void or Task.

Good idea for an analyzer.

Also, were they trying to call DP_Execute directly? An analyzer saying that you can never call these methods directly would be good too :smile:

JasonBock commented 5 years ago

Since I'm on a roll recently with analyzers, @rockfordlhotka, want to move this to a CSLA issue? I'd want to focus strictly on checking the return value for an operation method and say it can be either void or a Task. Checking to see if someone is invoking an operation directly should be a separate issue.

With respect to this second idea, are you saying code should never invoke an operation method directly, whether they're in an ObjectFactory instance or not?

rockfordlhotka commented 5 years ago

Yes, this would be a good analyzer.

It is true, nobody should be calling DP_XYZ methods directly. I'd like to say that's true of ObjectFactory methods also, but really we're mostly hands-off with how/when people build and use those factories, so I'd say we should not block direct calls to those methods.

JasonBock commented 5 years ago

OK, to be clear....

rockfordlhotka commented 5 years ago

Locking this thread so all discussion goes to the actual work issue.

JasonBock commented 4 years ago

Hey @rockfordlhotka any reason this should still stay open, or close it? I think this is done...