Skip to content

Commit 7817325

Browse files
committed
Eval tests for generic invocations
1 parent 66ad4d7 commit 7817325

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

MonoDevelop.Debugger.Tests.TestApp/AdvancedEvaluation.cs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task Bug24998 ()
8686
someVariable.Add (someField);/*cc622137-a162-4b91-a85c-88241e68c3ea*/
8787
}
8888

89-
89+
9090
public void InvocationsCountDuringExpandingTest ()
9191
{
9292
var mutableFieldClass = new MutableFieldClass ();
@@ -118,6 +118,77 @@ public MutableField(int x)
118118
this.x = x;
119119
}
120120
}
121+
122+
public void MethodWithTypeGenericArgsEval ()
123+
{
124+
var a = new A("Just A");
125+
var wrappedA = new Wrapper<A>(new A("wrappedA"));
126+
var genericClass = new GenericClass<A>(new A("Constructor arg A"));
127+
//genericClass.BaseMethodWithClassTArg (wrappedA);
128+
//genericClass.RetMethodWithClassTArg (a)
129+
Console.WriteLine("Break for MethodWithTypeGenericArgsEval");/*ba6350e5-7149-4cc2-a4cf-8a54c635eb38*/
130+
}
131+
132+
class A
133+
{
134+
public A(string myProp)
135+
{
136+
MyProp = myProp;
137+
}
138+
139+
public string MyProp { get; set; }
140+
141+
public override string ToString()
142+
{
143+
return MyProp;
144+
}
145+
}
146+
147+
class GenericBaseClass<TBaseClassArg>
148+
{
149+
public readonly TBaseClassArg myArg;
150+
151+
public GenericBaseClass(TBaseClassArg arg)
152+
{
153+
myArg = arg;
154+
}
155+
156+
public TBaseClassArg BaseMethodWithClassTArg(TBaseClassArg arg)
157+
{
158+
return arg;
159+
}
160+
161+
162+
}
163+
164+
class Wrapper<TObj>
165+
{
166+
public TObj obj;
167+
168+
public Wrapper(TObj obj)
169+
{
170+
this.obj = obj;
171+
}
172+
173+
public override string ToString()
174+
{
175+
return string.Format("Wrapper({0})", obj);
176+
}
177+
}
178+
179+
class GenericClass<TOfClass> : GenericBaseClass<Wrapper<TOfClass>>
180+
{
181+
public GenericClass(TOfClass arg) : base(new Wrapper<TOfClass>(arg))
182+
{
183+
}
184+
185+
public void VoidMethodWithClassTArg(TOfClass tOfClass) {}
186+
public TOfClass RetMethodWithClassTArg(TOfClass tOfClass) {return tOfClass;}
187+
188+
public void VoidMethodWithMethodTArg<TOfMethod>(TOfMethod tOfMethod) { }
189+
public void VoidMethodWithMethodAndClassTArg<TOfMethod>(TOfMethod tOfMethod, TOfClass tOfClass) { }
190+
191+
}
121192
}
122193
}
123194

MonoDevelop.Debugger.Tests/AdvancedEvaluationTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@ public void InvocationsCountDuringExpandingTest ()
180180

181181
Assert.AreEqual ("2", sharedX.Value);
182182
}
183+
184+
[Test]
185+
public void MethodWithTypeGenericArgsEval ()
186+
{
187+
InitializeTest ();
188+
AddBreakpoint ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38");
189+
StartTest ("MethodWithTypeGenericArgsEval");
190+
CheckPosition ("ba6350e5-7149-4cc2-a4cf-8a54c635eb38");
191+
192+
var baseMethodEval = Eval ("genericClass.BaseMethodWithClassTArg (wrappedA)");
193+
Assert.NotNull (baseMethodEval);
194+
Assert.AreEqual ("{Wrapper(wrappedA)}", baseMethodEval.Value);
195+
196+
var thisMethodEval = Eval ("genericClass.RetMethodWithClassTArg (a)");
197+
Assert.NotNull (thisMethodEval);
198+
Assert.AreEqual ("{Just A}", thisMethodEval.Value);
199+
}
200+
201+
183202
}
184203
}
185204

0 commit comments

Comments
 (0)