Browse Source

Fix unhandled exception if code coverage results file does not exist.

Show error message in code coverage pad's text editor if the code coverage file does not exist.
pull/28/head
Matt Ward 13 years ago
parent
commit
28d9289116
  1. 15
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs

15
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -318,7 +318,9 @@ namespace ICSharpCode.CodeCoverage
void OpenFile(string fileName, int line, int column) void OpenFile(string fileName, int line, int column)
{ {
if (fileName != textEditorFileName) { if (fileName != textEditorFileName) {
textEditor.Load(fileName); if (!TryLoadFileIntoTextEditor(fileName)) {
return;
}
textEditor.SyntaxHighlighting = GetSyntaxHighlighting(fileName); textEditor.SyntaxHighlighting = GetSyntaxHighlighting(fileName);
} }
textEditor.ScrollToEnd(); textEditor.ScrollToEnd();
@ -327,6 +329,17 @@ namespace ICSharpCode.CodeCoverage
CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName); CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName);
} }
bool TryLoadFileIntoTextEditor(string fileName)
{
if (!File.Exists(fileName)) {
textEditor.Text = String.Format("File does not exist '{0}'.", fileName);
return false;
}
textEditor.Load(fileName);
return true;
}
IHighlightingDefinition GetSyntaxHighlighting(string fileName) IHighlightingDefinition GetSyntaxHighlighting(string fileName)
{ {
return HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName)); return HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));

Loading…
Cancel
Save