Bug 6956 - Expression Evaluator parser does not perform implicit conversions (C#)
Summary: Expression Evaluator parser does not perform implicit conversions (C#)
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: Normal minor
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-06 10:57 UTC by Yvan Rodrigues
Modified: 2017-07-13 00:00 UTC (History)
5 users (show)

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


Attachments

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

Note You need to log in before you can comment on or make changes to this bug.