Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
Expand Down Expand Up @@ -604,7 +602,8 @@ private static bool NeedsSeparator(SyntaxToken token, SyntaxToken next)
if (next.IsKind(SyntaxKind.ColonToken))
{
if (next.Parent.IsKind(SyntaxKind.BaseList) ||
next.Parent.IsKind(SyntaxKind.TypeParameterConstraintClause))
next.Parent.IsKind(SyntaxKind.TypeParameterConstraintClause) ||
next.Parent is ConstructorInitializerSyntax)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,12 @@ public void TestSpacingOnInvocationLikeKeywords()
// no space between this and (
TestNormalizeDeclaration(
"class C { C() : this () { } }",
"class C\r\n{\r\n C(): this()\r\n {\r\n }\r\n}");
"class C\r\n{\r\n C() : this()\r\n {\r\n }\r\n}");

// no space between base and (
TestNormalizeDeclaration(
"class C { C() : base () { } }",
"class C\r\n{\r\n C(): base()\r\n {\r\n }\r\n}");
"class C\r\n{\r\n C() : base()\r\n {\r\n }\r\n}");

// no space between checked and (
TestNormalizeExpression("checked (a)", "checked(a)");
Expand Down Expand Up @@ -920,6 +920,35 @@ public void TestNormalizeFunctionPointerWithUnmanagedCallingConventionAndSpecifi
TestNormalizeDeclaration(content, expected);
}

[Fact]
[WorkItem(53254, "https://github.com/dotnet/roslyn/issues/53254")]
public void TestNormalizeColonInConstructorInitializer()
{
var content =
@"class Base
{
}

class Derived : Base
{
public Derived():base(){}
}";

var expected =
@"class Base
{
}

class Derived : Base
{
public Derived() : base()
{
}
}";

TestNormalizeDeclaration(content, expected);
}

[Fact]
[WorkItem(49732, "https://github.com/dotnet/roslyn/issues/49732")]
public void TestNormalizeXmlInDocComment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ public void TestConstructorDeclaration()
Generator.ConstructorDeclaration("c",
parameters: new[] { Generator.ParameterDeclaration("p", Generator.IdentifierName("t")) },
baseConstructorArguments: new[] { Generator.IdentifierName("p") }),
"c(t p): base(p)\r\n{\r\n}");
"c(t p) : base(p)\r\n{\r\n}");
}

[Fact]
Expand Down