I changed the example that comes with the new version of Roslyn that was released yesterday to use dynamic and ExpandoObject, but I get a compiler error that I donβt know how to fix. Mistake:
(7,21): error CS0656: The required compiler member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' is missing
Can you use dynamics in the new compiler? How can i fix this? Here is an example that I updated:
[TestMethod] public void EndToEndCompileAndRun() { var text = @"using System.Dynamic; public class Calculator { public static object Evaluate() { dynamic x = new ExpandoObject(); x.Result = 42; return x.Result; } }"; var tree = SyntaxFactory.ParseSyntaxTree(text); var compilation = CSharpCompilation.Create( "calc.dll", options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), syntaxTrees: new[] {tree}, references: new[] {new MetadataFileReference(typeof (object).Assembly.Location), new MetadataFileReference(typeof (ExpandoObject).Assembly.Location)}); Assembly compiledAssembly; using (var stream = new MemoryStream()) { var compileResult = compilation.Emit(stream); compiledAssembly = Assembly.Load(stream.GetBuffer()); } Type calculator = compiledAssembly.GetType("Calculator"); MethodInfo evaluate = calculator.GetMethod("Evaluate"); string answer = evaluate.Invoke(null, null).ToString(); Assert.AreEqual("42", answer); }
c # roslyn
Rush Frisby Apr 04 '14 at 13:53 on 2014-04-04 13:53
source share