Bug 19423

Summary: Testing if a dynamic Type variable is a string
Product: [Mono] Compilers Reporter: Leandro <leandro>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: lluis, masafa, mono-bugs+monodevelop, mono-bugs+mono, mono-bugs+runtime
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Leandro 2014-04-30 12:21:32 UTC
Description of Problem: 

When comparing if a dynamic Type variable is a string, it returns true even if it has a int or bool value.


Steps to reproduce the problem:

public void TestDynamic(dynamic value){
    if (value != null) {
	Console.Write (String.Concat(value.GetType().FullName,": ",value));
    }
    if (value is int) {
	Console.WriteLine (" - I'm a int;");
    }
    if (value is bool) {
	Console.WriteLine (" - I'm a bool;");
    }
    if (value is string) {
        Console.WriteLine (" - I'm a string;");
    }
}

TestDynamic ("a");
TestDynamic (1);
TestDynamic (true);
TestDynamic (null);

Actual Results:

System.String: a - I'm a string;
System.Int32: 1 - I'm a int;
 - I'm a string;
System.Boolean: True - I'm a bool;
 - I'm a string;

Expected Results:

System.String: a - I'm a string;
System.Int32: 1 - I'm a int;
System.Boolean: True - I'm a bool;

How often does this happen? Always

Additional Information:

Its happenning since I updated my operating system to Ubuntu 14.04 LTS with MonoDevelop 4.0.12. It doesn't happen on Ubuntu 13.10 with MonoDevelop 3.0.3.2
Comment 1 Marek Safar 2014-05-02 12:02:44 UTC
Fixed in master