From 5210eb17a3b615c1c4aa57425f35271eaa340066 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Fri, 13 Mar 2020 14:24:11 -0700 Subject: [PATCH] Fix nullref. See https://github.com/dotnet/source-indexer/issues/35 --- .../src/HtmlGenerator/Pass1-Generation/Classifier.cs | 2 +- .../src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/Classifier.cs b/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/Classifier.cs index cd88709..9108dae 100644 --- a/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/Classifier.cs +++ b/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/Classifier.cs @@ -23,7 +23,7 @@ public async Task> Classify(Document document, SourceText tex catch (Exception ex) { Log.Exception(ex, "Exception during Classification of document: " + document.FilePath); - return null; + return Array.Empty(); } // Roslyn 3.0.0 introduced `Symbol - Static` as an "additive" classification, meaning that multiple diff --git a/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs b/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs index 7259000..29db160 100644 --- a/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs +++ b/src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs @@ -151,7 +151,7 @@ private async Task GenerateHtml(StreamWriter writer) writer.Write(prefix); GenerateHeader(writer.WriteLine); - var ranges = (await classifier.Classify(Document, Text)).ToArray(); + var ranges = (await classifier.Classify(Document, Text))?.ToArray(); // pass a value larger than 0 to generate line numbers statically at HTML generation time var table = Markup.GetTablePrefix(