Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I import the System.Linq namespace to Boo?

Tags:

namespaces

c#

boo

When I try to import the System.Linq namespace to Boo compiler, I get this error:

Boo.Lang.Compiler.CompilerError:

Namespace 'System.Linq' not found, maybe you forgot to add an assembly reference?

I use "Rhino.DSL.dll" and my DSL engine code is here:

public class MyDslEngine : DslEngine
{
    protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
    {
        pipeline.Insert(1, new AnonymousBaseClassCompilerStep(typeof(DslBase), "Prepare",
            "System.Linq",
            "Azarakhsh.Framework.Repository" //it's my repository framework
            ));
        pipeline.Insert(2, new UseSymbolsStep());
        pipeline.Insert(3, new RunScriptCompilerStep());
    }
}
like image 679
Omid-RH Avatar asked Feb 25 '23 11:02

Omid-RH


2 Answers

Why do you need System.Linq in your DSL? Sytem.Linq must be "hidden" in your framework. Besides using Linq in Boo, it's kinda of verbose (in my opinion) and your DSL should hide this verbose stuff...

import System.Linq.Enumerable from System.Core
bar = List of string() 
bar.Add("foo")
bar.Add("baz")

baz = bar.Where({x as string | x =="baz"}).Single()

About using the System.Linq, haven't tried but I found this link Boo Markmail, where the code above was copied...

like image 61
jjchiw Avatar answered Feb 28 '23 00:02

jjchiw


Try adding a reference to the System.Core assembly to your project. Most of the classes in the System.Linq namespace are found in that assembly.

If that doesn't work, you might also try adding a reference to System.Data.Linq.

And in the future, don't underestimate the usefulness of the error messages provided by the compiler. Yes, sometimes they are cryptic and other times they are even misleading. But they're certainly a good place to start when you're trying to figure out why something won't compile that you expected to work.

like image 44
Cody Gray Avatar answered Feb 28 '23 00:02

Cody Gray