Why does ReSharper tell me “implicitly captured closure”?

I have the following code: public double CalculateDailyProjectPullForceMax(DateTime date, string start = null, string end = null) { Log(“Calculating Daily Pull Force Max…”); var pullForceList = start == null ? _pullForce.Where((t, i) => _date[i] == date).ToList() // implicitly captured closure: end, start : _pullForce.Where( (t, i) => _date[i] == date && DateTime.Compare(_time[i], DateTime.Parse(start)) > 0 … Read more

Visual Studio displaying errors even if projects build

I have a problem with Visual Studio on a C# solution. It displays totally random errors, but the projects build. Right now, I have 33 files with errors, and I can see red squiggly lines in all of them. I tried cleaning / rebuilding the solution, closing Visual Studio and even restarting my computer. I … Read more

Access to Modified Closure

string [] files = new string[2]; files[0] = “ThinkFarAhead.Example.Settings.Configuration_Local.xml”; files[1] = “ThinkFarAhead.Example.Settings.Configuration_Global.xml”; //Resharper complains this is an “access to modified closure” for (int i = 0; i < files.Length; i++ ) { // Resharper disable AccessToModifiedClosure if(Array.Exists(Assembly.GetExecutingAssembly().GetManifestResourceNames(), delegate(string name) { return name.Equals(files[i]); })) return Assembly.GetExecutingAssembly().GetManifestResourceStream(files[i]); // ReSharper restore AccessToModifiedClosure } The above seems to work … Read more

Handling warning for possible multiple enumeration of IEnumerable

In my code I need to use an IEnumerable<> several times, resulting in the ReSharper error of “Possible multiple enumeration of IEnumerable“. Sample code: public List<object> Foo(IEnumerable<object> objects) { if (objects == null || !objects.Any()) throw new ArgumentException(); var firstObject = objects.First(); var list = DoSomeThing(firstObject); var secondList = DoSomeThingElse(objects); list.AddRange(secondList); return list; } I … Read more