[英]Visual Studio 2015 / C# 6 / Roslyn can't compile XML comments in PCL project
I just installed the fresh released Community Edition of Visual Studio 2015 (RTM) and I'm trying to get my open source project working under VS2015 and C# 6.0. 我刚刚安装了最新发布的Visual Studio 2015社区版(RTM),我试图让我的开源项目在VS2015和C#6.0下工作。
Some of my .cs are shared across projects. 我的一些.cs在项目中共享。 This way I'm able to build both a PCL version (with limited functionality) and a 'full' version of the core library.
这样我就可以构建PCL版本(功能有限)和核心库的“完整”版本。
For some reason however, some code files build properly in the full project, but fail when built in the PCL project (where everything compiles under C# 5 and Visual Studio 2013). 但是出于某种原因,某些代码文件在整个项目中正确构建,但在PCL项目中构建时会失败(其中所有内容都在C#5和Visual Studio 2013下编译)。 The compiler seems to be unable to resolve a
cref
in an XML comment when building the PCL version. 在构建PCL版本时,编译器似乎无法解析XML注释中的
cref
。 Here is a simplified code example that fails on my machine: 这是一个在我的机器上失败的简化代码示例:
/// <summary></summary>
public class A
{
// Compile error on next line:
/// <summary><see cref="Y(Type)"/>.</summary>
public void X() { }
/// <summary></summary>
/// <param name="x"></param>
public void Y(Type x) { }
/// <summary></summary>
/// <param name="i"></param>
public void Y(int i) { }
}
The compile error I'm getting is: 我得到的编译错误是:
CS1580 Invalid type for parameter Type in XML comment cref attribute: 'Y(Type)' SimpleInjector.PCL
CS1580参数的类型无效XML注释cref属性中的类型:'Y(Type)'SimpleInjector.PCL
Weird thing is though that the IntelliSense support in the XML comments (Wow! we have IntelliSense in XML comments now!) actually works, and the method Y(Type)
is selectable through the drop down list. 奇怪的是,XML评论中的IntelliSense支持(哇!我们现在在XML评论中有智能感知!)实际上是可行的,方法
Y(Type)
可以通过下拉列表进行选择。 But after selecting this, a compile error is generated (in PCL only). 但选择此选项后,将生成编译错误(仅在PCL中)。
My question of course is how to fix this? 我的问题当然是如何解决这个问题? Is this a common problem?
这是个常见的问题吗? Could project's configuration have anything to do with this?
项目的配置可能与此有关吗? Is this a known bug?
这是一个已知的错误?
David Kean , a dev on the C#/VB languages team, responded quite quickly on Twitter and did some research on this. C#/ VB语言团队的开发人员David Kean在Twitter上做出了相当快的反应并对此做了一些研究。 He reported back to me that this is in fact a bug and known limitation in Roslyn.
他向我报告说,这实际上是罗斯林的一个错误和已知限制。 After investigation, he reported the problem on Github here and here .
经过调查,他在这里和这里报告了Github上的问题。
There are basically two problems here that together caused me to get stuck: 这里基本上有两个问题让我陷入困境:
Type
, there seems to be an internal type named Type
, but different than the public System.Type
. Type
的情况下,似乎有一个名为Type
的内部Type
,但不同于公共System.Type
。 Although this internal Type
type, doesn't exist for my code, it does exist for Roslyn, and Roslyn gets confused. Type
类型,但它确实存在于Roslyn中,并且Roslyn感到困惑。 The current work around for this problem is to fully qualify the types like this: 目前解决此问题的方法是完全限定类似这样的类型:
/// <summary><see cref="Y(System.Type)"/>.</summary>
public void X() { }
Note: The same holds for Assembly
. 注意:同样适用于
Assembly
。 You will have to fully qualify that type as System.Reflection.Assembly
. 您必须完全限定该类型为
System.Reflection.Assembly
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.