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

RSRP-288540: The hint to make an interface covariant or contravariant should not apply to Windows Phone assemblies

$
0
0
Reporter Ian Johnson (Ian.Johnson) Ian Johnson (Ian.Johnson)
Created Feb 26, 2012 4:26:19 PM
Updated Feb 26, 2012 4:42:06 PM
Priority Major
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Sergey Coox (coox)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
I created a new Windows Phone 7 Panorama project and produced two interfaces for writing to and reading from streams:


public interface IReader<T> { T Read(Stream stream); }
public interface IWriter<T> { void Write(Stream stream, T); }


These were referenced from the main view model and were being used to read data in from the isolated file storage. The default MainViewModel is referenced in App.xaml.cs.

Resharper gives a hint that IReader<T> can be changed to IReader<out T> and IWriter<T> can be changed to IWriter<out T>, I did as resharper advised. It compiled successfully (I'll be raising an issue with Microsoft about that) and when I ran the project the splash screen loaded in the emulator and then the app disappeared without any error being raised.

The .NET compact framework does not support this and Resharper should not be recommending that we use in and out generic type parameters on projects for windows phone (and maybe silverlight)

I have created a sample test project and attached it in a failing state. The IReader<out T> interface is set to be covariant, turn it back to IReader<T> and the project will run successfully but Resharper will give you a hint to The type parameter T could be declared as covariant.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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