Bug 4385 - Cannot set value of a nullable from immediate window
Summary: Cannot set value of a nullable from immediate window
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-04-10 17:40 UTC by Jonathan Pobst
Modified: 2012-04-25 05:11 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pobst 2012-04-10 17:40:35 UTC
If you have a nullable variable, you cannot change the value from the immediate window.

int? foo = null;

> foo = 6
Evaluation failed.

Stacktrace from Visual Studio version:

System.ArgumentException: Value does not match the type of the local variable.
   at Mono.Debugger.Soft.StackFrame.SetValue(LocalVariable var, Value value) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugger.Soft\Mono.Debugger.Soft\StackFrame.cs:line 155
   at Mono.Debugging.Soft.VariableValueReference.set_Value(Object value) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging.Soft\VariableValueReference.cs:line 75
   at Mono.Debugging.Evaluation.EvaluatorVisitor.VisitAssignmentExpression(AssignmentExpression assignmentExpression, Object data) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging\Mono.Debugging.Evaluation\NRefactoryEvaluator.cs:line 809
   at ICSharpCode.OldNRefactory.Ast.AssignmentExpression.AcceptVisitor(IAstVisitor visitor, Object data) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\NRefactory\Project\Src\Ast\Generated.cs:line 247
   at Mono.Debugging.Evaluation.NRefactoryEvaluator.Evaluate(EvaluationContext ctx, String exp, Object expectedType, Boolean tryTypeOf) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging\Mono.Debugging.Evaluation\NRefactoryEvaluator.cs:line 97
   at Mono.Debugging.Evaluation.NRefactoryEvaluator.Evaluate(EvaluationContext ctx, String exp, Object expectedType) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging\Mono.Debugging.Evaluation\NRefactoryEvaluator.cs:line 49
   at Mono.Debugging.Evaluation.ExpressionEvaluator.Evaluate(EvaluationContext ctx, String exp) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging\Mono.Debugging.Evaluation\ExpressionEvaluator.cs:line 40
   at Mono.Debugging.Evaluation.ObjectValueAdaptor.GetExpressionValue(EvaluationContext ctx, String exp) in D:\Documents\Visual Studio 2010\Projects\AndroidVS\External\Mono.Debugging\Mono.Debugging.Evaluation\ObjectValueAdaptor.cs:line 1039
Comment 1 Jeffrey Stedfast 2012-04-12 18:30:27 UTC
looks like a runtime issue unless MonoDevelop is supposed to first cast 6 to an Nullable<int> ?
Comment 2 Zoltan Varga 2012-04-25 04:27:59 UTC
It would be better to handle this in md, handing it in the runtime would get quite complex. I can add some functionaiity to Mono.Debugger.Soft to make this easier/possible.
Comment 3 Zoltan Varga 2012-04-25 05:11:41 UTC
Fixed in master.