Skip to content

Allow vertical alignment without triggering IDE0055 #51389

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

Open
lonix1 opened this issue Feb 22, 2021 · 9 comments
Open

Allow vertical alignment without triggering IDE0055 #51389

lonix1 opened this issue Feb 22, 2021 · 9 comments
Labels
Area-IDE Feature - IDE0055 Formatting Feature Request IDE-Formatter Code formatter and/or smart indent
Milestone

Comments

@lonix1
Copy link

lonix1 commented Feb 22, 2021

Brief description:

The csharp_space_around_declaration_statements allows this:

var a    = foo;
var bc   = 123;
var some = thing;

But all the following have no support:

a    = foo;
bc   = 123;
some = thing;
static int Foo(int x, int y) => (x, y) switch {
  (    0,     0) => 0,
  (int i,     0) => 11,
  (int i, int j) => i + j,
};
if (foo == null)       throw new ArgumentNullException(nameof(foo));
if (foo == wrongValue) throw new ArgumentException(nameof(foo));
if (qux == 42)         throw new ArgumentOutOfRangeException(nameof(qux));
switch (i) {
  case 0:      foo(); break;
  case 1:      bar(); break;
  case 424242: baz(); break;
  case XYZ:    return;
  default:     throw new InvalidOperationException();
}
     if (true)      foo();
else if (false)     bar();
else if (something) baz();
else                qux();
AddJsonFile("appsettings.json",                    optional:false, reloadOnChange:true)
AddJsonFile($"appsettings.{environmentName}.json", optional:true,  reloadOnChange:true)

Please consider adding support for them?

Languages applicable:

C#

Code example that the analyzer should report:

See above

Documentation requirements:

When this analyzer is implemented, it must be documented by following the steps at Documentation for IDE CodeStyle analyzers.

@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 22, 2021
@Youssef1313
Copy link
Member

Related to (but not duplicate of): #38241

@lonix1 lonix1 closed this as completed Feb 22, 2021
@lonix1 lonix1 changed the title csharp_space_around_declaration_statements without declarations Allow vertical alignment without triggering IDE0055 Feb 22, 2021
@lonix1 lonix1 reopened this Feb 22, 2021
@jinujoseph jinujoseph added Feature Request IDE-Formatter Code formatter and/or smart indent and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 24, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Feb 24, 2021
@levicki
Copy link

levicki commented Oct 18, 2021

Please consider this for C++ as well.

@CyrusNajmabadi
Copy link
Member

@levicki Roslyn is unrelated to the c++ vs experience. Please file requests for that experience over at developercommunity. Thanks!

@levicki
Copy link

levicki commented Oct 18, 2021

Like anyone is going to read that. It would be just another "closed due to inactivity" thread.

@CyrusNajmabadi
Copy link
Member

Like anyone is going to read that. It would be just another "closed due to inactivity" thread.

@levicki This is not the c++ repro. No one on C++ is present here, and no one here works on the C++ components. If you would like teh C++ to investigate and/or triage issues relates to their experience, then issues will need to be filed against them. Thanks!

@levicki

This comment has been minimized.

@CyrusNajmabadi
Copy link
Member

@levicki I'm not sure why sarcasm is appropriate. C++/cli has nothing to do with Roslyn. You would report it to the c++ team.

@jibbers42
Copy link

jibbers42 commented Jun 6, 2022

It may be obvious to anyone working on this issue, but calling out this alternate switch expression spacing to be considered as well...

static int Foo(int x, int y) => (x, y) switch {
  (0, 0)         => 0,
  (int i, 0)     => 11,
  (int i, int j) => i + j,
};

@JDA88
Copy link

JDA88 commented Nov 15, 2024

No idea why but the last version of Visual Studio 2022 (17.12.0) made it worse, I have hundread of IDE0055 warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature - IDE0055 Formatting Feature Request IDE-Formatter Code formatter and/or smart indent
Projects
None yet
Development

No branches or pull requests

7 participants