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

RSRP-288331: Allow InstantHandleAttribute on methods (to indicate the return value is not deferred)

$
0
0
Reporter Jesse Plamondon-Willard (Jesse.Plamondon-Willard) Jesse Plamondon-Willard (Jesse.Plamondon-Willard)
Created Feb 15, 2012 7:57:38 PM
Updated Feb 15, 2012 7:57:38 PM
Priority Normal
Type Feature
Fix versions No Fix versions
State Submitted
Assignee Evgeny Pasynkov (pasynkov)
Subsystem Code Analysis - Find Code Issues
Affected versions No Affected versions
Fixed in build No Fixed in build
We use IEnumerable<T> to represent an enumerable set of values, but there's no way to indicate that a method doesn't return a deferred query. For example, ReSharper will raise possible multiple enumeration of IEnumerable warnings for the code below:

incorrect multiple enumeration warnings
public IEnumerable<int> GetRandomArray()
{
	return new[] { 4 };
}

public void Demo()
{
	IEnumerable<int> values = this.GetRandomArray();
	if(values.Any())
		Console.WriteLine(values.First());
}


This could be fixed by allowing InstantHandleAttribute to be placed on methods, which would indicate that the return values are not deferred:

proposed attribute usage
[InstantHandle]
public IEnumerable<int> GetRandomArray()
{
	return new[] { 4 };
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>