Bug 11795 - Use of regex in linq statement not being recognized.
Summary: Use of regex in linq statement not being recognized.
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.0.3
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-04-15 11:32 UTC by Jake Hall
Modified: 2013-05-03 05:14 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screenshot -- see the 'corrective action' recommended on the initialization (249.94 KB, image/png)
2013-04-15 11:32 UTC, Jake Hall
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jake Hall 2013-04-15 11:32:56 UTC
Created attachment 3814 [details]
Screenshot -- see the 'corrective action' recommended on the initialization

Using a RegEx only within the Where statement of a linq statement is not being recognized.  The editor is saying "Warning: Remove Redundant Assignment".  Using the regex method chaining in contrast is recognized:

public void Demo ()
{
	// IDE is incorrectly saying this is not being used
	Regex pattern = new Regex (@"^.*\.(jpg|png)$", RegexOptions.IgnoreCase);
	string path = Path.Combine (NSBundle.MainBundle.BundlePath, "speakers");

	AddRange (from file in Directory.GetFiles (path)
	         where pattern.IsMatch (file)
	         select new Speaker { ImageFile = "speakers/" + Path.GetFileName(file) });

	// uncomment this use to see the designer stop complaining about the redundant assignment
	//AddRange (Directory.GetFiles (path).Where (pattern.IsMatch)
	//	.Select (p => new Speaker{ImageFile = "speakers/" + Path.GetFileName(p) }));
}
Comment 1 Mike Krüger 2013-05-03 05:14:11 UTC
fixed