diff --git a/src/dotnet/APIView/APIViewWeb/Languages/LanguageProcessor.cs b/src/dotnet/APIView/APIViewWeb/Languages/LanguageProcessor.cs index 531403b1827..72f08bee6a8 100644 --- a/src/dotnet/APIView/APIViewWeb/Languages/LanguageProcessor.cs +++ b/src/dotnet/APIView/APIViewWeb/Languages/LanguageProcessor.cs @@ -26,6 +26,9 @@ public override async Task GetCodeFileAsync(string originalName, Strea var tempDirectory = Path.Combine(tempPath, "ApiView", randomSegment); Directory.CreateDirectory(tempDirectory); originalName = Path.GetFileName(originalName); + // Replace spaces and parentheses in the file name to remove invalid file name in cosmos DB. + // temporary work around. We need to make sure FileName is set for all requests. + originalName = originalName.Replace(" ", "_").Replace("(", "").Replace(")",""); var originalFilePath = Path.Combine(tempDirectory, originalName); var jsonFilePath = (LanguageServiceHelpers.UseTreeStyleParser(this.Name)) ? Path.ChangeExtension(originalFilePath, ".json.tgz") : Path.ChangeExtension(originalFilePath, ".json"); diff --git a/src/dotnet/APIView/APIViewWeb/Managers/CodeFileManager.cs b/src/dotnet/APIView/APIViewWeb/Managers/CodeFileManager.cs index e01d5704326..3efcea480c3 100644 --- a/src/dotnet/APIView/APIViewWeb/Managers/CodeFileManager.cs +++ b/src/dotnet/APIView/APIViewWeb/Managers/CodeFileManager.cs @@ -201,6 +201,11 @@ public async Task CreateReviewCodeFileModel(string apiRevision /// public async Task AreAPICodeFilesTheSame(RenderedCodeFile codeFileA, RenderedCodeFile codeFileB) { + if (codeFileA.CodeFile.VersionString != codeFileA.CodeFile.VersionString) + { + return false; + } + if (LanguageServiceHelpers.UseTreeStyleParser(codeFileA.CodeFile.Language)) { var diffTree =CodeFileHelpers.ComputeAPIForestDiff(codeFileA.CodeFile.APIForest, codeFileB.CodeFile.APIForest); diff --git a/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs b/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs index b7be0d1a3ea..971bde6418f 100644 --- a/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs +++ b/src/dotnet/APIView/APIViewWeb/Repositories/BlobCodeFileRepository.cs @@ -45,7 +45,18 @@ public async Task GetCodeFileAsync(string revisionId, string c var info = await client.DownloadAsync(); - codeFile = new RenderedCodeFile(await CodeFile.DeserializeAsync(info.Value.Content, doTreeStyleParserDeserialization: LanguageServiceHelpers.UseTreeStyleParser(language))); + CodeFile deserializedCodeFile = null; + // Try to deserialize the code file twice, as the first time might fail due to the file being not yet updated to new tree token format. + // This is a temporary work around. We should have a property in Cosmos revision to indicate whether a token is using new format or old format. + try + { + deserializedCodeFile = await CodeFile.DeserializeAsync(info.Value.Content, doTreeStyleParserDeserialization: LanguageServiceHelpers.UseTreeStyleParser(language)); + } + catch + { + deserializedCodeFile = await CodeFile.DeserializeAsync(info.Value.Content, doTreeStyleParserDeserialization: false); + } + codeFile = new RenderedCodeFile(deserializedCodeFile); if (updateCache) {