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

RSRP-334005: Extract Superclass has problems with generic method call

$
0
0
Reporter Daniel Hilgarth (DanielH) Daniel Hilgarth (DanielH)
Created Nov 1, 2012 3:48:28 PM
Updated Apr 26, 2018 11:42:25 AM
Resolved Apr 26, 2018 11:42:25 AM
Subsystem Refactorings
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Fixed
Type Bug
Fix version Unidentified prior version
Affected versions 8.0
Fixed In Version ReSharper Undefined
VsVersion All Versions
The following methods have been moved to a super class using the Resharper "Extract Superclass" feature:

private Uri GetSelf(TEntity entity)
{
return GetSelf(entity, (dynamic)this);
}

private Uri GetSelf<TController>(TEntity entity, TController dummy) where TController : CrudControllerBase<TModel, TEntity>
{
return _routeLinker.GetUri<TController>(c => c.GetById(entity.Id));
}

The second method got moved correctly, but the first one resulted in the following:

private Uri GetSelf(TEntity entity)
{
return GetSelf<object>(entity, (dynamic)this);
}

Note the generic type parameter.
This doesn't compile as object isn't a CrudControllerBase<TModel, TEntity>. That's how I noticed the error.
However, in cases where there isn't a constraint it would compile but change the behavior of the code, as the type inference of the DLR doesn't kick in any more.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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