in DevSkim-DotNet/Microsoft.DevSkim.VSExtension/Checker/DevSkimErrorsSnapshot.cs [73:181]
public override bool TryGetValue(int index, string columnName, out object content)
{
string productName = "DevSkim";
if ((index >= 0) && (index < this.Errors.Count))
{
if (columnName == StandardTableKeyNames.ProjectName)
{
content = _project;
return true;
}
else if (columnName == StandardTableKeyNames.DocumentName)
{
// We return the full file path here. The UI handles displaying only the Path.GetFileName().
content = _filePath;
return true;
}
else if (columnName == StandardTableKeyNames.ErrorCategory)
{
content = "Security";
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSource)
{
content = productName;
return true;
}
else if (columnName == StandardTableKeyNames.Line)
{
// Line and column numbers are 0-based (the UI that displays the line/column number will
// add one to the value returned here).
content = this.Errors[index].Span.Start.GetContainingLine().LineNumber;
return true;
}
else if (columnName == StandardTableKeyNames.Column)
{
var position = this.Errors[index].Span.Start;
var line = position.GetContainingLine();
content = position.Position - line.Start.Position;
return true;
}
else if (columnName == StandardTableKeyNames.Text)
{
content = string.Format(CultureInfo.InvariantCulture, "{0}: [{1}] {2}", productName, this.Errors[index].Rule.Severity, this.Errors[index].Rule.Name);
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSeverity)
{
if (!this.Errors[index].Actionable)
{
content = __VSERRORCATEGORY.EC_MESSAGE;
}
else
{
switch (this.Errors[index].Rule.Severity)
{
case Severity.Critical:
case Severity.Important:
case Severity.Moderate:
content = __VSERRORCATEGORY.EC_ERROR;
break;
case Severity.BestPractice:
content = __VSERRORCATEGORY.EC_WARNING;
break;
default:
content = __VSERRORCATEGORY.EC_MESSAGE;
break;
}
}
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSource)
{
content = ErrorSource.Other;
return true;
}
else if (columnName == StandardTableKeyNames.BuildTool)
{
content = productName;
return true;
}
else if (columnName == StandardTableKeyNames.ErrorCode)
{
content = this.Errors[index].Rule.Id;
return true;
}
else if ((columnName == StandardTableKeyNames.ErrorCodeToolTip) || (columnName == StandardTableKeyNames.HelpLink))
{
content = this.Errors[index].Rule.RuleInfo;
return true;
}
// We should also be providing values for StandardTableKeyNames.Project &
// StandardTableKeyNames.ProjectName but that is beyond the scope of this sample.
}
content = null;
return false;
}