"Change to value parameter" quickfix for public methods.

Hello,

when using a private function with a not-assigned-to ref parameter , (like this:)

private void ARefFunction(ref string value) {
     string mystring = value;
     /* ... */
}

ReSharper proposes the "Change to value parameter"-QuickFix. Is it possible to achieve the same functionality for public functions?

Thanks a lot.

Michael

1 comment

That's possible to achieve this with use of solution-wide analysis and we
did this for most of such inspections in ReSharper 4.5.

But unfortunately we decided to drop this particular inspection at all (even
for private methods). The reason is that it's hard to check that the change
will be safe. In fact, it's not enough to analyse the body of the method.
Imaging the following example:


void DoSomething(ref bool doItFlag)
{
while(doItFlag)
DoABit();
}

It's intended that value passed is changed either asynchronyously from another
thread or as a consequence of activity performed in "DoABit" call.
It's hard to detect such cases automatically.

Valentin Kipiatkov
CTO and Chief Scientist
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello,

when using a private function with a not-assigned-to ref parameter ,
(like this:)

 string mystring = value;
> /* ... */
> }]]>

ReSharper proposes the "Change to value parameter"-QuickFix. Is it
possible to achieve the same functionality for public functions?

Thanks a lot.

Michael

---
Original message URL:
http://www.jetbrains.net/devnet/message/5229807#5229807



0

Please sign in to leave a comment.