Skip to content

Use elastic crlf where applicable#25929

Merged
jinujoseph merged 5 commits intodotnet:masterfrom
Therzok:elastic-crlf
Jun 5, 2018
Merged

Use elastic crlf where applicable#25929
jinujoseph merged 5 commits intodotnet:masterfrom
Therzok:elastic-crlf

Conversation

@Therzok
Copy link
Copy Markdown
Contributor

@Therzok Therzok commented Apr 4, 2018

The changes switch End of Line trivia to use Elastic on code paths which end up being formatted by code actions or explicit elastic annotation formatting

Details ### Customer scenario

See repro in #25927

Bugs this fixes

#25927

Workarounds, if any

Reformat the piece of code

Risk

?

Performance impact

Only modified the crlf trivia in case of code going into code actions. That triggers elastic trivia formatting, even if the code itself is not marked to format via annotation.

Is this a regression from a previous update?

Root cause analysis

I'm not sure how to add tests for this.

How was the bug found?

Found via ad-hoc testing in vsmac.

@Therzok Therzok requested review from a team as code owners April 4, 2018 18:31
@Neme12
Copy link
Copy Markdown
Contributor

Neme12 commented Apr 4, 2018

Have you also checked references of SyntaxGenerator.CarriageReturnLineFeed?

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented Apr 4, 2018

Yes, it is not used.

cc @sharwell @CyrusNajmabadi

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

This needs @dotnet/roslyn-compiler review as we're touching the compiler layer. Also @mattwar for feedback. This will need tests of appropriate systems.

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented Apr 4, 2018

The first commit in the PR is the one that fixes the github bug I reported.

The others are code actions which are not marked with Formatter.Annotation so I judged that adding elastic eol would get them fixed as a catch all in:
http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/CodeActions/CodeAction.cs,275

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented Apr 4, 2018

I have removed the elastic crlf change in SyntaxNodeRemover. It was an oversight when adding changes to the commit, elastic markers are added post-fact.

@jcouv jcouv added Area-IDE Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. and removed Area-Compilers labels Apr 4, 2018
@jcouv
Copy link
Copy Markdown
Member

jcouv commented Apr 4, 2018

There no longer is any compiler change in this PR, so I removed Compiler tag. Thanks

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented Apr 4, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is different behaviour from C#. declarationStatement does not have this check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As in, this probably causes the eol changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, the EOL changes are welcome IMO. The whole point of elastic trivia formatting was precisely for these cases.

@jinujoseph jinujoseph added this to the 15.8 milestone Apr 15, 2018
@jasonmalinowski
Copy link
Copy Markdown
Member

@Therzok @DustinCampbell To confirm, we're not taking this in 15.7? If so, we'll need to change the PR target.

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented May 16, 2018

Sure. I'll retarget

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented May 21, 2018

Which branch should I target this PR to?

@Therzok Therzok changed the base branch from dev15.7.x to master May 21, 2018 20:59
@Therzok Therzok requested a review from a team as a code owner May 21, 2018 20:59
Copy link
Copy Markdown
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

The change looks good to me. However, the integration tests need to be looked at. I expect many of them are failing because fixes/refactorings are now inserting line breaks where they didn't before.

Copy link
Copy Markdown
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

The change looks good to me. However, the integration tests need to be looked at. I expect many of them are failing because fixes/refactorings are now inserting line breaks where they didn't before.

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented May 22, 2018

Yeah, I rebased in order to get a new build. I had fixed the previous ones before having to retarget. I'll fix asap

@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented May 22, 2018

Aren't the test failures related to #27048 ?

@etbyrd
Copy link
Copy Markdown
Contributor

etbyrd commented May 22, 2018

Yes, I can confirm that the tests are failing because of the ongoing issue in #27048

@etbyrd
Copy link
Copy Markdown
Contributor

etbyrd commented May 24, 2018

Ping - the new tests have completed.

However, I have identified that

  • Roslyn.VisualStudio.IntegrationTests.CSharp.CSharpReplIdeFeatures.AddUsing
  • Roslyn.VisualStudio.IntegrationTests.CSharp.CSharpReplIdeFeatures.QualifyName

Are failing across multiple PR's are probably flaky/broken

@etbyrd etbyrd removed the Community The pull request was submitted by a contributor who is not a Microsoft employee. label May 26, 2018
@Therzok
Copy link
Copy Markdown
Contributor Author

Therzok commented May 30, 2018

@DustinCampbell anything else needed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, the EOL changes are welcome IMO. The whole point of elastic trivia formatting was precisely for these cases.

@jinujoseph
Copy link
Copy Markdown
Contributor

Approved to merge for 15.8.Preview3

@jinujoseph jinujoseph merged commit 5bef566 into dotnet:master Jun 5, 2018
@Therzok Therzok deleted the elastic-crlf branch June 5, 2018 15:55
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.

8 participants