a lambda error on resharper 5.0

i download the resharper 5.0 for vs 2010 ,but i found a error ,my code is :

     data.AfterReceiveData+={(s,e)=>{  //  do something }}

AfterReceiveData is a delegate . when i use resharper 4.5 for vs 2008,these code is normal but  5.0 is show the error ....and i build the sln , alway is normal .

8 comments
Comment actions Permalink

I too am receiving this error.  My code snippet is:

mappers.Where(mapper => mapper.IsActive)

Very simple.  I noticed that if I get rid of the "using System.Linq" and "using System.Linq.Expressions" directives in my file, then when I put my cursor on the "Where", RS gives me the suggestion:
"Reference 'System.Core' and Import 'System.Linq'".  However, that operation fails.  I checked my project references and there is no reference to System.Core (4.0.0.0) in my project.  I tried to add one explicitly, and VS gives the error:

A reference to 'System.Core' could not be added.  This component is already automatically referenced by the build system.

My guess is that because the reference to System.Linq is not explicit (not in the .csproj file), RS doesn't know it's there, so it doesn't parse the code properly.  In fact, the 2 using directives in my file (using System.Linq and using System.Linq.Expressions) are grayed out by RS, suggesting I remove them since they are not being used.  Well they are being used, and removing them causes my build to fail.

Perhaps this "automatically referenced" thing was a last minute change to VS behavior?

Please fix soon!  I don't like seeing the red bars in my scrollbar when it builds fine.  I also don't like seeing suggestions that, when followed, break my builds.

0
Comment actions Permalink

Same errors here.  Very annoying.  Everything builds fine, but I don't dare run the full cleanup, as it will remove the System.Linq references.

The only workaround that I've been able to get working is to switch resharper to use VS IntelliSense, and not resharper by default.

0
Comment actions Permalink

Hello
     Could you please attach a small sample solution demonstrating this problem? Thank you!

Andrey Serebryansky

Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"
0
Comment actions Permalink

Finally got the repro.  It didn't work when I created a new VS2010 solution and simply did:

int[] myInts = {1, 2, 3};

myInts.Where(i => i > 2);

So I was confused:  Why did this solution work, but not my other one?  I thought maybe it was because my other solution was upgraded from VS2008, so I tried that.  Still no repro.  Then I noticed that my new VS2010 solution (upgraded not just to VS2010, but also .NET 4) still had a reference to System.Core.  I removed it, and the error came back.  Then I tried to re-add a reference to System.Core 4.0, and VS gives the error that it can't, because it's already automatically referenced by the build system.

The one part I don't know is how my other project (where I first experienced the bug) had its reference to System.Core removed.  I know I didn't do it manually.  However, VS2010 won't let me add it, so I'm stuck with the resharper errors.

Hope this helps.

VS2010 solution attached.  Was created in VS2008, upgraded to VS2010, upgraded to .NET 4, had System.Core ref removed, then the Resharper errors came.  All in that order.  Notice that it builds and runs just fine.

UPDATE:  Before I sent this, I reopened the project, and it no longer shows the errors.  I think the workaround might be as simple as closing and reopening the solution.  So the attached project will probably not show you RS errors, but if you follow the steps outlined yourself, you'll at least be able to repro the bug.  Good luck!


Sam



Attachment(s):
LambdaConversionTest.zip
0
Comment actions Permalink

Hello Sam
     I'm afraid we weren't able to reproduce the problem with the sample provided. Have you tried clearing caches (ReSharper > Options > General > Clear Caches) after removing the reference to System.Core? Thank you!

Andrey Serebryansky

Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Of course you couldn't reproduce it with the attached sample.  I told you that you wouldn't be able to, and that you had to follow the steps outlined.

1. Create a .NET 3.5 project in VS2008 with a lambda expression such as:

int[] myInts = {1, 2, 3};
myInts.Where(i => i > 2);

2. Close and save

3. Open the solution in VS2010 and upgrade it.

4. Go to the project properties and change the target framework to 4.0

5. Remove the reference to System.Core

At that point you'll have resharper errors on the screen, but the project will still build and run just fine.  Also, you'll not be able to add a reference to System.Core.  If you close the solution and reopen it, it will probably fix it anyway.

0
Comment actions Permalink

Sam,

I certainly could replicate the RS bar errors you mentioned. I suspended RS in VS 2010's Tools ->  Options dialog but under no conditions could I add System.Core back as a reference. I'm sort of wondering if that might be a VS 2010 problem and not something RS introduced? Thought I'd mention it all the same.

0
Comment actions Permalink

Hello Sam
     Thank you for clarification! I've created a bug-report in our tracker: http://youtrack.jetbrains.net/issue/RSRP-179075 and you're welcome to monitor its status.

Andrey Serebryansky

Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.