Extract method is easily confused within lambda expressions.
I feel plugging the holes in terms of what it offers will also help in wringing out the rest of the bugs in this space, so I have added in some associated extractions that are not being offered.
Steps to Reproduce:
public class Tests
{
class A
{
public int Xx { get; set; }
}
public void Test()
{
A a = new A();
Action action = () => a.Xx = 1;
Action<A> actionB = b => b.Xx = 1;
Action<A> actionC = c => { c.Xx = 1; };
Action<A> actionD = d => { a.Xx = 1; };
Func<int> func = ()=>a.Xx+2;
}
}
(I had a better repro where it was not dropping the return type and param type to object unnecessarily for a failry simple case but cant get it now)
Actual Results:
Extract on "a.Xx" yields wrong code
Extract Method to A on "a.Xx" yields wrong code
Extract on "b.Xx" yields wrong code
Extract/Extract Method To on "a.XX" and "a.Xx+2" in "Func<int> func = ()=>a.Xx+2;" yields wrong code
Extract on "a.Xx = 1" doesnt work
Extract on "b.Xx = 1" doesnt work
Extract on "c.Xx" doesnt work
Extract on "a.Xx = 1" and "a.Xx" in "Action<A> actionD = d => { a.Xx = 1; };" doesnt work
Expected Results:
It should all work as smoothly as the rest of the product…
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Another missing one is:
Normally, I can do
TestContext testContext = …;
DataRow firstRow = testContext.MainTable.Rows[ 0 ];
Then hilight "testContext.MainTable.Rows[ 0 ]" and extract to
Inside a lamda expression, it doesnt:
RunATest( testContext => {
DataRow firstRow = testContext.MainTable.Rows[ 0 ];
});
Hilighting the same piece doesnt offer the extract to.
Remember, the reason a lot of people arent looking for this is because they're not using it yet. That doesnt mean they won't, and it doesnt mean tyhe competition won't support it…