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
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ private static async Task<Solution> GetTransformedSolutionAsync(Document documen
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.DelegateDeclaration:
case SyntaxKindEx.RecordDeclaration:
case SyntaxKindEx.RecordStructDeclaration:
nodesToRemoveFromExtracted.Add(child);
break;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules
{
using StyleCop.Analyzers.Test.MaintainabilityRules;

public class SA1402CSharp10ForRecordClassUnitTests : SA1402ForBlockDeclarationUnitTestsBase
{
public override string Keyword => "record class";

protected override string SettingKeyword => "class";

protected override bool IsConfiguredAsTopLevelTypeByDefault => true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules
{
using StyleCop.Analyzers.Test.MaintainabilityRules;

public class SA1402CSharp10ForRecordStructUnitTests : SA1402ForBlockDeclarationUnitTestsBase
{
public override string Keyword => "record struct";

protected override string SettingKeyword => "struct";

protected override bool IsConfiguredAsTopLevelTypeByDefault => false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules
{
using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules;

public class SA1402CSharp10ForRecordUnitTests : SA1402CSharp9ForRecordUnitTests
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules
{
using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules;

public class SA1402CSharp11ForRecordClassUnitTests : SA1402CSharp10ForRecordClassUnitTests
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules
{
using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules;

public class SA1402CSharp11ForRecordStructUnitTests : SA1402CSharp10ForRecordStructUnitTests
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules
{
using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules;

public class SA1402CSharp11ForRecordUnitTests : SA1402CSharp10ForRecordUnitTests
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules
{
using StyleCop.Analyzers.Test.MaintainabilityRules;

public class SA1402CSharp9ForRecordUnitTests : SA1402ForBlockDeclarationUnitTestsBase
{
public override string Keyword => "record";

protected override string SettingKeyword => "class";

protected override bool IsConfiguredAsTopLevelTypeByDefault => true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public abstract class SA1402ForBlockDeclarationUnitTestsBase : FileMayOnlyContai

protected SA1402SettingsConfiguration SettingsConfiguration { get; set; } = SA1402SettingsConfiguration.ConfigureAsTopLevelType;

protected virtual string SettingKeyword => this.Keyword;

protected abstract bool IsConfiguredAsTopLevelTypeByDefault { get; }

[Fact]
Expand Down Expand Up @@ -190,7 +192,7 @@ public async Task TestNestedTypesAsync()

protected override string GetSettings()
{
return this.SettingsConfiguration.GetSettings(this.Keyword);
return this.SettingsConfiguration.GetSettings(this.SettingKeyword);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ private static bool IsRelevantType(SyntaxNode node, StyleCopSettings settings)
switch (node.Kind())
{
case SyntaxKind.ClassDeclaration:
case SyntaxKindEx.RecordDeclaration:
isRelevant = topLevelTypes.Contains(TopLevelType.Class);
break;
case SyntaxKind.InterfaceDeclaration:
isRelevant = topLevelTypes.Contains(TopLevelType.Interface);
break;
case SyntaxKind.StructDeclaration:
case SyntaxKindEx.RecordStructDeclaration:
isRelevant = topLevelTypes.Contains(TopLevelType.Struct);
break;
case SyntaxKind.EnumDeclaration:
Expand Down