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

RSRP-289048: ReSharper fails to correctly resolve extension methods in some cases

$
0
0
Reporter Daniel Cassidy (djcsdy) Daniel Cassidy (djcsdy)
Created Mar 5, 2012 10:20:03 PM
Updated Mar 5, 2012 10:20:03 PM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem No subsystem
Affected versions 6.1
Fixed in build No Fixed in build
This minimal project on GitHub demonstrates a case where ReSharper 6.1 fails to correctly resolve an extension method.

As a result, ReSharper reports an error on this line, even though the program compiles and runs perfectly. Also, ReShaprer is unable to correctly navigate to the extension method via ctrl+click (it instead asks the user to choose from a list of candidate methods).

ReSharper 5 does not have this problem, so this is a regression.

Note that the solution is split into two projects: BrokenExtensionMethodResolution targets .NET 4, and Furniture targets .NET 3.5. This is significant.

If both projects were targeting .NET 3.5, then ReSharper’s error report would be correct, since IEnumerable<T> is not covariant in .NET 3.5.

It appears that ReSharper is applying the typing rules from .NET 3.5 since the type is declared in a .NET 3.5 project. But .NET itself appears to apply the typing rules from .NET 4 because the type is used in a .NET 4 project.

To illustrate this, see also:
  • The explicit-type branch, in which ReSharper resolves the extension method correctly, since the type is now declared in a .NET 4 project.
  • The inferred-type branch, in which ReSharper still reports an error, since the type is inferred from a .NET 4 project, and consequently still effectively declared in the .NET 3.5 project.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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