Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the first set of editor options for visual studio #15020

Merged

Conversation

jmarolf
Copy link
Contributor

@jmarolf jmarolf commented Nov 5, 2016

@dotnet/roslyn-ide @jasonmalinowski

Adds the following options

Advanced

editorconfig name possible values
dotnet_sort_system_directives_first true , false

Indentation Options

editorconfig name possible values
csharp_indent_block_contents true , false
csharp_indent_braces true , false
csharp_indent_case_contents true , false
csharp_indent_switch_labels true , false
csharp_indent_labels flush_left , no_change , one_less_than_current

New Line Options

editorconfig name possible values
csharp_new_line_before_open_brace accessors, anonymous_methods, anonymous_types, control_blocks, events, indexers, lambdas, local_functions, methods, object_collection, properties, types, all, none (or separate with ',')
csharp_new_line_before_else true , false
csharp_new_line_before_catch true , false
csharp_new_line_before_finally true , false
csharp_new_line_before_members_in_object_initializers true , false
csharp_new_line_before_members_in_anonymous_types true , false
csharp_new_line_within_query_expression_clauses true , false

Spacing Options

editorconfig name possible values
csharp_space_after_cast true , false
csharp_space_after_colon_in_inheritance_clause true , false
csharp_space_after_comma true , false
csharp_space_after_dot true , false
csharp_space_after_keywords_in_control_flow_statements true , false
csharp_space_after_semicolon_in_for_statement true , false
csharp_space_around_binary_operators none, before_and_after, ignore
csharp_space_around_declaration_statements ignore, do_not_ignore
csharp_space_before_colon_in_inheritance_clause true , false
csharp_space_before_comma true , false
csharp_space_before_dot true , false
csharp_space_before_semicolon_in_for_statement true , false
csharp_space_before_open_square_brackets true , false
csharp_space_between_empty_square_brackets true , false
csharp_space_between_method_declaration_name_and_open_parenthesis true , false
csharp_space_between_method_declaration_parameter_list_parentheses true , false
csharp_space_between_method_declaration_empty_parameter_list_parentheses true , false
csharp_space_between_method_call_name_and_opening_parenthesis true , false
csharp_space_between_method_call_parameter_list_parentheses true , false
csharp_space_between_method_call_empty_parameter_list_parentheses true , false
csharp_space_between_square_brackets true , false
csharp_space_between_parentheses expressions, type_casts, control_flow_statements

Wrapping Options

editorconfig name possible values
csharp_preserve_single_line_blocks true , false
csharp_preserve_single_line_statements true , false

using Microsoft.CodeAnalysis.Options;
using System.Linq;
Copy link
Contributor

@dpoeschl dpoeschl Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort usings. #Pending


public static Option<bool> SpaceWithinMethodDeclarationParenthesis { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceWithinMethodDeclarationParenthesis), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceWithinMethodDeclarationParenthesis"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_method_declaration_parameter_list_parenthesis"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within the parentheses (plural)? #Pending


public static Option<bool> SpaceWithinMethodCallParentheses { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceWithinMethodCallParentheses), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceWithinMethodCallParentheses"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_method_call_parameter_list_parenthesis"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Parentheses (plural)? #Pending


public static Option<bool> SpaceWithinExpressionParentheses { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceWithinExpressionParentheses), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceWithinExpressionParentheses"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_parentheses", (s) => ParseSpaceOptions(s, SpacingOption.Expressions)),
Copy link
Contributor

@dpoeschl dpoeschl Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a zillion other csharp_space_within_*_parentheses, so this one without the * is confusing to me. Maybe csharp_space_within_expression_parentheses? #Resolved


public static Option<bool> SpaceWithinCastParentheses { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceWithinCastParentheses), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceWithinCastParentheses"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_parentheses", (s) => ParseSpaceOptions(s, SpacingOption.TypeCasts)),
Copy link
Contributor

@dpoeschl dpoeschl Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is why. You collapsed several of these into one... Ugh. csharp_space_within_other_parentheses? I don't love it, but I don't love the unqualified version more. #ByDesign

Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Feel free to disagree) #ByDesign


public static Option<bool> SpacesIgnoreAroundVariableDeclaration { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpacesIgnoreAroundVariableDeclaration), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpacesIgnoreAroundVariableDeclaration"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_in_declaration_statements"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of these says "spacesignore" and the other one says "space_in" -- is this backwards? #Resolved


public static Option<bool> SpaceAfterColonInBaseTypeDeclaration { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceAfterColonInBaseTypeDeclaration), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceAfterColonInBaseTypeDeclaration"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_after_colon_for_base_or_interface_in_type_declaration"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do better with the name? I'm not sure how, but maybe there's a way. #Resolved


public static Option<bool> IndentSwitchSection { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(IndentSwitchSection), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.IndentSwitchSection"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_indent_case_labels"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also indents default: which is probably why they call it "SwitchSection" in the option name. Not sure I care, though. #Resolved

Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you matched the text in Tools | Options. It's fine. #Resolved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"indent_switch_labels"


public static Option<bool> WrappingPreserveSingleLine { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(WrappingPreserveSingleLine), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.WrappingPreserveSingleLine"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_wrap_block_on_single_line"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For "spacing" and "indent" the names read nicely. csharp_space_goes_wherever and indent_some_construct. With wrap it doesn't parse so cleanly for me. This makes it seem like you're trying to wrap a block on a single line. I understand that it should be parsed csharp_wrap (pause) block_on_single_line but it's hard to read it that way. #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tradeoff between understandable structure and English readability. I don't think I'll change this as I csharp_wrap gives structure to these set of options


In reply to: 87113514 [](ancestors = 87113514)

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csharp_wrapping_preserve_block_on_single_line?
csharp_wrapping_keep_block_on_single_line?
csharp_wrapping_do_not_wrap_single_line_block? (my preference)
csharp_wrapping_preserve_single_line_block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think I will use wrapping as no other option uses that tense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, "csharp_wrap_block_on_single_line = true" means "do not wrap a block on a single line? That's super8 confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need something to indicate that when these are set to true, we do not wrap.

Copy link
Contributor Author

@jmarolf jmarolf Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyrusNajmabadi

So, "csharp_wrap_block_on_single_line = true" means "do not wrap a block on a single line?

That is not correct

csharp_wrap_block_on_single_line = true
image

csharp_wrap_block_on_single_line = false
image


public static Option<bool> NewLineForMembersInAnonymousTypes { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(NewLineForMembersInAnonymousTypes), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.NewLineForMembersInAnonymousTypes"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_new_line_before_members_in_anonymouse_types"),
Copy link
Contributor

@dpoeschl dpoeschl Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csharp_new_line_before_members_in_anonymouse_types incorrect spelling of anonymous #Resolved

@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch 4 times, most recently from 6b1fabe to c20c007 Compare November 10, 2016 00:37
{
public static partial class CSharpFormattingOptions
{
internal static bool ParseParenthesesSpaceOptions(string value, SpacingWithinParenthesesOption parenthesesSpacingOption)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange function signature. It's called 'ParseXXX' but returns a bool?

switch (binaryOperatorSpacingValue)
{
case "ignore": return BinaryOperatorSpacingOptions.Ignore;
case "none": return BinaryOperatorSpacingOptions.Remove;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it bothers me that tehse names don't match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm preferring the names we expose in the IDE over the variable names. It would be a breaking API change the modify the enum names as BinaryOperatorSpacingOptions is a public type.


internal static bool ParseNewLineOption(string value, NewLineOption optionName)
{
var values = value.Split(',').Select((v) => v.Trim());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parens around (v) not needed

{
var values = value.Split(',').Select((v) => v.Trim());

if (values.Any((v) => v == "all"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same.


public static Option<bool> SpaceBetweenEmptyMethodCallParentheses { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceBetweenEmptyMethodCallParentheses), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceBetweenEmptyMethodCallParentheses"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_method_call_empty_parameter_list_parentheses"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm torn on how i feel about this. So Roslyn calls these 'Invocations' not method-calls. But the old IDE called the method calls. I'm wondering if we should unify on roslyn naming as we move forward. A core reason for this is that we often have confusion around what the option name is and what it actually controls with our new APi.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calls is fine - it's throughout the IDE (Call Hierachy, Call stack, etc). I see no reason to change the user facing term to the API term.

[InlineData("type_casts, expressions, , ", SpacingWithinParenthesesOption.TypeCasts)]
[InlineData("expressions , , , control_flow_statements", SpacingWithinParenthesesOption.ControlFlowStatements)]
[InlineData("expressions , , , control_flow_statements", SpacingWithinParenthesesOption.Expressions)]
[InlineData(", , , control_flow_statements", SpacingWithinParenthesesOption.ControlFlowStatements)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

witchcraft!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, get rid of a bunch of brackets and just put , between the atrributes

@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch from c20c007 to 2654a6c Compare November 11, 2016 03:46
@CyrusNajmabadi
Copy link
Member

We can deprecate the old names, and add the new names to the enum, with the same values as the older ones.

Copy link
Member

@Pilchie Pilchie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So excited to have this.

Should we re-base to dev15-rc2?


public static Option<bool> SpaceBetweenEmptyMethodCallParentheses { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceBetweenEmptyMethodCallParentheses), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceBetweenEmptyMethodCallParentheses"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_within_method_call_empty_parameter_list_parentheses"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calls is fine - it's throughout the IDE (Call Hierachy, Call stack, etc). I see no reason to change the user facing term to the API term.

{
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpacingAfterMethodDeclarationName), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpacingAfterMethodDeclarationName"));
storageLocations: new OptionStorageLocation[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can you use implicit array creations here with just new [] {...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EditorConfigStorageLocation and RoamingProfileStorageLocation are both derived from OptionStorageLocation but implicit array creation cannot infer OptionStorageLocation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems unexpected/crappy. :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could cast them explcitly

public static Option<bool> SpaceWithinMethodDeclarationParenthesis { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpaceWithinMethodDeclarationParenthesis), defaultValue: false,
             storageLocations: new [] {
                 (OptionStorageLocation)new EditorConfigStorageLocation("csharp_space_within_method_declaration_parameter_list_parentheses"),
                 (OptionStorageLocation)new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpaceWithinMethodDeclarationParenthesis")});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is fine if it's the best the compiler can do.

[InlineData("type_casts, expressions, , ", SpacingWithinParenthesesOption.TypeCasts)]
[InlineData("expressions , , , control_flow_statements", SpacingWithinParenthesesOption.ControlFlowStatements)]
[InlineData("expressions , , , control_flow_statements", SpacingWithinParenthesesOption.Expressions)]
[InlineData(", , , control_flow_statements", SpacingWithinParenthesesOption.ControlFlowStatements)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, get rid of a bunch of brackets and just put , between the atrributes

@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch from 2654a6c to 3f8fc56 Compare November 11, 2016 20:33
@jmarolf jmarolf changed the base branch from master to dev15-rc2 November 11, 2016 20:33
@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch from 3f8fc56 to 4769c05 Compare November 11, 2016 20:35
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks only.

{
public static partial class CSharpFormattingOptions
{
internal static bool DetermindIfSpaceOptionIsSet(string value, SpacingWithinParenthesesOption parenthesesSpacingOption)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "Determind".

{
internal static bool DetermindIfSpaceOptionIsSet(string value, SpacingWithinParenthesesOption parenthesesSpacingOption)
=> (from v in value.Split(',').Select(v => v.Trim())
let option = ConvertToSpacingOption(v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just select ConvertToSpacingOption directly and the .Any() would just handle the null case for you, right?

}
}

internal static object ParseEditorConfigSpacingAroundBinaryOperator(string binaryOperatorSpacingValue)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why weakly typed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EditorConfigStorageLocation requires Func<string, object>

Error   CS0407  'BinaryOperatorSpacingOptions CSharpFormattingOptions.ParseEditorConfigSpacingAroundBinaryOperator(string)' has the wrong return type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer the return type still be: "BinaryOperatorSpacingOptions ". But htat hte consumer does hte conversion with a lambda.

}
}

internal static object ParseEditorConfigLabelPositioning(string lableIndentationValue)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "lable"

{
var values = value.Split(',').Select(v => v.Trim());

if (values.Any(v => v == "all"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Contains?

}

return (from v in values
let option = ConvertToNewLineOption(v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unify this code with the other Determine* functions?

{
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpacingAfterMethodDeclarationName), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpacingAfterMethodDeclarationName"));
storageLocations: new OptionStorageLocation[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems unexpected/crappy. :-/


public static Option<bool> SpacesIgnoreAroundVariableDeclaration { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpacesIgnoreAroundVariableDeclaration), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpacesIgnoreAroundVariableDeclaration"));
storageLocations: new OptionStorageLocation[] {
new EditorConfigStorageLocation("csharp_space_ignore_around_declaration_statements"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one better done as csharp_space_around_declaration_statements = ignore or something? It feels like having the checkboxes that say "don't do this".

[InlineData("one_less_than_current", LabelPositionOptions.OneLess)]
static void TestParseEditorConfigLabelPositioningTrue(string value, LabelPositionOptions expectedValue)
{
Assert.True((LabelPositionOptions)ParseEditorConfigLabelPositioning(value) == expectedValue,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's make these methods more strongly typed.

@jmarolf
Copy link
Contributor Author

jmarolf commented Nov 12, 2016

@Pilchie @MattGertz @natidea I've re-targeted the PR against RC.2, please let me know it we want to take this.

Customer scenario

  • The customer can now set visual studio settings in editorconfig files that allow different editor options to be specified per folder.

Bugs this fixes: (either VSO or GitHub links)

Workarounds

  • The user can manually change their settings each time they open a solution file, but cannot have different settings from different folders within that solution.

Risk

  • This uses the editorconfig API from the Visual Studio Platfrom team, it does not introduce code into roslyn other than consuming that API and handing it to the options service

Performance impact

  • When folders are quieried is set by the Visual Studio Platfrom team which has done the work to not requery unless their are file changes. Perf impact should be Low

Is this a regression from a previous update?

  • No.

Root cause analysis: how did we miss it? What tests are we adding to guard against it in the future?

  • This is not a regression. It is new feature work.

How was the bug found? (E.g. customer reported it vs. ad hoc testing)

  • This is not a bug. It is new feature work.

@jmarolf
Copy link
Contributor Author

jmarolf commented Nov 12, 2016

@CyrusNajmabadi

We can deprecate the old names, and add the new names to the enum, with the same values as the older ones.

We certainly can. I would need to compat council to sign off in that case

@MattGertz
Copy link
Contributor

Approved pending @dpoeschl agreement re:his requested changes.

{
public static Option<bool> SpacingAfterMethodDeclarationName { get; } = new Option<bool>(nameof(CSharpFormattingOptions), nameof(SpacingAfterMethodDeclarationName), defaultValue: false,
storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.SpacingAfterMethodDeclarationName"));
storageLocations: new OptionStorageLocation[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is fine if it's the best the compiler can do.

@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch from 33fc8a6 to 4c9163f Compare November 14, 2016 20:27
Copy link
Contributor

@dpoeschl dpoeschl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the changes. Looking good.

@CyrusNajmabadi
Copy link
Member

csharp_space_after_colon_for_base_or_interface_in_type_declaration => csharp_space_after_colon_in_inheritance_clause

@CyrusNajmabadi
Copy link
Member

csharp_space_between_method_declaration_name_and_open_parentheses => csharp_space_between_method_declaration_name_and_open_parenthesis
csharp_space_between_method_call_name_and_opening_parentheses => csharp_space_between_method_call_name_and_open_parenthesis

csharp_space_around_operators => csharp_space_around_binary_operators ?

csharp_keep_block_on_single_line => csharp_preserve_single_line_blocks
csharp_keep_statement_and_member_declarations_on_same_line => csharp_preserve_single_line_statements

csharp_preserve_single_line_member_declarations

@CyrusNajmabadi
Copy link
Member

not suggesitng, just preserving:
csharp_indent_label_one_less_than_current_level
csharp_indent_label_do_not_change
csharp_indent_label_to_zero_column

also: mouse.

@jmarolf jmarolf force-pushed the feature/editorconfig-general-editor-options branch from 6ab5f8e to d46a349 Compare November 16, 2016 01:07
@jmarolf
Copy link
Contributor Author

jmarolf commented Nov 16, 2016

@CyrusNajmabadi Updated with your suggestions

for csharp_indent_labels I changed the possible options to be flush_left , no_change , one_less_than_current

@CyrusNajmabadi
Copy link
Member

csharp_new_line_before_open_brace
possible values has event_accessor, but not property_accessors?

Spacing Options
can we sort these by name?

Usages of both between and within. Seems synonymous.

What happened to csharp_preserve_single_line_member_declarations?

@jmarolf
Copy link
Contributor Author

jmarolf commented Nov 16, 2016

@CyrusNajmabadi

csharp_new_line_before_open_brace possible values has event_accessor, but not property_accessors?

Options updated

Spacing Options can we sort these by name?

Done

Usages of both between and within. Seems synonymous.

Use within everywhere

What happened to csharp_preserve_single_line_member_declarations?

I don't know, I've never used that as a name for anything and I can't remember why you wrote it in the previous comment. Do you recall what this was about?

@CyrusNajmabadi
Copy link
Member

csharp_space_around_declaration_statements

Is this about the space in a field/location declaration? Or does it refer to more than that?

@CyrusNajmabadi
Copy link
Member

Overall i like it. I feel like i like "between" versus "within". I think it reads better. But if you feel "within" is better, i'll defer.

@jmarolf
Copy link
Contributor Author

jmarolf commented Nov 17, 2016

@CyrusNajmabadi

Is this about the space in a field/location declaration? Or does it refer to more than that?

It should just be about field /local declarations. I've updated the possible values to be more clear

editorconfig name possible values
csharp_space_around_declaration_statements ignore, do_not_ignore

I like "between" versus "within". I think it reads better. But if you feel "within" is better, i'll defer.

I only picked within because between was one character longer. I will happily switch it back for better readability

@CyrusNajmabadi
Copy link
Member

👍

@ygoe
Copy link

ygoe commented Apr 17, 2017

How is csharp_space_between_parentheses supposed to be used? It looks like the values are actually options that need a value like true or false. This design seems broken. I couldn't follow the code far enough to find the meaning.

@jmarolf
Copy link
Contributor Author

jmarolf commented Apr 17, 2017

You can specify expressions, type_casts, or control_flow_statements separated by a comma.

If expressions is present it means "insert space within parenthesis of expressions" like so:

var x = 3;
var y = 4;
var z = ( x * y ) - ( ( y - x ) * 3 );

If expressions is not present your code will be formatted like:

var x = 3;
var y = 4;
var z = (x * y) - ((y - x) * 3);

If type_casts is present it means "insert space within parenthesis of type casts" like so:

int y = ( int )x;

If type_casts is not present your code will be formatted like:

int y = (int)x;

If control_flow_statements is present it means "insert space within parenthesis of control flow statements" like so:

for( int i; i < x; i++ )
{
}

If control_flow_statements is not present your code will be formatted like:

for(int i; i < x; i++)
{
}

An example of all three specified in an editorconfig file would be:

# Code files
[*.cs]
csharp_space_between_parentheses = expressions,type_casts,control_flow_statements

@ygoe
Copy link

ygoe commented Apr 18, 2017

I didn't know multiple values were allowed, this isn't obvious.

What's the value for none of these? Simply csharp_space_between_parentheses =?

@jmarolf
Copy link
Contributor Author

jmarolf commented Apr 18, 2017

@ygoe do not specify the option at all if you do not want spaces added in any of these scenarios.

@jmarolf
Copy link
Contributor Author

jmarolf commented Apr 18, 2017

I didn't know multiple values were allowed, this isn't obvious.

Some of these options may be removed at some point due to low to no useage, which is why we haven't documented several of them. Is this an option that you want to turn on?

@ygoe
Copy link

ygoe commented Apr 18, 2017

My point is to explicitly override whatever the IDE is configured to. Not specifying the option means "no intent" which is different from "intent to not use spaces". All other options let me specify "true", "false" or nothing at all. This one is different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants