Repository navigation
Introduce analyzer to enforce proper HRESULT handling - #1837
Mark Gross (MarkusG) wants to merge 5 commits into
Conversation
Jevan Saks (jevansaks)
left a comment
There was a problem hiding this comment.
Thank you for providing this write-up! I left some thoughts.
| 2. Is overwritten. | ||
| 3. Reaches a normal method exit. | ||
| 4. Is handled on only some reachable paths. | ||
| 5. Escapes into a field, collection, delegate, or unknown method. |
There was a problem hiding this comment.
Not sure when this happens but ... ok?
There was a problem hiding this comment.
Yeah, this is a weird example that the robot cooked up. I couldn't imagine writing such code, but I think raising the diagnostic on it is still in the spirit of preventing accidental HRESULT mishandling, and also draws attention to code that probably shouldn't be written.
On second thought, we should keep it conservative and consider this kind of thing, although weird, explicit handling of the HRESULT and therefore sufficient consumption.
| Log(obj.DoWork()); | ||
| Console.WriteLine(obj.DoWork()); | ||
| int value = obj.DoWork().Value; | ||
| this.lastResult = obj.DoWork(); |
There was a problem hiding this comment.
Falls under the weird "escapes to an untrackable location" case. Following from the Log(obj.DoWork()) case, should we allow this by default and catch it with the strict analyzer?
Let's allow this to keep the analyzer conservative.
| int value = obj.DoWork().Value; | ||
| this.lastResult = obj.DoWork(); | ||
| results.Add(obj.DoWork()); | ||
| callback(obj.DoWork()); |
There was a problem hiding this comment.
weird but ... maybe ok
There was a problem hiding this comment.
Should be identical to the Log(obj.DoWork()) case IMO
|
Mark Gross (@MarkusG) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
No description provided.