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

RSRP-297466: Warn me if typeof(...) expressions of wrong type is provided where a specific kind of types (delegates, enums etc) is expected

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Apr 25, 2012 1:38:47 AM
Updated Apr 26, 2012 3:40:58 AM
Priority Normal
Type Feature
Fix versions No Fix versions
State Submitted
Assignee Evgeny Pasynkov (pasynkov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Reflection;

class A
{
    static void Main()
    {
        var x = Delegate.CreateDelegate(typeof(Comparison<string>), typeof(string), "Compare"); // OK
        var y = Delegate.CreateDelegate(typeof(Comparer<string>), typeof(string), "Compare"); // System.ArgumentException: Type must derive from Delegate.

        var a = Enum.Parse(typeof(EventAttributes), "None"); // OK
        var b = Enum.Parse(typeof(EventAttribute), "None"); // System.ArgumentException: Type provided must be an Enum.
    }
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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