Reporter | Bojan Rajkovic (bojan.rajkovic1) |
---|---|
Created | Feb 22, 2012 8:58:33 PM |
Updated | Feb 22, 2012 8:58:33 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | Code Analysis |
Affected versions | 6.1.1 |
Fixed in build | No Fixed in build |
I'm working with some GMime# code, and I have the following construct:
where p is an instance of GMime.Parser, and GMime.Parser.ConstructMessage consists of the following code:
ReSharper insists on believing that message cannot be null, when in fact it's rather clear that it can be. In this case, GLib.Object.GetObject returns a GLib.Object. Message does inherit from GLib.Object, but not all GLib.Object instances are Message instances, and GetObject is fully capable of returning null.
ReSharper should realize that this method call chain is capable of returning null, and not insist on message never being null.
var message = p.ConstructMessage ()
where p is an instance of GMime.Parser, and GMime.Parser.ConstructMessage consists of the following code:
return GLib.Object.GetObject(Parser.g_mime_parser_construct_message(this.Handle), true) as Message;
ReSharper insists on believing that message cannot be null, when in fact it's rather clear that it can be. In this case, GLib.Object.GetObject returns a GLib.Object. Message does inherit from GLib.Object, but not all GLib.Object instances are Message instances, and GetObject is fully capable of returning null.
ReSharper should realize that this method call chain is capable of returning null, and not insist on message never being null.