当我尝试导入 System.Linq boo编译器的名称空间,我得到此错误:

boo.lang.compiler.com pilererror:

找不到名称空间“ system.linq”,也许您忘了添加汇编引用?

我使用“ rhino.dsl.dll”,我的DSL引擎代码在这里:

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());
    }
}
有帮助吗?

解决方案

为什么您需要DSL中的system.linq? sytem.linq必须在您的框架中“隐藏”。除了在Boo中使用Linq外,它还有点冗长(在我看来),您的DSL应该隐藏此冗长的东西...

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()

关于使用system.linq,没有尝试过,但我找到了此链接 Boo Markmail, ,上面的代码被复制...

其他提示

尝试添加对 System.Core 组装您的项目。 大多数班级 System.Linq 名称空间在该组件中找到。

如果那不起作用,您也可以尝试添加参考 System.Data.Linq.

并且将来,不要低估编译器提供的错误消息的有用性。是的,有时它们是神秘的,有时他们甚至会误导。但是,当您试图弄清楚为什么不希望您工作的某些内容时,它们当然是一个很好的起点。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top