Bug 5413 - Missing interface on created object when creating new class instance using Mono.CSharp.Evaluator.Evaluate()
Summary: Missing interface on created object when creating new class instance using Mo...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2012-05-30 11:22 UTC by m.eischeid
Modified: 2012-09-06 15:09 UTC (History)
1 user (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 m.eischeid 2012-05-30 11:22:19 UTC
When creating a class instance with evaluator.Evaluate(), the created object does'nt implement the given interface. Please see annotations in code:

namespace ConsoleApplication2
    public interface ITest
        string Value { get; }

    class Program
        static void Main(string[] args)
            CompilerSettings settings = new CompilerSettings();
            ReportPrinter reportPrinter = new ConsoleReportPrinter();
            CompilerContext context = new CompilerContext(settings, reportPrinter);
            Evaluator evaluator = new Evaluator(context);
            evaluator.Run("using ConsoleApplication2;");
            // Define class with interface implementation.
                @"public class Test : ITest" +
                @"{" +
                @"    public override string Value" +
                @"    {" +
                @"        get { return ""bla""; }" +
                @"    }" +
            // Create instance and cast to ITest.
            object instance = evaluator.Evaluate(@"new Test();");
            ITest test = instance as ITest;

            Console.WriteLine("Instance is null = " + (instance == null));
            Console.WriteLine("Instance typename = " + instance.GetType().Name);

            // Here should one interface be found.
            Console.WriteLine("Instance interface# = " + instance.GetType().GetInterfaces().Length);

            // The created instance have been casted to ITest.
            Console.WriteLine("Test is null = " + (test == null));
Comment 1 Marek Safar 2012-09-06 15:09:43 UTC
It should be fixed in master