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

时间:2014-10-19 03:00:06

标签: 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, "", 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是否存在传播错误的问题?或者我现在需要做一些不同的事情以防止编译?

0 个答案:

没有答案