Bug 6956 - Expression Evaluator parser does not perform implicit conversions (C#)
Summary: Expression Evaluator parser does not perform implicit conversions (C#)
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: Macintosh Mac OS
: Normal minor
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2012-09-06 10:57 UTC by Yvan Rodrigues
Modified: 2017-07-13 00:00 UTC (History)
5 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 for Bug 6956 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Yvan Rodrigues 2012-09-06 10:57:15 UTC
Depending on your perspective this is a missing feature, a feature request, or a bug. If the goal it to reproduce Visual Studio's behaviour it is a bug; otherwise it is more of a missing feature.

The Expression Evaluator does not perform implicit conversions.

For example lets say you had a method:

string foo(uint bar)
    return bar.ToString();

If you put in the Expression Evaluator: foo(42)
It returns: Invalid arguments for method `foo': Argument 0: Cannot implicitly convert `System.Int32' to `System.UInt32'

To get the expected behaviour you would need to use: foo(42U).

I acknowledge that this is not a true implicit conversion (an implicit conversion doesn't exist from int to uint) but rather a "common use" conversion that Visual Studio performs on behalf of the programmer. On the other hand, take the second example:

Let's say you have field: XDocument foo;

And you wish to evaluate: foo.Attribute("bar")
It returns: Invalid arguments for method `Attribute: Argument 0: Cannot implicitly convert `System.String' to `System.Xml.Linq.XName'

In this case an implicit conversion *does* existing in the XName class to convert string to XName.

To get the expected behaviour you would need to use: foo.Attribute(new XName("bar")). Now you can see it would start getting annoying, particularly if the expression you are evaluating requires several explicit conversions to be useful.
Comment 1 Yvan Rodrigues 2012-09-07 13:10:37 UTC
For what it's worth, I have observed that the behaviour is the same when you inspect expressions by hovering over them.
Comment 2 Jeffrey Stedfast 2012-09-18 15:37:19 UTC
This appears to be a runtime bug...

Zoltan: the problem appears to be that TypeMirror.IsAssignableFrom (TypeMirror) is returning false when it shouldn't.
Comment 3 Zoltan Varga 2012-09-27 14:23:11 UTC
For what types IsAssignableFrom () doesn't work ?
Comment 4 Rodrigo Kumpera 2017-07-13 00:00:40 UTC
System.Uint32 and System.Int32