From 5730c87bd12a105c3899a10bd5fe5cb285da76aa Mon Sep 17 00:00:00 2001 From: Alex Ghiondea Date: Thu, 4 Oct 2018 14:31:24 -0700 Subject: [PATCH] Fix an issue where the start and end tokens for the copyright are the same. --- .../Rules/HasNoCustomCopyrightHeaderFormattingRule.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Microsoft.DotNet.CodeFormatting/Rules/HasNoCustomCopyrightHeaderFormattingRule.cs b/src/Microsoft.DotNet.CodeFormatting/Rules/HasNoCustomCopyrightHeaderFormattingRule.cs index a5b65033..2d0926ca 100644 --- a/src/Microsoft.DotNet.CodeFormatting/Rules/HasNoCustomCopyrightHeaderFormattingRule.cs +++ b/src/Microsoft.DotNet.CodeFormatting/Rules/HasNoCustomCopyrightHeaderFormattingRule.cs @@ -77,10 +77,17 @@ private static bool TryGetStartAndEndOfXmlHeader(SyntaxTriviaList triviaList, ou foreach (var trivia in triviaList) { if (!hasStart && IsBeginningOfXmlHeader(trivia, out start)) + { hasStart = true; + continue; // we need to continue because start and end can be the same token + } + if (!hasEnd && IsEndOfXmlHeader(trivia, out end)) + { hasEnd = true; + continue; // we need to continue because start and end can be the same token + } } return hasStart && hasEnd;