public void Jagged() { // Resharper is unable to infer the type of arr[1] without the previous declaration of arr. // Technically this code is invalid since arr is not initialized. CompleteInMethod(@" int[][] arr; int i = arr[1][2]; $"); AssertBody( VarDecl("arr", Names.Type(NFix.IntArr(2))), VarDecl("i", Fix.Int), VarDecl("$0", Fix.IntArray), Assign( "$0", new IndexAccessExpression { Reference = VarRef("arr"), Indices = { Const("1") } }), Assign( "i", new IndexAccessExpression { Reference = VarRef("$0"), Indices = { Const("2") } }), Fix.EmptyCompletion); }
public void AssigningValueToArrayElement_Jagged() { CompleteInMethod(@" int[][] arr; arr[1][2] = 1; $"); AssertBody( VarDecl("arr", Names.Type(NFix.IntArr(2))), VarDecl("$0", Fix.IntArray), Assign( "$0", new IndexAccessExpression { Reference = VarRef("arr"), Indices = { Const("1") } }), Assign( new IndexAccessReference { Expression = new IndexAccessExpression { Reference = VarRef("$0"), Indices = { Const("2") } } }, Const("1")), Fix.EmptyCompletion); }
public void ShouldTranslateMethodVarArgsParameterProposal() { CompleteInCSharpFile(@" class C { public void M(params Object[] objs) { this.$ } }"); ThenProposalCollectionContains( "[{0}] [C, TestProject].M(params [{1}] objs)", Fix.Void, Fix.ObjectArr(1)); }
public void ShouldTranslateArrayTypeProposals() { CompleteInCSharpFile(@" public class C { private string[] myStringArray; private object[,,] myMultidimensionalArray; private object[][][] myJaggedArray; private void myMethod<R>(R[] p) {} public void TriggerCompletionHerein() { this.my$ } }"); ThenProposalCollectionContainsMulti( "[{0}] [C, TestProject].myJaggedArray".FormatEx(Fix.ObjectArr(3)), "[{0}] [C, TestProject].myMethod`1[[R]]([R[]] p)".FormatEx(Fix.Void), "[{0}] [C, TestProject].myMultidimensionalArray".FormatEx(Fix.ObjectArr(3)), "[{0}] [C, TestProject].myStringArray".FormatEx(Fix.StringArr(1))); }