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

Support enforcing "Code Style" in the IDE #7071

Closed
18 of 42 tasks
Pilchie opened this issue Nov 25, 2015 · 16 comments
Closed
18 of 42 tasks

Support enforcing "Code Style" in the IDE #7071

Pilchie opened this issue Nov 25, 2015 · 16 comments

Comments

@Pilchie
Copy link
Member

Pilchie commented Nov 25, 2015

@sharwell
Copy link
Member

I think the Roslyn (referring to this repository) should only be responsible for a subset of these, plus one you didn't mention:

This would allow the analyzers themselves to be implemented and distributed independently, and developed at a faster rate in a lighter-weight environment.

I believe that moving the analyzers themselves out of this repository and in general not giving them "special treatment" that doesn't apply to other analyzers will substantially benefit the entire analyzer ecosystem. And if you're already rewriting the formatter as a set of analyzers, I doubt you'll ever have a better time to do so. 😄

@Pilchie
Copy link
Member Author

Pilchie commented Nov 26, 2015

For your third bullet we had tentatively decided not to support it, and instead offer something more like VSCode's configuration experience - show a readonly view of our default .editorconfig file and allow you to override it per-user.

There are definitely tradeoffs to moving the rest of the work outside of the Roslyn repo - we'd like to bring this into the box as part of the default experience, and that's MUCH harder if we don't have everything packaged together. That isn't to say that we don't want to re-use a bunch of code, but we need to figure out the right approach to that.

Regarding rewriting the formatter as a bunch of analyzers, that's unlikely. Generally the formatting code is VERY performance sensitive, even when it has to make thousands of changes, and we're unlikely to be able to achieve that as a set of independent code fixes as opposed to the rewriter we have today. Additionally, we're not sure that the level of granularity StyleCop exposes around whitespace formatting (and distinct error codes, etc) are actually beneficial to anyone, so we were thinking of consolidating it into a simpler "Your code's whitespace is not consistent" sort of diagnostic, the fix for which would be to run the formatting engine.

@AdamSpeight2008
Copy link
Contributor

Is there a way to bring the tab spacing options into this, that is to make them solution specific.
I personally like 2 space indentation, this project uses 4 space indentation.

@Pilchie
Copy link
Member Author

Pilchie commented Nov 26, 2015

@AdamSpeight2008 - yes, we'd want to solve that, likely as part of #7060.

@sharwell
Copy link
Member

Additionally, we're not sure that the level of granularity StyleCop exposes around whitespace formatting (and distinct error codes, etc) are actually beneficial to anyone, so we were thinking of consolidating it into a simpler "Your code's whitespace is not consistent" sort of diagnostic, the fix for which would be to run the formatting engine.

Note that I wasn't saying StyleCopAnalyzers is necessarily the location for these, or that you should take the same rules. The takeaway from that experience with respect to this issue is the fact that we've been able to make rapid progress on the features while working in a small code base, and get these changes out to a reasonably large number of users without too much trouble. The analyzers mentioned in this issue are similar - they involve supporting a wide variety of strongly-held individual opinions. I believe they would benefit from the same type of development and distribution effort.

@alrz
Copy link
Member

alrz commented Dec 1, 2015

I'm not sure if this is relevant to this issue but it would be nice that code formatter preserve this style

using( ... ) try {
  ...
} catch {
 ...
}

@Pilchie
Copy link
Member Author

Pilchie commented Dec 3, 2015

@alrz That's not a style I've ever seen used before, and it's not something we have been tracking. Do you know of any codebases that actually use this style?

@alrz
Copy link
Member

alrz commented Dec 3, 2015

@Pilchie Probably it was Java, Java IDEs preserve this style. (I don't remember where I saw it though)

@mkrueger
Copy link
Contributor

The roslyn formatter is very inflexible. However it's enough to support the allman code style and most K&R variants. So it is ok.

If you're really want to improve that and searching for ideas. I can recommend looking at Resharper or Jetbrains IDEA for a good set of formatting options. Or looking at the old NRefactory 5 option set:

https://github.com/icsharpcode/NRefactory/blob/master/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs

If it's worth implementing it - I don't know :)

+1 for making the options more fine grained & making the option API more usable.

@Pilchie Pilchie modified the milestones: 2.0 (RC), 2.0 (Preview) Mar 15, 2016
@Pilchie
Copy link
Member Author

Pilchie commented Mar 15, 2016

Moving this to 2.0 (Preview) to continue working on it.

@alrz
Copy link
Member

alrz commented Apr 16, 2016

An option in "formatting" category to break method parameter list (or any other code if possible) to multiple lines (one per param) when it's longer than 80 chars would be great.

@lorcanmooney
Copy link
Contributor

I see #3798 (Options can be populated from .editorconfig files), but will there be support for going the other way - exporting our current style preferences into an .editorconfig file?

@Pilchie
Copy link
Member Author

Pilchie commented Nov 16, 2016

We want to do that, but we're not sure we'll get there before RTM?

@Pilchie Pilchie modified the milestones: Unknown, 2.0 (RTM) Jan 19, 2017
@jmarolf
Copy link
Contributor

jmarolf commented Feb 6, 2017

@Pilchie can we track this as a project instead of an issue?

@Pilchie
Copy link
Member Author

Pilchie commented Feb 6, 2017

I still haven't looked into "Projects", but it's on my todo list. agree that this isn't a great system.

@Pilchie
Copy link
Member Author

Pilchie commented Feb 6, 2017

Okay - I was going to triage and add more items to this list, and decided to just switch now. @kuhlenh Take a look at https://github.com/dotnet/roslyn/projects/4.

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

No branches or pull requests

8 participants