From 1c9239e660fc8d948bafa7e89c3bb8157943511b Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:57:45 -0800 Subject: [PATCH] Fix null error (#7412) --- .../Managers/APIRevisionsManager.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/dotnet/APIView/APIViewWeb/Managers/APIRevisionsManager.cs b/src/dotnet/APIView/APIViewWeb/Managers/APIRevisionsManager.cs index 1dcdcc9c923..07e4aaca3f0 100644 --- a/src/dotnet/APIView/APIViewWeb/Managers/APIRevisionsManager.cs +++ b/src/dotnet/APIView/APIViewWeb/Managers/APIRevisionsManager.cs @@ -296,9 +296,13 @@ public async Task GetLineNumbersOfHeadingsOfSectionsWithDiff(string reviewId, AP { var RevisionARootNode = RevisionACodeFile.GetCodeLineSectionRoot((int)diffLine.Line.SectionKey); var RevisionBRootNode = RevisionBCodeFile.GetCodeLineSectionRoot((int)diffLine.OtherLine.SectionKey); - var diffSectionRoot = ComputeSectionDiff(before: RevisionARootNode, after: RevisionBRootNode, beforeFile: RevisionACodeFile, afterFile: RevisionBCodeFile); - if (RevisionACodeFile.ChildNodeHasDiff(diffSectionRoot)) - lineNumbersForHeadingOfSectionWithDiff.Add((int)diffLine.Line.LineNumber); + + if (RevisionARootNode != null && RevisionBRootNode != null) + { + var diffSectionRoot = ComputeSectionDiff(before: RevisionARootNode, after: RevisionBRootNode, beforeFile: RevisionACodeFile, afterFile: RevisionBCodeFile); + if (RevisionACodeFile.ChildNodeHasDiff(diffSectionRoot)) + lineNumbersForHeadingOfSectionWithDiff.Add((int)diffLine.Line.LineNumber); + } } } @@ -321,9 +325,13 @@ public async Task GetLineNumbersOfHeadingsOfSectionsWithDiff(string reviewId, AP { var RevisionBRootNode = RevisionBCodeFile.GetCodeLineSectionRoot((int)diffLine.Line.SectionKey); var RevisionARootNode = RevisionACodeFile.GetCodeLineSectionRoot((int)diffLine.OtherLine.SectionKey); - var diffSectionRoot = ComputeSectionDiff(before: RevisionBRootNode, after: RevisionARootNode, beforeFile: RevisionBCodeFile, afterFile: RevisionACodeFile); - if (RevisionACodeFile.ChildNodeHasDiff(diffSectionRoot)) - lineNumbersForHeadingOfSectionWithDiff.Add((int)diffLine.Line.LineNumber); + + if (RevisionARootNode != null && RevisionBRootNode != null) + { + var diffSectionRoot = ComputeSectionDiff(before: RevisionBRootNode, after: RevisionARootNode, beforeFile: RevisionBCodeFile, afterFile: RevisionACodeFile); + if (RevisionACodeFile.ChildNodeHasDiff(diffSectionRoot)) + lineNumbersForHeadingOfSectionWithDiff.Add((int)diffLine.Line.LineNumber); + } } }