Skip to content

Commit

Permalink
Make similar changes to FormattingOptions and C# FormattingOptions - …
Browse files Browse the repository at this point in the history
…core impl types in shared layer with "2" suffix and shim public API types in Workspaces layer.
  • Loading branch information
mavasani committed Mar 10, 2020
1 parent cd860f7 commit a2c78bd
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 132 deletions.
105 changes: 105 additions & 0 deletions src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
public static partial class CSharpFormattingOptions
{
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = CSharpFormattingOptions2.SpacingAfterMethodDeclarationName;

public static Option<bool> SpaceWithinMethodDeclarationParenthesis { get; } = CSharpFormattingOptions2.SpaceWithinMethodDeclarationParenthesis;

public static Option<bool> SpaceBetweenEmptyMethodDeclarationParentheses { get; } = CSharpFormattingOptions2.SpaceBetweenEmptyMethodDeclarationParentheses;

public static Option<bool> SpaceAfterMethodCallName { get; } = CSharpFormattingOptions2.SpaceAfterMethodCallName;

public static Option<bool> SpaceWithinMethodCallParentheses { get; } = CSharpFormattingOptions2.SpaceWithinMethodCallParentheses;

public static Option<bool> SpaceBetweenEmptyMethodCallParentheses { get; } = CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses;

public static Option<bool> SpaceAfterControlFlowStatementKeyword { get; } = CSharpFormattingOptions2.SpaceAfterControlFlowStatementKeyword;

public static Option<bool> SpaceWithinExpressionParentheses { get; } = CSharpFormattingOptions2.SpaceWithinExpressionParentheses;

public static Option<bool> SpaceWithinCastParentheses { get; } = CSharpFormattingOptions2.SpaceWithinCastParentheses;

public static Option<bool> SpaceWithinOtherParentheses { get; } = CSharpFormattingOptions2.SpaceWithinOtherParentheses;

public static Option<bool> SpaceAfterCast { get; } = CSharpFormattingOptions2.SpaceAfterCast;

public static Option<bool> SpacesIgnoreAroundVariableDeclaration { get; } = CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration;

public static Option<bool> SpaceBeforeOpenSquareBracket { get; } = CSharpFormattingOptions2.SpaceBeforeOpenSquareBracket;

public static Option<bool> SpaceBetweenEmptySquareBrackets { get; } = CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets;

public static Option<bool> SpaceWithinSquareBrackets { get; } = CSharpFormattingOptions2.SpaceWithinSquareBrackets;

public static Option<bool> SpaceAfterColonInBaseTypeDeclaration { get; } = CSharpFormattingOptions2.SpaceAfterColonInBaseTypeDeclaration;

public static Option<bool> SpaceAfterComma { get; } = CSharpFormattingOptions2.SpaceAfterComma;

public static Option<bool> SpaceAfterDot { get; } = CSharpFormattingOptions2.SpaceAfterDot;

public static Option<bool> SpaceAfterSemicolonsInForStatement { get; } = CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement;

public static Option<bool> SpaceBeforeColonInBaseTypeDeclaration { get; } = CSharpFormattingOptions2.SpaceBeforeColonInBaseTypeDeclaration;

public static Option<bool> SpaceBeforeComma { get; } = CSharpFormattingOptions2.SpaceBeforeComma;

public static Option<bool> SpaceBeforeDot { get; } = CSharpFormattingOptions2.SpaceBeforeDot;

public static Option<bool> SpaceBeforeSemicolonsInForStatement { get; } = CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement;

public static Option<BinaryOperatorSpacingOptions> SpacingAroundBinaryOperator { get; } = CSharpFormattingOptions2.SpacingAroundBinaryOperator;

public static Option<bool> IndentBraces { get; } = CSharpFormattingOptions2.IndentBraces;

public static Option<bool> IndentBlock { get; } = CSharpFormattingOptions2.IndentBlock;

public static Option<bool> IndentSwitchSection { get; } = CSharpFormattingOptions2.IndentSwitchSection;

public static Option<bool> IndentSwitchCaseSection { get; } = CSharpFormattingOptions2.IndentSwitchCaseSection;

public static Option<bool> IndentSwitchCaseSectionWhenBlock { get; } = CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock;

public static Option<LabelPositionOptions> LabelPositioning { get; } = CSharpFormattingOptions2.LabelPositioning;

public static Option<bool> WrappingPreserveSingleLine { get; } = CSharpFormattingOptions2.WrappingPreserveSingleLine;

public static Option<bool> WrappingKeepStatementsOnSingleLine { get; } = CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine;

public static Option<bool> NewLinesForBracesInTypes { get; } = CSharpFormattingOptions2.NewLinesForBracesInTypes;

public static Option<bool> NewLinesForBracesInMethods { get; } = CSharpFormattingOptions2.NewLinesForBracesInMethods;

public static Option<bool> NewLinesForBracesInProperties { get; } = CSharpFormattingOptions2.NewLinesForBracesInProperties;

public static Option<bool> NewLinesForBracesInAccessors { get; } = CSharpFormattingOptions2.NewLinesForBracesInAccessors;

public static Option<bool> NewLinesForBracesInAnonymousMethods { get; } = CSharpFormattingOptions2.NewLinesForBracesInAnonymousMethods;

public static Option<bool> NewLinesForBracesInControlBlocks { get; } = CSharpFormattingOptions2.NewLinesForBracesInControlBlocks;

public static Option<bool> NewLinesForBracesInAnonymousTypes { get; } = CSharpFormattingOptions2.NewLinesForBracesInAnonymousTypes;

public static Option<bool> NewLinesForBracesInObjectCollectionArrayInitializers { get; } = CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers;

public static Option<bool> NewLinesForBracesInLambdaExpressionBody { get; } = CSharpFormattingOptions2.NewLinesForBracesInLambdaExpressionBody;

public static Option<bool> NewLineForElse { get; } = CSharpFormattingOptions2.NewLineForElse;

public static Option<bool> NewLineForCatch { get; } = CSharpFormattingOptions2.NewLineForCatch;

public static Option<bool> NewLineForFinally { get; } = CSharpFormattingOptions2.NewLineForFinally;

public static Option<bool> NewLineForMembersInObjectInit { get; } = CSharpFormattingOptions2.NewLineForMembersInObjectInit;

public static Option<bool> NewLineForMembersInAnonymousTypes { get; } = CSharpFormattingOptions2.NewLineForMembersInAnonymousTypes;

public static Option<bool> NewLineForClausesInQuery { get; } = CSharpFormattingOptions2.NewLineForClausesInQuery;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public CSharpFormattingOptionsProvider()
{
}

public ImmutableArray<IOption> Options { get; } = CSharpFormattingOptions.AllOptions;
public ImmutableArray<IOption> Options { get; } = CSharpFormattingOptions2.AllOptions.As<IOption>();
}
}
34 changes: 34 additions & 0 deletions src/Workspaces/Core/Portable/Formatting/FormattingOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Formatting
{
public static partial class FormattingOptions
{
public static PerLanguageOption<bool> UseTabs { get; } = FormattingOptions2.UseTabs;

// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<int> TabSize { get; } = FormattingOptions2.TabSize;

// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<int> IndentationSize { get; } = FormattingOptions2.IndentationSize;

// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<IndentStyle> SmartIndent { get; } = FormattingOptions2.SmartIndent;

public static PerLanguageOption<string> NewLine { get; } = FormattingOptions2.NewLine;

internal static Option<bool> InsertFinalNewLine { get; } = FormattingOptions2.InsertFinalNewLine;

internal static Option<int> PreferredWrappingColumn { get; } = FormattingOptions2.PreferredWrappingColumn;

internal static Option<bool> AllowDisjointSpanMerging { get; } = FormattingOptions2.AllowDisjointSpanMerging;

internal static readonly PerLanguageOption<bool> AutoFormattingOnReturn = FormattingOptions2.AutoFormattingOnReturn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public FormattingOptionsProvider()
{
}

public ImmutableArray<IOption> Options { get; } = FormattingOptions.AllOptions;
public ImmutableArray<IOption> Options { get; } = FormattingOptions2.AllOptions.As<IOption>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
public static partial class CSharpFormattingOptions
internal static partial class CSharpFormattingOptions2
{
internal static bool DetermineIfSpaceOptionIsSet(string value, SpacingWithinParenthesesOption parenthesesSpacingOption)
=> (from v in value.Split(',').Select(v => v.Trim())
Expand Down
Loading

0 comments on commit a2c78bd

Please sign in to comment.