Project
ReSharper
Priority
Normal
Type
Bug
Fix versions
4.5, 4.5.1, 5.0
State
Fixed
Assignee
Sergey Shkredov
Subsystem
No subsystem
Affected versions
No Affected versions
Fixed in build
No Fixed in build
  • Created by   Serge Baltic
    4 years ago (07 Oct 2007 06:17)
  • Updated by   Olga Lobacheva
    23 months ago (15 Feb 2010 21:45)
  • Jira: RSRP-50606
    (history, comments)
 
RSRP-50606 Introduce Variable: Merges Occurences of Incompatible Types
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
Before:
public class Test
{
	public static void Do()
	{
		DictionaryEvents<string, string> dict = new DictionaryEvents<string, string>();
		CollectionEvents<string> coll = new CollectionEvents<string>();

		dict.BeforeAddRemove += delegate { throw new InvalidOperationException(string.Format("Whoops!")); };
		coll.BeforeAddRemove += delegate { throw new InvalidOperationException(string.Format("Whoops!")); };
	}
}


After introducing from "delegate ... }; ", "Replace All" mode:

public class Test
{
	public static void Do()
	{
		DictionaryEvents<string, string> dict = new DictionaryEvents<string, string>();
		CollectionEvents<string> coll = new CollectionEvents<string>();

		EventHandler<BeforeAddRemoveEventArgs<KeyValuePair<string, string>>> handler = delegate { throw new InvalidOperationException(string.Format("Whoops!")); };
		dict.BeforeAddRemove += handler;
		coll.BeforeAddRemove += handler;
	}
}


The coll.BeforeAddRemove += handler; line has an error because the delegate types are not compatible (have different event args).

The "replace all" candidates should be filtered more thoroughly.

Issue was closed
Comments (0)
 
History
 
Linked Issues (?)
 
TeamCity Changes (0)
 
Issue has no comments