How to import a System.Linq namespace into Boo?

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

Boo.Lang.Compiler.CompilerError:

Namespace 'System.Linq' not found, maybe you forgot to add a link to the assembly?

I am using "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 my repository framework )); pipeline.Insert(2, new UseSymbolsStep()); pipeline.Insert(3, new RunScriptCompilerStep()); } } 
+4
source share
2 answers

Why do you need System.Linq in DSL? Sytem.Linq should be "hidden" in your structure. Besides using Linq in Boo, this is kind 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() 

I have not tried using System.Linq, but I found this Boo Markmail link where the code above was copied ...

+3
source

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

If this does not work, you can also try adding a link to System.Data.Linq .

And in the future, do not underestimate the usefulness of error messages provided by the compiler. Yes, sometimes they are mysterious, and sometimes they are even misleading. But they are certainly a good place to start when you are trying to understand why something will not compile, what you expected to work.

+4
source

Source: https://habr.com/ru/post/1334045/


All Articles