Vb.net 如何通过诊断防止编译成功?

Vb.net 如何通过诊断防止编译成功?,vb.net,roslyn,Vb.net,Roslyn,我使用的是VS14 ctp 4发行版中提供的Roslyn,但当我的诊断发现一个应视为错误的问题时,我似乎无法使编译不成功。下面是我尝试过的两种方法 Sub AddError(msg As String, d As Action(Of Diagnostic), st As SyntaxTree, offset As Integer, s As IndexSpan) Dim r As New DiagnosticDescriptor(DiagnosticId, "", MessageForm

我使用的是VS14 ctp 4发行版中提供的Roslyn,但当我的诊断发现一个应视为错误的问题时,我似乎无法使编译不成功。下面是我尝试过的两种方法

 Sub AddError(msg As String, d As Action(Of Diagnostic), st As SyntaxTree, offset As Integer, s As IndexSpan)
   Dim r As New DiagnosticDescriptor(DiagnosticId, "", MessageFormat, Category, DiagnosticSeverity.Error, True)
   Dim q = Diagnostic.Create(DiagnosticId, Category, String.Format(MessageFormat, msg), DiagnosticSeverity.Error, True, 0, False, Description,, Location.Create(st, TextSpan.FromBounds(offset + s.Index + 1, offset + s.Index + s.Span)))
   d(q)
'   d(Diagnostic.Create(r, Location.Create(st, TextSpan.FromBounds(offset + s.Index + 1, offset + s.Index + s.Span)), msg))
 End Sub

我不知道这是否是IDE没有传播错误的问题?或者我现在需要做一些不同的事情来防止编译

你的意思是你根本看不到错误?@svick错误会显示在错误窗口中。但是根据错误枚举上的Intellisense,语言或其他权威机构不允许的某些东西会阻止成功编译我也尝试过勾选设置“将警告视为错误”,编译成功,代码随后运行。