.fsx 中的 IntelliSense 和动态加载的程序集
当使用 #I
和 #r
动态引用 .fsx 中的程序集时,VS 会突出显示导入类型的以下用法并写入“命名空间或模块 'XXX' 未定义” 。可以吗?
例如,在下面的代码中,
#I @".\Tools\FAKE"
#r "FakeLib.dll"
open Fake
Target "Hello" (fun _ -> trace "hello!")
Run "Hello"
VS 突出显示 Fake
并显示“命名空间或模块 'Fake' 未定义”,它还突出显示 Target
和 Run.我在 VS 2010 SP1 和 VS 11 CTP 中遇到这个问题。这个问题使得编写 F# 脚本变得更加困难。
顺便说一句,“常见”类型的 IntelliSence 效果很好。 FakeLib.dll
和 FakeLib.xml
位于 .\Tools\FAKE
目录中。代码运行良好。
更新1 这是情况的屏幕截图。您可以看到 VS 正确解析程序集 FakeLib
(在工具提示中),同时 Intellisense“查看”标准类型(Console
上的工具提示)类。
更新 2 我认为我的工作工作站上的 IntelliSense 有问题,因为它(IntelliSense)的行为本身很奇怪。当我启动 VS 并打开 .fsx 文件时,IntelliSense 甚至拒绝解析标准类型/类,并且它不会强调 FAKE
类,它什么也不做。但经过一段时间和对代码的一些操作后,IntelliSense 开始对标准类型和下划线 FAKE
类型起作用。
此外,当我在我的家庭工作站上创建类似的代码时,没有出现任何问题,IntelliSense 可以正常工作。
When dynamically referencing assemblies in .fsx using #I
and #r
, VS highlights the following usages of imported types and writes "The namespace or module 'XXX' is not defined". Is it ok?
For example, in the following code
#I @".\Tools\FAKE"
#r "FakeLib.dll"
open Fake
Target "Hello" (fun _ -> trace "hello!")
Run "Hello"
VS highlights Fake
and says "The namespace or module 'Fake' is not defined", it also highlights Target
and Run
. I have this problem in VS 2010 SP1 and in VS 11 CTP. This issue makes writing F# scripts a bit harder task than it could be.
By the way, IntelliSence for "common" types works well. FakeLib.dll
and FakeLib.xml
are present in the .\Tools\FAKE
directory. The code runs well.
Update 1
Here's the screenshot of the situation. You can see that VS resolves assembly FakeLib
correctly (in a tooltip), and that at the same time Intellisense "see" standard types (tooltip over Console
) class.
Update 2
I think there's something wrong with the IntelliSense on my work workstation, because it (IntelliSense) behaves itself quite strange. When I start VS and open .fsx file, IntelliSense refuses to resolve even standard types/classes, and it doesn't underlines FAKE
classes, it does nothing. But after some period of time and some manipulation over code IntelliSense starts working for standard types and underlines FAKE
types.
Moreover, when I've created the similar code on my home workstation there were no problems, IntelliSense works as it should.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果将完整路径放入 #r 指令中,您将获得完整的 IntelliSense。 #I 指令虽然方便,但会阻止 IntelliSense 正常工作,尽管代码可以正常运行。对于松散脚本和项目中的脚本都是如此。查看 Tomas Petricek 的 [FSharp.AsyncExtensions](http://github.com/tpetricek/FSharp.AsyncExtensions) 项目。
If you put the full path into the #r directive, you'll get full IntelliSense. The #I directive, while convenient, prevents IntelliSense from working properly though the code will run just fine. This is true for both loose scripts and those found in projects. Have a look at Tomas Petricek's [FSharp.AsyncExtensions](http://github.com/tpetricek/FSharp.AsyncExtensions] project.
不,事情不是这样的。你的代码能运行吗?为使用
#r
引用的程序集提供了智能感知。No, that's not how it works. Does your code run? Intellisense is provided for assemblies referenced using
#r
.