diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs index 633371605c..daedfd6e9e 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor_Global.cs @@ -120,10 +120,10 @@ namespace ICSharpCode.NRefactory.CSharp void FixAttributesAndDocComment(EntityDeclaration entity) { - var node =entity.FirstChild; + var node = entity.FirstChild; while (node != null && node.Role == Roles.Comment) { - FixIndentation(node); node = node.GetNextSibling(NoWhitespacePredicate); + FixIndentation(node); } if (entity.Attributes.Count > 0) { AstNode n = null; diff --git a/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs b/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs index ca82ab0406..5325697972 100644 --- a/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs +++ b/ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs @@ -101,10 +101,27 @@ class Test { { CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono(); policy.ClassBraceStyle = BraceStyle.DoNotChange; - + + Test(policy, + @" class Test {}", + @"class Test {}"); + } + + [Test] + public void TestClassIndentationWithDocComment() + { + CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono(); + policy.ClassBraceStyle = BraceStyle.DoNotChange; + Test(policy, - @" class Test {}", - @"class Test {}"); + @"/// + /// olwcowcolwc + /// + class Test {}", + @"/// +/// olwcowcolwc +/// +class Test {}"); } [Test]