Skip to content

Commit a2c78bd

Browse files
committed
Make similar changes to FormattingOptions and C# FormattingOptions - core impl types in shared layer with "2" suffix and shim public API types in Workspaces layer.
1 parent cd860f7 commit a2c78bd

File tree

8 files changed

+290
-132
lines changed

8 files changed

+290
-132
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.CodeAnalysis.Options;
6+
7+
namespace Microsoft.CodeAnalysis.CSharp.Formatting
8+
{
9+
public static partial class CSharpFormattingOptions
10+
{
11+
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = CSharpFormattingOptions2.SpacingAfterMethodDeclarationName;
12+
13+
public static Option<bool> SpaceWithinMethodDeclarationParenthesis { get; } = CSharpFormattingOptions2.SpaceWithinMethodDeclarationParenthesis;
14+
15+
public static Option<bool> SpaceBetweenEmptyMethodDeclarationParentheses { get; } = CSharpFormattingOptions2.SpaceBetweenEmptyMethodDeclarationParentheses;
16+
17+
public static Option<bool> SpaceAfterMethodCallName { get; } = CSharpFormattingOptions2.SpaceAfterMethodCallName;
18+
19+
public static Option<bool> SpaceWithinMethodCallParentheses { get; } = CSharpFormattingOptions2.SpaceWithinMethodCallParentheses;
20+
21+
public static Option<bool> SpaceBetweenEmptyMethodCallParentheses { get; } = CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses;
22+
23+
public static Option<bool> SpaceAfterControlFlowStatementKeyword { get; } = CSharpFormattingOptions2.SpaceAfterControlFlowStatementKeyword;
24+
25+
public static Option<bool> SpaceWithinExpressionParentheses { get; } = CSharpFormattingOptions2.SpaceWithinExpressionParentheses;
26+
27+
public static Option<bool> SpaceWithinCastParentheses { get; } = CSharpFormattingOptions2.SpaceWithinCastParentheses;
28+
29+
public static Option<bool> SpaceWithinOtherParentheses { get; } = CSharpFormattingOptions2.SpaceWithinOtherParentheses;
30+
31+
public static Option<bool> SpaceAfterCast { get; } = CSharpFormattingOptions2.SpaceAfterCast;
32+
33+
public static Option<bool> SpacesIgnoreAroundVariableDeclaration { get; } = CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration;
34+
35+
public static Option<bool> SpaceBeforeOpenSquareBracket { get; } = CSharpFormattingOptions2.SpaceBeforeOpenSquareBracket;
36+
37+
public static Option<bool> SpaceBetweenEmptySquareBrackets { get; } = CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets;
38+
39+
public static Option<bool> SpaceWithinSquareBrackets { get; } = CSharpFormattingOptions2.SpaceWithinSquareBrackets;
40+
41+
public static Option<bool> SpaceAfterColonInBaseTypeDeclaration { get; } = CSharpFormattingOptions2.SpaceAfterColonInBaseTypeDeclaration;
42+
43+
public static Option<bool> SpaceAfterComma { get; } = CSharpFormattingOptions2.SpaceAfterComma;
44+
45+
public static Option<bool> SpaceAfterDot { get; } = CSharpFormattingOptions2.SpaceAfterDot;
46+
47+
public static Option<bool> SpaceAfterSemicolonsInForStatement { get; } = CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement;
48+
49+
public static Option<bool> SpaceBeforeColonInBaseTypeDeclaration { get; } = CSharpFormattingOptions2.SpaceBeforeColonInBaseTypeDeclaration;
50+
51+
public static Option<bool> SpaceBeforeComma { get; } = CSharpFormattingOptions2.SpaceBeforeComma;
52+
53+
public static Option<bool> SpaceBeforeDot { get; } = CSharpFormattingOptions2.SpaceBeforeDot;
54+
55+
public static Option<bool> SpaceBeforeSemicolonsInForStatement { get; } = CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement;
56+
57+
public static Option<BinaryOperatorSpacingOptions> SpacingAroundBinaryOperator { get; } = CSharpFormattingOptions2.SpacingAroundBinaryOperator;
58+
59+
public static Option<bool> IndentBraces { get; } = CSharpFormattingOptions2.IndentBraces;
60+
61+
public static Option<bool> IndentBlock { get; } = CSharpFormattingOptions2.IndentBlock;
62+
63+
public static Option<bool> IndentSwitchSection { get; } = CSharpFormattingOptions2.IndentSwitchSection;
64+
65+
public static Option<bool> IndentSwitchCaseSection { get; } = CSharpFormattingOptions2.IndentSwitchCaseSection;
66+
67+
public static Option<bool> IndentSwitchCaseSectionWhenBlock { get; } = CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock;
68+
69+
public static Option<LabelPositionOptions> LabelPositioning { get; } = CSharpFormattingOptions2.LabelPositioning;
70+
71+
public static Option<bool> WrappingPreserveSingleLine { get; } = CSharpFormattingOptions2.WrappingPreserveSingleLine;
72+
73+
public static Option<bool> WrappingKeepStatementsOnSingleLine { get; } = CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine;
74+
75+
public static Option<bool> NewLinesForBracesInTypes { get; } = CSharpFormattingOptions2.NewLinesForBracesInTypes;
76+
77+
public static Option<bool> NewLinesForBracesInMethods { get; } = CSharpFormattingOptions2.NewLinesForBracesInMethods;
78+
79+
public static Option<bool> NewLinesForBracesInProperties { get; } = CSharpFormattingOptions2.NewLinesForBracesInProperties;
80+
81+
public static Option<bool> NewLinesForBracesInAccessors { get; } = CSharpFormattingOptions2.NewLinesForBracesInAccessors;
82+
83+
public static Option<bool> NewLinesForBracesInAnonymousMethods { get; } = CSharpFormattingOptions2.NewLinesForBracesInAnonymousMethods;
84+
85+
public static Option<bool> NewLinesForBracesInControlBlocks { get; } = CSharpFormattingOptions2.NewLinesForBracesInControlBlocks;
86+
87+
public static Option<bool> NewLinesForBracesInAnonymousTypes { get; } = CSharpFormattingOptions2.NewLinesForBracesInAnonymousTypes;
88+
89+
public static Option<bool> NewLinesForBracesInObjectCollectionArrayInitializers { get; } = CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers;
90+
91+
public static Option<bool> NewLinesForBracesInLambdaExpressionBody { get; } = CSharpFormattingOptions2.NewLinesForBracesInLambdaExpressionBody;
92+
93+
public static Option<bool> NewLineForElse { get; } = CSharpFormattingOptions2.NewLineForElse;
94+
95+
public static Option<bool> NewLineForCatch { get; } = CSharpFormattingOptions2.NewLineForCatch;
96+
97+
public static Option<bool> NewLineForFinally { get; } = CSharpFormattingOptions2.NewLineForFinally;
98+
99+
public static Option<bool> NewLineForMembersInObjectInit { get; } = CSharpFormattingOptions2.NewLineForMembersInObjectInit;
100+
101+
public static Option<bool> NewLineForMembersInAnonymousTypes { get; } = CSharpFormattingOptions2.NewLineForMembersInAnonymousTypes;
102+
103+
public static Option<bool> NewLineForClausesInQuery { get; } = CSharpFormattingOptions2.NewLineForClausesInQuery;
104+
}
105+
}

src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptionsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public CSharpFormattingOptionsProvider()
1717
{
1818
}
1919

20-
public ImmutableArray<IOption> Options { get; } = CSharpFormattingOptions.AllOptions;
20+
public ImmutableArray<IOption> Options { get; } = CSharpFormattingOptions2.AllOptions.As<IOption>();
2121
}
2222
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
#nullable enable
6+
7+
using Microsoft.CodeAnalysis.Options;
8+
9+
namespace Microsoft.CodeAnalysis.Formatting
10+
{
11+
public static partial class FormattingOptions
12+
{
13+
public static PerLanguageOption<bool> UseTabs { get; } = FormattingOptions2.UseTabs;
14+
15+
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
16+
public static PerLanguageOption<int> TabSize { get; } = FormattingOptions2.TabSize;
17+
18+
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
19+
public static PerLanguageOption<int> IndentationSize { get; } = FormattingOptions2.IndentationSize;
20+
21+
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
22+
public static PerLanguageOption<IndentStyle> SmartIndent { get; } = FormattingOptions2.SmartIndent;
23+
24+
public static PerLanguageOption<string> NewLine { get; } = FormattingOptions2.NewLine;
25+
26+
internal static Option<bool> InsertFinalNewLine { get; } = FormattingOptions2.InsertFinalNewLine;
27+
28+
internal static Option<int> PreferredWrappingColumn { get; } = FormattingOptions2.PreferredWrappingColumn;
29+
30+
internal static Option<bool> AllowDisjointSpanMerging { get; } = FormattingOptions2.AllowDisjointSpanMerging;
31+
32+
internal static readonly PerLanguageOption<bool> AutoFormattingOnReturn = FormattingOptions2.AutoFormattingOnReturn;
33+
}
34+
}

src/Workspaces/Core/Portable/Formatting/FormattingOptionsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public FormattingOptionsProvider()
1717
{
1818
}
1919

20-
public ImmutableArray<IOption> Options { get; } = FormattingOptions.AllOptions;
20+
public ImmutableArray<IOption> Options { get; } = FormattingOptions2.AllOptions.As<IOption>();
2121
}
2222
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.CodeAnalysis.CSharp.Formatting
1717
{
18-
public static partial class CSharpFormattingOptions
18+
internal static partial class CSharpFormattingOptions2
1919
{
2020
internal static bool DetermineIfSpaceOptionIsSet(string value, SpacingWithinParenthesesOption parenthesesSpacingOption)
2121
=> (from v in value.Split(',').Select(v => v.Trim())

0 commit comments

Comments
 (0)