From b562661b84b8283185e82dcbfe939a3bc5b1d672 Mon Sep 17 00:00:00 2001 From: Kunpeng Fan Date: Thu, 19 Nov 2020 15:46:40 +0800 Subject: [PATCH 01/18] Update Errors.cs --- src/docfx/Errors.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index 8ebcadd3043..da1c05d89d5 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -72,6 +72,8 @@ public static Error GitCloneIncomplete(string repoPath) /// Behavior: ❌ Message: ✔️ public static Error GitNotFound() => new Error(ErrorLevel.Error, "git-not-found", $"Git isn't installed on the target machine. Try closing and reopening the PR. If you get this Error again, file an issue."); + public static Error GitNotFoundNew() + => new Error(ErrorLevel.Error, "git-not-found-new", $"Git isn't installed on the target machine. Try closing and reopening the PR. If you get this Error again, file an issue."); /// /// Call Microsoft Graph API failed From a76814cb8c549152030a9761c2a449bd6fd1b07c Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Fri, 19 Feb 2021 17:27:52 +0800 Subject: [PATCH 02/18] include analyzer package --- src/docfx/Errors.cs | 2 -- src/docfx/docfx.csproj | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index d5b104db410..f5f7594abf8 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -72,8 +72,6 @@ public static Error GitCloneIncomplete(string repoPath) /// Behavior: ❌ Message: ✔️ public static Error GitNotFound() => new Error(ErrorLevel.Error, "git-not-found", $"Git isn't installed on the target machine. Try closing and reopening the PR. If you get this Error again, file an issue."); - public static Error GitNotFoundNew() - => new Error(ErrorLevel.Error, "git-not-found-new", $"Git isn't installed on the target machine. Try closing and reopening the PR. If you get this Error again, file an issue."); /// /// Call Microsoft Graph API failed diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 98827b4dba2..e1c5c190310 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -1,4 +1,4 @@ - + Exe @@ -40,6 +40,7 @@ + From 7668c67daa941dd4a56905601a8af5ff79945d8d Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Wed, 24 Feb 2021 16:29:50 +0800 Subject: [PATCH 03/18] update version --- src/docfx/docfx.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index e1c5c190310..8f6926167d0 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -1,4 +1,4 @@ - + Exe @@ -40,7 +40,7 @@ - + From 375acfcd163597585eb1ab300d184bba55662f34 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Thu, 25 Feb 2021 16:11:06 +0800 Subject: [PATCH 04/18] upgrade version --- src/docfx/docfx.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 8f6926167d0..a8022ebcb3e 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -40,7 +40,7 @@ - + From 84447d77d6ed779ff48e2a2ac7687fb0bc2c7915 Mon Sep 17 00:00:00 2001 From: Yufei Huang Date: Fri, 26 Feb 2021 17:13:41 +0800 Subject: [PATCH 05/18] Minor clean up --- .github/workflows/release.yml | 2 +- src/docfx/config/ops/OpsAccessor.cs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6ce73f5da8..e7fec75f1d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Docfx V3 Release +name: Release on: push: branches: [ v3-release ] diff --git a/src/docfx/config/ops/OpsAccessor.cs b/src/docfx/config/ops/OpsAccessor.cs index 4b03f1a17b6..5ed958bbabd 100644 --- a/src/docfx/config/ops/OpsAccessor.cs +++ b/src/docfx/config/ops/OpsAccessor.cs @@ -32,15 +32,9 @@ internal class OpsAccessor : ILearnServiceAccessor public static readonly DocsEnvironment DocsEnvironment = GetDocsEnvironment(); - private static readonly string s_docsProdServiceEndpoint = - Environment.GetEnvironmentVariable("DOCS_PROD_SERVICE_ENDPOINT") ?? "https://buildapi.docs.microsoft.com"; - - private static readonly string s_docsPPEServiceEndpoint = - Environment.GetEnvironmentVariable("DOCS_PPE_SERVICE_ENDPOINT") ?? "https://BuildApiPubDev.azurefd.net"; - - private static readonly string s_docsPerfServiceEndpoint = - Environment.GetEnvironmentVariable("DOCS_PERF_SERVICE_ENDPOINT") ?? "https://op-build-perf.azurewebsites.net"; - + private static readonly string s_docsProdServiceEndpoint = "https://buildapi.docs.microsoft.com"; + private static readonly string s_docsPPEServiceEndpoint = "https://BuildApiPubDev.azurefd.net"; + private static readonly string s_docsPerfServiceEndpoint = "https://op-build-perf.azurewebsites.net"; private static readonly SecretClient s_secretClient = new(new("https://docfx.vault.azure.net"), new DefaultAzureCredential()); private static readonly Lazy> s_opsTokenProd = new(() => GetSecret("OpsBuildTokenProd")); private static readonly Lazy> s_opsTokenSandbox = new(() => GetSecret("OpsBuildTokenSandbox")); From 4b740aab7d9199465fba46f2aa4bf3448a114ed8 Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Fri, 26 Feb 2021 17:26:23 +0800 Subject: [PATCH 06/18] update version --- src/docfx/docfx.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index e1c5c190310..24c41cf14e6 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -1,4 +1,4 @@ - + Exe @@ -40,7 +40,7 @@ - + From 4499cbdce146155bff801c48f066539a54b22c39 Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Fri, 26 Feb 2021 17:33:07 +0800 Subject: [PATCH 07/18] merge --- src/docfx/docfx.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index fa93d17ebea..24c41cf14e6 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -22,8 +22,8 @@ - - + + @@ -34,8 +34,8 @@ + - From a63ebde2adb52e74efc9f371199b4bd1ce72f04b Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Fri, 26 Feb 2021 17:36:18 +0800 Subject: [PATCH 08/18] update version --- src/docfx/docfx.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 24c41cf14e6..756eb123742 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -22,8 +22,8 @@ - - + + @@ -34,14 +34,14 @@ - + - + @@ -50,4 +50,4 @@ - + \ No newline at end of file From b964b14a1ff0b2472d282bf6da304990123c5d96 Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Fri, 26 Feb 2021 20:10:18 +0800 Subject: [PATCH 09/18] restore analyzer severity level --- .editorconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.editorconfig b/.editorconfig index be1de3d6ce6..d56b6bc7b48 100644 --- a/.editorconfig +++ b/.editorconfig @@ -258,6 +258,8 @@ dotnet_diagnostic.IDE0055.severity = default # IDE0061: Use block body for local functions dotnet_diagnostic.IDE0061.severity = default +dotnet_diagnostic.BuildErrorsAnalyzer.severity = error + # Test specific diagnostic settings [test/**.cs] From 3fa99f2638b2385fc89e7d60f6d15f84ae9fd40d Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Mon, 1 Mar 2021 10:18:01 +0800 Subject: [PATCH 10/18] fix analyzer error of Errors.cs --- src/docfx/Errors.cs | 36 ++++++++++++++++--- .../moniker/EvaluatorWithMonikersVisitor.cs | 3 +- src/docfx/lib/moniker/ExpressionCreator.cs | 6 ++-- src/docfx/lib/moniker/MonikerRangeParser.cs | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index f5f7594abf8..13c80edba37 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -457,11 +457,39 @@ public static Error MonikerOverlapping(string uid, List files, IEnumer => new Error(ErrorLevel.Error, "moniker-overlapping", $"Two or more documents with the same uid `{uid}`({StringUtility.Join(files)}) have defined overlapping moniker: {StringUtility.Join(overlappingMonikers)}."); /// - /// Failed to parse moniker string. + /// Failed to parse moniker string: moniker is not defined. /// /// Behavior: ✔️ Message: ❌ - public static Error MonikerRangeInvalid(SourceInfo? operand, FormattableString message) - => new Error(ErrorLevel.Error, "moniker-range-invalid", message, operand); + public static Error MonikerRangeMissing(SourceInfo? operand, string moniker) + => new Error(ErrorLevel.Error, "moniker-range-missing", $"Invalid moniker range '{operand}': Moniker '{moniker}' is not defined.", operand); + + /// + /// Failed to parse moniker string: parse ends before reaching end of string + /// + /// Behavior: ✔️ Message: ❌ + public static Error MonikerRangeUnrecognized(SourceInfo? operand, string rangeString) + => new Error(ErrorLevel.Error, "moniker-range-unrecognized", $"Parse ends before reaching end of string, unrecognized string: '{rangeString}'.", operand); + + /// + /// Failed to parse moniker string: expect a comparator set + /// + /// Behavior: ✔️ Message: ❌ + public static Error MonikerRangeMissComparator(SourceInfo? operand, string rangeString) + => new Error(ErrorLevel.Error, "moniker-range-miss-comparator", $"Expect a comparator set, but got '{rangeString}'.", operand); + + /// + /// Failed to parse moniker string: expect a moniker string + /// + /// Behavior: ✔️ Message: ❌ + public static Error MonikerRangeMissMoniker(SourceInfo? operand, string rangeString) + => new Error(ErrorLevel.Error, "moniker-range-miss-moniker", $"Expect a moniker string, but got '{rangeString}'.", operand); + + /// + /// Failed to parse moniker string: Moniker key is not defined. + /// + /// Behavior: ✔️ Message: ❌ + public static Error MonikerRangeKeyUndefined(SourceInfo? operand, string key) + => new Error(ErrorLevel.Error, "moniker-range-key-undefined", $"Invalid monikers: Moniker '{key}' is not defined.", operand); /// /// MonikerRange is not defined in docfx.yml or doesn't match an article.md, @@ -761,7 +789,7 @@ public static Error DisallowedHtml(SourceInfo? source, string tag) /// Html Attribute value must be in allowed list /// public static Error DisallowedHtml(SourceInfo? source, string tag, string attribute) - => new Error(ErrorLevel.Info, "disallowed-html", $"HTML attribute '{attribute}' on tag '{tag}' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.", source, propertyPath: $"{tag}_{attribute}"); + => new Error(ErrorLevel.Info, "disallowed-html-attribute", $"HTML attribute '{attribute}' on tag '{tag}' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.", source, propertyPath: $"{tag}_{attribute}"); } public static class DependencyRepository diff --git a/src/docfx/lib/moniker/EvaluatorWithMonikersVisitor.cs b/src/docfx/lib/moniker/EvaluatorWithMonikersVisitor.cs index eacfe4aeabe..80b89e30bac 100644 --- a/src/docfx/lib/moniker/EvaluatorWithMonikersVisitor.cs +++ b/src/docfx/lib/moniker/EvaluatorWithMonikersVisitor.cs @@ -26,8 +26,7 @@ public EvaluatorWithMonikersVisitor(MonikerDefinitionModel monikerDefinition) { if (!MonikerOrder.TryGetValue(expression.Operand, out var moniker)) { - return (Errors.Versioning.MonikerRangeInvalid( - monikerRange, $"Invalid moniker range '{monikerRange}': Moniker '{expression.Operand}' is not defined."), Array.Empty()); + return (Errors.Versioning.MonikerRangeMissing(monikerRange, expression.Operand), Array.Empty()); } return expression.Operator switch diff --git a/src/docfx/lib/moniker/ExpressionCreator.cs b/src/docfx/lib/moniker/ExpressionCreator.cs index c81e015985f..ad4a23af73e 100644 --- a/src/docfx/lib/moniker/ExpressionCreator.cs +++ b/src/docfx/lib/moniker/ExpressionCreator.cs @@ -28,7 +28,7 @@ public static (List, IExpression?) Create(string rangeString, SourceInfo? errors.AddRange(rangeErrors); if (!string.IsNullOrWhiteSpace(rangeString)) { - errors.Add(Errors.Versioning.MonikerRangeInvalid(source, $"Parse ends before reaching end of string, unrecognized string: '{rangeString}'.")); + errors.Add(Errors.Versioning.MonikerRangeUnrecognized(source, rangeString)); } return (errors, expression); @@ -75,7 +75,7 @@ private static (List, IExpression?) GetComparatorSet(ref string rangeStri if (result is null) { - errors.Add(Errors.Versioning.MonikerRangeInvalid(source, $"Expect a comparator set, but got '{rangeString}'.")); + errors.Add(Errors.Versioning.MonikerRangeMissComparator(source, rangeString)); } return (errors, result); } @@ -101,7 +101,7 @@ private static bool TryGetComparator(ref string rangeString, SourceInfo? source, } else { - error = Errors.Versioning.MonikerRangeInvalid(source, $"Expect a moniker string, but got '{rangeString}'."); + error = Errors.Versioning.MonikerRangeMissMoniker(source, rangeString); return false; } } diff --git a/src/docfx/lib/moniker/MonikerRangeParser.cs b/src/docfx/lib/moniker/MonikerRangeParser.cs index c9e111b358f..1a73375dda1 100644 --- a/src/docfx/lib/moniker/MonikerRangeParser.cs +++ b/src/docfx/lib/moniker/MonikerRangeParser.cs @@ -29,7 +29,7 @@ public MonikerList Validate(ErrorBuilder errors, SourceInfo[] monikers) { if (!_monikersEvaluator.MonikerMap.ContainsKey(key)) { - errors.Add(Errors.Versioning.MonikerRangeInvalid(moniker, $"Invalid monikers: Moniker '{key}' is not defined.")); + errors.Add(Errors.Versioning.MonikerRangeKeyUndefined(moniker, key)); } else { From 55fd248943fb9699f112304654b4cfb53d938667 Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Mon, 1 Mar 2021 12:44:12 +0800 Subject: [PATCH 11/18] fix test case --- docs/specs/markdown.yml | 10 +++++----- docs/specs/moniker.yml | 8 ++++---- docs/specs/validation/content-validation.yml | 2 +- src/docfx/Errors.cs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/specs/markdown.yml b/docs/specs/markdown.yml index 11a9f40def8..b3535897e0e 100644 --- a/docs/specs/markdown.yml +++ b/docs/specs/markdown.yml @@ -313,7 +313,7 @@ outputs: .errors.log: | {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'script' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":1,"column":2} {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'link' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":2,"column":2} - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'style' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":3,"column":6} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'style' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":3,"column":6} {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'style' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":4,"column":2} --- # markdown table with styles is allowed @@ -520,10 +520,10 @@ outputs: docs/c.json: | { "conceptual": "

\n" } .errors.log: | - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'style' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/c.md","line":1,"column":4} - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'style' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/b.md","line":1,"column":4} - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'onclick' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/c.md","line":1,"column":27} - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'onclick' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/b.md","line":1,"column":27} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'style' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/c.md","line":1,"column":4} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'style' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/b.md","line":1,"column":4} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'onclick' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/c.md","line":1,"column":27} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'onclick' on tag 'a' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/b.md","line":1,"column":27} --- # yaml header shouldn't be array inputs: diff --git a/docs/specs/moniker.yml b/docs/specs/moniker.yml index 6f193bcaaa7..828255effdd 100644 --- a/docs/specs/moniker.yml +++ b/docs/specs/moniker.yml @@ -1407,7 +1407,7 @@ inputs: outputs: docs/v1/a.json: .errors.log: | - {"message_severity":"error","code":"moniker-range-invalid","message":"Invalid moniker range '>= netcore-2.0': Moniker 'netcore-2.0' is not defined.","file":"docfx.yml","line":2,"column":17} + {"message_severity":"error","code":"moniker-range-missing","message":"Invalid moniker range '>= netcore-2.0': Moniker 'netcore-2.0' is not defined.","file":"docfx.yml","line":2,"column":17} --- # Invalid moniker range in file inputs: @@ -1432,8 +1432,8 @@ inputs: } outputs: .errors.log: | - {"message_severity":"error","code":"moniker-range-invalid","message":"Invalid moniker range 'netcore-1.2': Moniker 'netcore-1.2' is not defined.","file":"docs/v1/a.md","line":2,"column":15} - {"message_severity":"error","code":"moniker-range-invalid","message":"Invalid moniker range '<= netcore-1.2': Moniker 'netcore-1.2' is not defined.","file":"docs/v1/b.md","line":2,"column":1} + {"message_severity":"error","code":"moniker-range-missing","message":"Invalid moniker range 'netcore-1.2': Moniker 'netcore-1.2' is not defined.","file":"docs/v1/a.md","line":2,"column":15} + {"message_severity":"error","code":"moniker-range-missing","message":"Invalid moniker range '<= netcore-1.2': Moniker 'netcore-1.2' is not defined.","file":"docs/v1/b.md","line":2,"column":1} {"message_severity":"error","code":"moniker-range-out-of-scope","message":"No moniker intersection between docfx.yml/docfx.json and file metadata. Config moniker range '>= netcore-1.0' is 'netcore-1.0', while file monikers is ''.","file":"docs/v1/a.md","line":2,"column":15} {"message_severity":"warning","code":"moniker-zone-empty","message":"No intersection between zone and file level monikers. The result of zone level range string '<= netcore-1.2' is '', while file level monikers is 'netcore-1.0'.","file":"docs/v1/b.md","line":2,"column":1} --- @@ -1699,7 +1699,7 @@ inputs: } outputs: .errors.log: | - {"message_severity":"error","code":"moniker-range-invalid","message":"Invalid monikers: Moniker 'netcore-1.1' is not defined.","file":"docs/v1/TOC.md","line":2,"column":11} + {"message_severity":"error","code":"moniker-range-key-undefined","message":"Invalid monikers: Moniker 'netcore-1.1' is not defined.","file":"docs/v1/TOC.md","line":2,"column":11} {"message_severity":"error","code":"moniker-range-out-of-scope","message":"No moniker intersection between docfx.yml/docfx.json and file metadata. Config moniker range '>= netcore-2.0' is 'netcore-2.0', while file monikers is ''.","file":"docs/v1/TOC.md","line":2,"column":11} --- # Should take monikerRange as final monikers even it outputs empty diff --git a/docs/specs/validation/content-validation.yml b/docs/specs/validation/content-validation.yml index d082b9303fb..ef8f50e4b3c 100644 --- a/docs/specs/validation/content-validation.yml +++ b/docs/specs/validation/content-validation.yml @@ -44,7 +44,7 @@ outputs: {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'H2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":1,"column":2} {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'BUTTON' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":2,"column":2} {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'h1' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":4,"column":2} - {"message_severity":"info","code":"disallowed-html","message":"HTML attribute 'onclick' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":5,"column":6} + {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'onclick' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":5,"column":6} --- # Suppress disallowed HTML on archive content inputs: diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index 13c80edba37..6c2c1edc5bb 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -460,7 +460,7 @@ public static Error MonikerOverlapping(string uid, List files, IEnumer /// Failed to parse moniker string: moniker is not defined. ///
/// Behavior: ✔️ Message: ❌ - public static Error MonikerRangeMissing(SourceInfo? operand, string moniker) + public static Error MonikerRangeMissing(SourceInfo operand, string moniker) => new Error(ErrorLevel.Error, "moniker-range-missing", $"Invalid moniker range '{operand}': Moniker '{moniker}' is not defined.", operand); /// From 6a768209648cde836a21eb36f4f2314b646dc25b Mon Sep 17 00:00:00 2001 From: fkpwolf Date: Mon, 1 Mar 2021 14:19:20 +0800 Subject: [PATCH 12/18] fix test case --- test/docfx.Test/lib/MonikerRangeParserTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/docfx.Test/lib/MonikerRangeParserTest.cs b/test/docfx.Test/lib/MonikerRangeParserTest.cs index 0b7c7550130..92bdc7b3c84 100644 --- a/test/docfx.Test/lib/MonikerRangeParserTest.cs +++ b/test/docfx.Test/lib/MonikerRangeParserTest.cs @@ -140,7 +140,7 @@ public void TestNullDefinitionShouldFail() monikerRangeParser.Parse(errors, new SourceInfo("netcore-1.0")); Assert.Collection(errors, error => { - Assert.Equal("moniker-range-invalid", error.Code); + Assert.Equal("moniker-range-missing", error.Code); Assert.Equal("Invalid moniker range 'netcore-1.0': Moniker 'netcore-1.0' is not defined.", error.Message); }); } From cd580a8641748d74dff1ca5f9dc2b8f0340d1254 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Tue, 2 Mar 2021 13:47:03 +0800 Subject: [PATCH 13/18] change "disallowed-html" to "disallowed-html-tag" --- docs/specs/error.yml | 4 ++-- docs/specs/markdown.yml | 8 ++++---- docs/specs/validation/content-validation.yml | 6 +++--- src/docfx/Errors.cs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/specs/error.yml b/docs/specs/error.yml index f700026de97..aecc2812a50 100644 --- a/docs/specs/error.yml +++ b/docs/specs/error.yml @@ -153,8 +153,8 @@ outputs: pig4.jpg: a.json: .errors.log: | - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'br2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":1,"end_line":1,"column":2,"end_column":5} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'br2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":2,"end_line":2,"column":2,"end_column":5} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'br2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":1,"end_line":1,"column":2,"end_column":5} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'br2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":2,"end_line":2,"column":2,"end_column":5} {"message_severity":"info","code":"exceed-max-file-errors","message":"Info count exceed '2'. Build will continue but newer logs in 'a.md' will be ignored.","file":"a.md","line":0,"end_line":0,"column":0,"end_column":0} --- diff --git a/docs/specs/markdown.yml b/docs/specs/markdown.yml index b3535897e0e..953a39eec36 100644 --- a/docs/specs/markdown.yml +++ b/docs/specs/markdown.yml @@ -311,10 +311,10 @@ outputs: docs/a.json: | { "conceptual": "

body

" } .errors.log: | - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'script' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":1,"column":2} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'link' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":2,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'script' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":1,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'link' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":2,"column":2} {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'style' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":3,"column":6} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'style' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":4,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'style' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":4,"column":2} --- # markdown table with styles is allowed inputs: @@ -389,7 +389,7 @@ outputs: {"message_severity":"warning","code":"bookmark-not-found","message":"Cannot find bookmark '#title-3' in 'docs/a.md', did you mean '#title-1'?","file":"docs/b.md","line":2,"column":1} {"message_severity":"warning","code":"bookmark-not-found","message":"Cannot find bookmark '#title-3' in 'docs/a.md', did you mean '#title-1'?","file":"docs/a.md","line":4,"column":1} {"message_severity":"warning","code":"bookmark-not-found","message":"Cannot find bookmark '#title-3' in 'docs/a.md', did you mean '#title-1'?","file":"docs/d.md","line":1,"column":1} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'h2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":8,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'h2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"docs/a.md","line":8,"column":2} --- # only validate bookmarks when the referenced file existed inputs: diff --git a/docs/specs/validation/content-validation.yml b/docs/specs/validation/content-validation.yml index ef8f50e4b3c..22b2ffd55f0 100644 --- a/docs/specs/validation/content-validation.yml +++ b/docs/specs/validation/content-validation.yml @@ -41,9 +41,9 @@ inputs: outputs: a.json: .errors.log: | - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'H2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":1,"column":2} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'BUTTON' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":2,"column":2} - {"message_severity":"info","code":"disallowed-html","message":"HTML tag 'h1' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":4,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'H2' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":1,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'BUTTON' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":2,"column":2} + {"message_severity":"info","code":"disallowed-html-tag","message":"HTML tag 'h1' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":4,"column":2} {"message_severity":"info","code":"disallowed-html-attribute","message":"HTML attribute 'onclick' on tag 'div' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.","file":"a.md","line":5,"column":6} --- # Suppress disallowed HTML on archive content diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index 6c2c1edc5bb..b2a1bcfa91a 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -783,7 +783,7 @@ public static Error Custom404Page(FilePath file) /// Html Tag value must be in allowed list ///
public static Error DisallowedHtml(SourceInfo? source, string tag) - => new Error(ErrorLevel.Info, "disallowed-html", $"HTML tag '{tag}' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.", source, propertyPath: tag); + => new Error(ErrorLevel.Info, "disallowed-html-tag", $"HTML tag '{tag}' isn't allowed. Disallowed HTML poses a security risk and must be replaced with approved Docs Markdown syntax.", source, propertyPath: tag); /// /// Html Attribute value must be in allowed list From 2ae44a612e0611548875689a97db88cb3a68c918 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Tue, 2 Mar 2021 17:12:07 +0800 Subject: [PATCH 14/18] change version --- src/docfx/docfx.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 756eb123742..1494996098c 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -41,7 +41,7 @@ - + From 2907feb4ed94920b2e1d75b00eb04f623de1d518 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Tue, 2 Mar 2021 17:29:47 +0800 Subject: [PATCH 15/18] update version --- src/docfx/docfx.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 1494996098c..2b5aef2dab5 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -41,7 +41,8 @@ - + + From ea10204ef2d6401f50e563c64a3eb7b9c28e04e0 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Wed, 3 Mar 2021 15:38:13 +0800 Subject: [PATCH 16/18] test warn as error --- .editorconfig | 2 -- src/docfx/Errors.cs | 3 ++- src/docfx/docfx.csproj | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index d56b6bc7b48..be1de3d6ce6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -258,8 +258,6 @@ dotnet_diagnostic.IDE0055.severity = default # IDE0061: Use block body for local functions dotnet_diagnostic.IDE0061.severity = default -dotnet_diagnostic.BuildErrorsAnalyzer.severity = error - # Test specific diagnostic settings [test/**.cs] diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index b2a1bcfa91a..3d99c3797f1 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -258,7 +258,8 @@ public static Error CircularReference(SourceInfo? source, T current, IEnumera { display ??= obj => obj?.ToString(); var dependencyChain = string.Join(" --> ", recursionDetector.Reverse().Append(current).Select(file => $"'{display(file)}'")); - return new Error(ErrorLevel.Error, "circular-reference", $"Build has identified file(s) referencing each other: {dependencyChain}.", source); + var code = "circular-reference"; + return new Error(ErrorLevel.Error, code, $"Build has identified file(s) referencing each other: {dependencyChain}.", source); } /// diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 2b5aef2dab5..370512f43f9 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -41,8 +41,7 @@ - - + From efae682d6cc251101087aaa25b8c7fe680b15aa6 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Thu, 4 Mar 2021 13:17:53 +0800 Subject: [PATCH 17/18] fix Errors.cs --- src/docfx/Errors.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/docfx/Errors.cs b/src/docfx/Errors.cs index 3d99c3797f1..b2a1bcfa91a 100644 --- a/src/docfx/Errors.cs +++ b/src/docfx/Errors.cs @@ -258,8 +258,7 @@ public static Error CircularReference(SourceInfo? source, T current, IEnumera { display ??= obj => obj?.ToString(); var dependencyChain = string.Join(" --> ", recursionDetector.Reverse().Append(current).Select(file => $"'{display(file)}'")); - var code = "circular-reference"; - return new Error(ErrorLevel.Error, code, $"Build has identified file(s) referencing each other: {dependencyChain}.", source); + return new Error(ErrorLevel.Error, "circular-reference", $"Build has identified file(s) referencing each other: {dependencyChain}.", source); } /// From b584359842acf45a17576f9163478a7bab500818 Mon Sep 17 00:00:00 2001 From: Kun Peng Fan Date: Thu, 4 Mar 2021 15:10:34 +0800 Subject: [PATCH 18/18] update version --- src/docfx/docfx.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 370512f43f9..7ff8f16efae 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -41,7 +41,7 @@ - +