internal DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool showPosition = false) { this.code = d.Code; this.isWarningAsError = d.IsWarningAsError; this.location = d.Location; DiagnosticWithInfo dinfo = null; if (d.Code == 0) { code = d.Id; errorCodeType = typeof(string); } else { dinfo = d as DiagnosticWithInfo; if (dinfo == null) { code = d.Code; errorCodeType = typeof(int); } else { errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType; code = d.Code; } } this.ignoreArgumentsWhenComparing = errorCodeOnly; this.showPosition = showPosition; if (!this.ignoreArgumentsWhenComparing) { if (this.location.IsInSource) { // we don't just want to do SyntaxNode.GetText(), because getting the text via the SourceTree validates the public API this.squiggledText = this.location.SourceTree.GetText().ToString(this.location.SourceSpan); } if (dinfo != null) { arguments = dinfo.Info.Arguments; } else { var args = d.Arguments; if (args == null || args.Count == 0) { arguments = null; } else { arguments = d.Arguments.ToArray(); } } if (this.arguments != null && this.arguments.Length == 0) { this.arguments = null; } } this.startPosition = this.location.GetMappedLineSpan().StartLinePosition; }
internal DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool showPosition = false) { _code = d.Code; _isWarningAsError = d.IsWarningAsError; _location = d.Location; DiagnosticWithInfo dinfo = null; if (d.Code == 0) { _code = d.Id; _errorCodeType = typeof(string); } else { dinfo = d as DiagnosticWithInfo; if (dinfo == null) { _code = d.Code; _errorCodeType = typeof(int); } else { _errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType; _code = d.Code; } } _ignoreArgumentsWhenComparing = errorCodeOnly; _showPosition = showPosition; if (!_ignoreArgumentsWhenComparing) { if (_location.IsInSource) { // we don't just want to do SyntaxNode.GetText(), because getting the text via the SourceTree validates the public API _squiggledText = _location.SourceTree.GetText().ToString(_location.SourceSpan); } if (dinfo != null) { _arguments = dinfo.Info.Arguments; } else { IReadOnlyList <object> args = d.Arguments; if (args == null || args.Count == 0) { _arguments = null; } else { _arguments = d.Arguments.ToArray(); } } if (_arguments != null && _arguments.Length == 0) { _arguments = null; } } _startPosition = _location.GetMappedLineSpan().StartLinePosition; }
public DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool includeDefaultSeverity = false, bool includeEffectiveSeverity = false) { _code = d.Code; _isWarningAsError = d.IsWarningAsError; _isSuppressed = d.IsSuppressed; _location = d.Location; _defaultSeverityOpt = includeDefaultSeverity ? d.DefaultSeverity : null; _effectiveSeverityOpt = includeEffectiveSeverity ? d.Severity : null; DiagnosticWithInfo dinfo = null; if (d.Code == 0) { _code = d.Id; _errorCodeType = typeof(string); } else { dinfo = d as DiagnosticWithInfo; if (dinfo == null) { _code = d.Code; _errorCodeType = typeof(int); } else { _errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType; _code = d.Code; } } _ignoreArgumentsWhenComparing = errorCodeOnly; if (!_ignoreArgumentsWhenComparing) { if (_location.IsInSource) { // we don't just want to do SyntaxNode.GetText(), because getting the text via the SourceTree validates the public API _squiggledText = _location.SourceTree.GetText().ToString(_location.SourceSpan); } if (dinfo != null) { _arguments = dinfo.Info.Arguments; } else { var args = d.Arguments; if (args == null || args.Count == 0) { _arguments = null; } else { _arguments = d.Arguments.ToArray(); } } if (_arguments != null && _arguments.Length == 0) { _arguments = null; } } _startPosition = _location.GetLineSpan().StartLinePosition; }