Version Used:
Microsoft Visual Studio Enterprise 2017
Version 15.6.3
VisualStudio.15.Release/15.6.3+27428.2011
Microsoft .NET Framework
Version 4.7.02556
Installed Version: Enterprise
Extensions:
TechTalk SpecFlow 30F08A29-D27E-42FF-92D3-50391313A1EF
TechTalk SpecFlow - Binding business requirements to .NET code, http://www.specflow.org
Copyright © 2009–2017 TechTalk
TSVN 1.9
Control TortoiseSVN from within Visual Studio
VsVim 2.5.0.0
VsVim is a Vim emulator for Visual Studio
WiX Toolset Visual Studio Extension 0.9.21.62588
WiX Toolset Visual Studio Extension version 0.9.21.62588
Copyright (c) .NET Foundation and contributors. All rights reserved.
Editorconfig also doesn't work in this lab environment (which is MS official one, https://www.microsoft.com/handsonlabs/Account/SignIn?redirect=/handsonlabs/SelfPacedLabs?storyId=external://content-private/content/external/Microsoft-Virtual-Labs/DT00178).
Used https://github.com/dotnet/roslyn/blob/master/.editorconfig as template.
Steps to Reproduce:
Expected Behavior:
Program.cs gets reformated based on the given .editoconfig
Actual Behavior:
Indents are not updated. It seems that no changes in .editorconfig are loaded by Visual Studio.
Visual Studio 15.6.4
Same issue with
[*.cs]
csharp_new_line_before_open_brace = none
When I do "Format Document" all {
are moved to the next line.
Visual Studio 15.6.6
Somehow Resharper knew which rules work and which not
Everything else was applied after "Format Document" as @ashmind said.
Same problem here, VIsual Studio 15.7.1
Same problem for me with 15.7.2. here is my editor config, no error is shown for violations:
# EditorConfig is awesome:http://EditorConfig.org
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom
# Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
# JSON files
[*.json]
indent_size = 2
# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error
# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:suggestion
# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:error
# CSharp code style settings:
[*.cs]
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = false:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:suggestion
# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none
# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
This is a probable duplicate of #15003
I'm having the same issue. I don't believe this is a duplicate of #15003 as suggested above. I have tried restarting VS, reloading the project, closing and reopening the file, and reloading the project.
Version Used:
Microsoft Visual Studio Professional 2017
Version 15.7.3
Microsoft .NET Framework Version 4.6.01586
Steps to Reproduce:
Expected Behavior:
Formatting is applied. Methods where formatting isn't applied are displayed as errors.
Actual Behavior:
Nothing happens.
@cmbentley Your issue is partially a duplicate of #15003, and partially a duplicate of #7067/#8268.
I'm running VS2017 15.7.4 with:
.editorconfig
in my project directory with indent_style = tab
set.editorconfig
in the solution directory with indent_style = space
setWhen I open a .cs
file in that project and choose Edit > Advanced > Format document it uses spaces instead of tabs.
This is not a duplicate of #15003 because it keeps on happening regardless of reloading Visual Studio or the solution or the code file and the .editorconfig
file is not new.
@Jehoel I am not able to reproduce that in 15.8 Preview 3.
The main issue reported here is fixed in 15.8 Preview 3. @cmbentley The additional issues you reported are covered by the other linked issues.
Is there a workaround for us who can't/don't want to install the preview version?
@dealdiane The workaround prior to 15.8 is closing and reopening source files after making a change to .editorconfig.
@sharwell That doesn't work for me 😫
@Jehoel Can you file your issue separately? I'm not sure it's the same as the others in this issue.
@dealdiane @mle-ii you both upvoted the post from @Jehoel, but it's hard for me to tell which of the related issues above you were hoping to see fixed. If you are looking at the same spaces/tabs issue as @Jehoel, can you upvote that issue when it's available? Otherwise, can you post a different issue asking for a workaround in 15.7 for the specific issue you are hitting (be very specific about how you encountered the issue and the part you need to find a workaround for).
@sharwell I upvoted because I couldn't get the .editorconfig working at all even after reopening the source files. It wasn't just the tab/space that didn't work. All the rules in my .editorconfig didn't work at all. It was exactly like what the title of this issue says.
It was only after I restarted Visual Studio, and reloaded the solution, that I got it working. Even after that though, any update in the .editorconfig, I had to unload and reload the project for Visual Studio to pick up the rule changes.
It was only after I restarted Visual Studio, and reloaded the solution, that I got it working. Even after that though, any update in the .editorconfig, I had to unload and reload the project for Visual Studio to pick up the rule changes.
This is an unexpectedly difficult workaround, but I would still consider it a workaround for 15.7 and earlier since the main issues have been fixed for 15.8.
If you happen to get the chance to try 15.8 Preview 4 or newer, please let us know if the experience hasn't substantially improved.
@sharwell I upvoted as none of the work arounds listed here worked for me and was just commiserating with Jehoel.
Made sure VS was on the latest update that I could get which is 15.7.5. I don't see a newer version when I checked for updates right now and it said I had the latest.
I tried reloading the file after closing, that didn't make a difference.
I tried restarting Visual Studio, no difference.
I tried rebooting, no difference.
Looking forward to the fix as I unfortunately have a few teams I work with here that have different settings per repo and it's hard to have to manually set them differently each time I need to edit their files. :(
@mle-ii Can you file a new issue with the following:
Most helpful comment
@sharwell That doesn't work for me 😫