From 18a7b9e460190882ad34f8f0442dfa91d1dfe9c6 Mon Sep 17 00:00:00 2001 From: Faith Gikundi Date: Tue, 14 Nov 2023 23:24:36 +0300 Subject: [PATCH] Add DocsLink to Duplicated File Error Message --- ApiDoctor.Console/Program.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ApiDoctor.Console/Program.cs b/ApiDoctor.Console/Program.cs index 6b033f30..4be6ac56 100644 --- a/ApiDoctor.Console/Program.cs +++ b/ApiDoctor.Console/Program.cs @@ -2364,11 +2364,15 @@ private static void WriteHttpSnippetsIntoFile(string tempDir, MethodDefinition[] if (duplicates.ContainsKey(fileName)) { (var originalSourceFile, var originalIdentifier, var count) = duplicates[fileName]; + var docsUrlFileSegment = Path.GetFileNameWithoutExtension(method.SourceFile.FullPath); + var docsUrlVersionSegment = snippetPrefix.Contains("beta") ? "beta" : "1.0"; + var documentationLink = $"https://learn.microsoft.com/en-us/graph/api/{docsUrlFileSegment}?view=graph-rest-{docsUrlVersionSegment}&tabs=http"; duplicates[fileName] = (originalSourceFile, originalIdentifier, count + 1); var errorMessage = "OriginalFile: " + originalSourceFile + Environment.NewLine + "OriginalIdentifier: " + originalIdentifier + Environment.NewLine + "DuplicateFile: " + method.SourceFile.DisplayName + Environment.NewLine - + "DuplicateIdentifier: " + method.Identifier + Environment.NewLine; + + "DuplicateIdentifier: " + method.Identifier + Environment.NewLine + + "DocsLink: " + documentationLink + Environment.NewLine; var duplicateFileFullPath = fileFullPath + "-duplicate" + count; FancyConsole.WriteLine(FancyConsole.ConsoleErrorColor, $"Writing {duplicateFileFullPath}"); @@ -2918,10 +2922,10 @@ private static string ConvertToThreeColumnPermissionsTable(IEnumerable t var permissionType = cells[0]; var leastPrivilegePermission = allPermissions.Any() ? allPermissions.First().Trim() : "Not supported."; - var higherPrivilegePermissions = !allPermissions.Any() - ? "Not supported." - : allPermissions.Count() == 1 - ? "Not available." + var higherPrivilegePermissions = !allPermissions.Any() + ? "Not supported." + : allPermissions.Count() == 1 + ? "Not available." : string.Join(", ", allPermissions.Skip(1).Select(x => x.Trim()).ToList()); tableString.Append($"\r\n|{permissionType}|{leastPrivilegePermission}|{higherPrivilegePermissions}|"); }