Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-286705: Unnecessary "Access to disposed closure" warning

$
0
0
Reporter Justin (McCulty) Justin (McCulty)
Created Dec 13, 2011 8:41:06 PM
Updated Feb 15, 2012 1:55:07 PM
Resolved Dec 14, 2011 5:44:25 PM
Priority Normal
Type Unspecified
Fix versions No Fix versions
State Won't fix
Assignee Evgeny Pasynkov (pasynkov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
Consider the following code:
using (obj)
{
    Method(delegate { obj.Something(); });
}

There is a warning created on the use of obj. However I don't think there is anything technically wrong with this. I realize that inside Method it could keep the delegate that was passed in and use it at a later time (after obj has been disposed) but there is no way for R# to know that. For example, R# doesn't complain about the following:
using (obj)
{
    Method(obj);
}

public void Method(object obj)
{
    // Keep a reference to obj or use it in a separate thread, etc...
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles