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

Contained document refactoring #41283

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

tmat
Copy link
Member

@tmat tmat commented Jan 29, 2020

Fixes #28322

@tmat
Copy link
Member Author

tmat commented Jan 29, 2020

@jasonmalinowski @KirillOsenkov Still work in progress, but wanted to gather initial feedback to see if this is going the right direction.

@tmat tmat force-pushed the ContainedDocumentRefactoring branch 2 times, most recently from 072c8a5 to 16def78 Compare January 29, 2020 17:50
@KirillOsenkov
Copy link
Member

Our goal is for the bulk of this code to land in a non-VisualStudio layer and still work.

For reference here's the MonoDevelop copy of the code:
http://source.monodevelop.com/#MonoDevelop.CSharpBinding/MonoDevelop.Ide.Completion.Presentation/MonoDevelopContainedDocument.cs,fd8c80b4797cb921

I would love to kill it and move to the same shared implementation.

Adding @ToddGrun and @DavidKarlas FYI.

Also my advice: cover it with unit-tests. That logic is gnarly.

@tmat
Copy link
Member Author

tmat commented Jan 29, 2020

Also my advice: cover it with unit-tests. That logic is gnarly.

I'll add some unit tests. I found we had some that were commented out :-/ I do not have understanding what the expected behavior should be though, so it might be better if someone who knows added more tests afterwards.

@KirillOsenkov
Copy link
Member

I guess nobody knows this code so you own it now :) The way I'd approach it is put a breakpoint in that code, run a simple ASP.NET Core app, open a .cshtml file, hit Return.

This will trigger the breakpoint. Capture the inputs that go into here and the outputs and that should be enough to give a decent coverage.

@tmat
Copy link
Member Author

tmat commented Jan 31, 2020

@KirillOsenkov I think i'm gonna give up on adding the tests. I can't figure out how to set up the projection buffers :(.

@KirillOsenkov
Copy link
Member

No worries, but I thought there are quite a few methods that just deal with strings. Maybe at least try for those?

@KirillOsenkov
Copy link
Member

Also I was thinking maybe @ToddGrun or @NTaylorMullen would be interested to help? This is a worthy and important effort.

@NTaylorMullen
Copy link
Contributor

Also I was thinking maybe @ToddGrun or @NTaylorMullen would be interested to help? This is a worthy and important effort.

Definitely sounds worthy! If only I had the bandwidth 😢

@tmat tmat force-pushed the ContainedDocumentRefactoring branch from 16def78 to ad75e87 Compare January 31, 2020 01:40
@tmat tmat marked this pull request as ready for review January 31, 2020 22:16
@tmat tmat requested a review from a team as a code owner January 31, 2020 22:16
@tmat
Copy link
Member Author

tmat commented Jan 31, 2020

If anyone can describe what is the layering of projection buffers and their content types that the VS actually creates, I could use that info to set up the buffers in the tests.

@KirillOsenkov
Copy link
Member

LOL the best doc I have is this:

image

Feel free to stop by for an explanation. We can debug and I can show you the buffers, we can also capture the exact contents and span positions for testing.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Comments so far.

@tmat tmat force-pushed the ContainedDocumentRefactoring branch from f4e8d4f to 9241594 Compare February 6, 2020 03:08
@tmat tmat requested a review from a team as a code owner February 6, 2020 03:08
@tmat tmat force-pushed the ContainedDocumentRefactoring branch from 9241594 to 8925302 Compare February 6, 2020 03:34
@tmat
Copy link
Member Author

tmat commented Feb 6, 2020

Figured out the projection buffer setup.

Now I'm getting an InvalidOperationException from the editor for some line endings:

image

Also the contained buffer impl ends up adding line breaks that shouldn't be there (I think).
Not sure, what's going on... any ideas?

@KirillOsenkov
Copy link
Member

This is precisely why we needed to terraform this code and cover it with tests ;) Thanks for doing this.

Maybe if @NTaylorMullen is busy he can at least help with answering questions, or perhaps @ToddGrun. Or who could we ask?

Base automatically changed from master to main March 3, 2021 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor ContainedDocument.cs to extract reusable logic
5 participants