-
Notifications
You must be signed in to change notification settings - Fork 199
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
Adding a setting to .editorconfig to enforce formatting #11236
Conversation
where !keyValuePair.Key.TranslateTo(visibleSpan.Snapshot, SpanTrackingMode.EdgeExclusive).IntersectsWith(visibleSpan) | ||
select keyValuePair.Key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this end up looking like if we format it? I can't see anything obviously weird here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks like a formatting bug...
what if we change it to
var toRemove =
from keyValuePari
in _adornmentCache
where ....
select ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the docs at https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/from-clause, recommendation seems to be to have in
on the same line as from
, after which formatting basically makes sense (though formatting in the first two examples in the same docs is still getting "corrected" by C# formatter). I made the change to make the formatter happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, yep, that's what it is. I didn't see it, but I always have put in
on the same line as from
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, yep, that's what it is. I didn't see it, but I always have put
in
on the same line asfrom
.
FWIW, that's pretty uncommon. Every single LINQ sample ever produced by Microsoft had from
and in
on the same line because that's how we expected query expressions to be formatted. I've personally never seen in
on a separate line until now. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, that's pretty uncommon
I think you misread what I wrote :) We're in vehement agreement about from
and in
being on the same line :)
I've personally never seen in on a separate line until now
Me neither, that's why I missed it when I wrote "I can't see anything obviously weird here" above.
@@ -8,9 +8,11 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting; | |||
[Flags] | |||
internal enum FormattingFlags | |||
{ | |||
#pragma warning disable format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason? What does it want to format to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'm totally fine with this not being lined up perfectly. I really don't like suppressions, they're uglier than jagged formatting :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair point. I removed suppressions and extra spaces. I think all suppressions are gone now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, if we want this setting in .editorconfig
, we should agree to never suppress it.
where !keyValuePair.Key.TranslateTo(visibleSpan.Snapshot, SpanTrackingMode.EdgeExclusive).IntersectsWith(visibleSpan) | ||
select keyValuePair.Key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks like a formatting bug...
what if we change it to
var toRemove =
from keyValuePari
in _adornmentCache
where ....
select ...
Summary of the changes
Fixes: https://github.com/orgs/dotnet/projects/197?pane=issue&itemId=88054220