roslyn: Scripting API: metadata references not backed by a file don't load
Scenario:
var s = await CSharpScript.EvaluateAsync("new MyLib.Class()", ScriptOptions.Default.AddReferences(
MetadataReference.CreateFromImage(File.ReadAllBytes(@"file.dll"))))
fails since the in-memory assembly is not registered with InteractiveAssemblyLoader.
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 9
- Comments: 16 (5 by maintainers)
Kinda sad that this issue hasn’t been touched in 7 years with no visible change on that matter to come. That’s the first usage scenario that comes to my mind when using scripts: Passing in a globals object, that is not necessarily inside a physical assembly. Takes a lot of the “dynamic” out of scripting.
This is a bummer. I was really excited about using Roslyn as a scripting engine but this limits the use case drastically as I understand it. To only be able to use a predefined class to pass in variables to a script would mean that we would have to have some sort of understanding about what variables are required by the script itself. The whole idea around a scripting engine would be to have the ability to pass in dynamic variables at runtime. I’ve come up with a pretty ugly solution but I feel this should be handled OOB for sure.
Is any progress on supporting ExpandoObject or Anonymous?
I can’t believe the dynamic type isn’t even supported 😦
Anonymous types aren’t supported either
Has anyone found any kind of work-around to being required to use static predefined types to pass data to these dynamic scripts?
For fleunt implementation it must be dynamic object with variables or just wtih simple properpties
globals =new Object(){ x=null, y=null}; await CSharpScript.EvaluateAsync<int>(“X+Y”, globals: globals)
PHP is more fleunt is this case ! Roslyn lose to php in this use case ! to saaaaaddd