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

Add ISourceText to language service and use Roslyn's SourceText for FSharp.Editor #6001

Merged
merged 34 commits into from
Dec 18, 2018

Conversation

TIHan
Copy link
Contributor

@TIHan TIHan commented Dec 11, 2018

We were doing .ToString() on Roslyn's SourceText type in FSharp.Editor. This is very bad as we are making full copies of the source text and for larges files making large allocations on the LOH. To solve this, we added an ISourceText interface that looks similar to Roslyn's SourceText type. It is then implemented in FSharp.Editor with Roslyn's SourceText as the implementation detail.

This also eradicates adding a new line at the end of every source file in FCS.

This should resolve these issues:
#5935
#5936
#5937

src/fsharp/UnicodeLexing.fs Outdated Show resolved Hide resolved
src/utils/prim-lexing.fs Outdated Show resolved Hide resolved
src/fsharp/service/service.fsi Outdated Show resolved Hide resolved
src/fsharp/service/service.fsi Outdated Show resolved Hide resolved
src/fsharp/service/service.fs Outdated Show resolved Hide resolved
src/fsharp/UnicodeLexing.fs Outdated Show resolved Hide resolved
src/utils/prim-lexing.fs Outdated Show resolved Hide resolved
Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

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

Looking great!

src/fsharp/UnicodeLexing.fs Outdated Show resolved Hide resolved
src/fsharp/UnicodeLexing.fsi Show resolved Hide resolved
src/fsharp/service/ServiceXmlDocParser.fs Outdated Show resolved Hide resolved
src/fsharp/service/service.fsi Outdated Show resolved Hide resolved
src/fsharp/service/service.fs Outdated Show resolved Hide resolved
vsintegration/src/FSharp.Editor/Common/Extensions.fs Outdated Show resolved Hide resolved
@dsyme
Copy link
Contributor

dsyme commented Dec 12, 2018

(@TIHan just found a couple of review comments I hadn't submitted)

@TIHan
Copy link
Contributor Author

TIHan commented Dec 12, 2018

getXmlDocablesImpl requires that we have all lines as text strings from source text. After looking at it, I think it is possible that we do not have to.

@TIHan
Copy link
Contributor Author

TIHan commented Dec 13, 2018

We are getting closer. I am a little worried that we have two different implementations of ISourceText, a Roslyn one and one that handles just a string. Perhaps I need to write some tests against both implementations to verify correct behavior.

@cartermp cartermp changed the title Added ISourceText - Implemented using Roslyn's SourceText in FSharp.Editor Add ISourceText to language service and use Roslyn's SourceText for FSharp.Editor Dec 17, 2018
@cartermp
Copy link
Contributor

Awesome!

@TIHan
Copy link
Contributor Author

TIHan commented Dec 18, 2018

I'm ready to merge this. Any objections?

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

:shipit: 🚢 🇮🇹

@auduchinok
Copy link
Member

This PR doesn't seem to have been merged to master. I wonder if there any others too.

@cartermp
Copy link
Contributor

Lots. It will be in master once dev16 ships and we merge into master.

@auduchinok
Copy link
Member

I think it's bad for OSS FCS development in this repo.
We now have diverged code for FCS and VS integration solutions and FCS clients cannot update their code until dev16.0 is merged back to master.

@baronfel
Copy link
Member

@auduchinok for FCS we could integrate to the FCS from from a branch other than master, I just chose master because it seemed convenient. If we want features faster we could just as easily pick a non-master branch. 🤷‍♂️

@dsyme
Copy link
Contributor

dsyme commented Mar 21, 2019

I think it's bad for OSS FCS development in this repo. We now have diverged code for FCS and VS integration solutions and FCS clients cannot update their code until dev16.0 is merged back to master.

I think it might be ok. What's the divergence between FCS master and visualfsharp master?

@dsyme
Copy link
Contributor

dsyme commented Mar 21, 2019

The fact there are pending unshipped changes in dev16.0 is a slight divergence but it is on a path back to convergence when dev16.0 ships. That's normal?

@auduchinok
Copy link
Member

auduchinok commented Mar 21, 2019

What's the divergence between FCS master and visualfsharp master?

My point is about not having some PRs merged to master, assuming one builds FCS from source in this repo. Due to all the development is currently happening here I doubt there's a reason to build it from the other repo unless all the FCS development and stuff is moved there as well.

@auduchinok
Copy link
Member

auduchinok commented Mar 21, 2019

@auduchinok for FCS we could integrate to the FCS from from a branch other than master, I just chose master because it seemed convenient. If we want features faster we could just as easily pick a non-master branch. 🤷‍♂️

And other branches may not contain some of PRs merged that are already in master in the same way. I'd expect master to have all changes that FCS clients will have to deal with.
Taking a branch that is tied to some future VS release doesn't feel right for FCS development that is not a part of VS integration plugin.

@auduchinok
Copy link
Member

auduchinok commented Mar 21, 2019

The fact there are pending unshipped changes in dev16.0 is a slight divergence but it is on a path back to convergence when dev16.0 ships.

From a glance there're PRs that are really important like #6191 and this one or are general improvements that'd be great to see in action like #6048 and #6058.

That's normal?

It'd probably be better to try to have it diverged for less time, e.g. until the first public VS preview is released and not the actual release. Other tools have to be updated for changes like this PR as well and it's better to have the changes in previews.
And changes like #6191 don't depend on VS-specific changes at all so they would seem better going to master first.

@dsyme
Copy link
Contributor

dsyme commented Mar 21, 2019

@auduchinok Yes, things should really go into master unless they specifically need to go into dev16.0

However we have to cut some slack here: @TIHan and others at Microsoft are doing us a great favor by always sitting on the latest VS preview and checking that things are good and performant there.

If you're doing regular work there it's kind of hard to switch back and do serious dev work on VS2017 (which is master). So it's better to just live with a bit of divergence and reconcile later.

@dsyme
Copy link
Contributor

dsyme commented Mar 21, 2019

The most important thing is that the automatic flows are set up to integrate and flow correctly, which they are.

@auduchinok
Copy link
Member

auduchinok commented Mar 28, 2019

I'm building Fantomas against FCS built from dev16.1 and getting the following errors. They're expected for me and, despite they are easy to fix by either using SourceText.ofString or changing Fantomas API, it can be quite unexpected for other FCS clients to have to change their public APIs this way now.
I wonder if preserving existing APIs (with an obsolete attribute and maybe a future removal notice?) and adding new overloads could be a better approach?

Screenshot 2019-03-28 at 10 23 07

@TIHan TIHan mentioned this pull request Aug 16, 2021
10 tasks
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
…Sharp.Editor (dotnet#6001)

* Initial ISourceText implementation (does not work yet)

* Lexbuffer works

* Removing Source. Now using only ISourceText. Added SourceText.ofString.

* Fixing tests

* We need to use addNewLine for tests to pass

* Added test for SourceText.ofString

* Trying to fix tests

* Simplified ISourceText API. Added RoslynSourceTextTests

* Trying to get the build working again

* Re-organize prim-lexing.fsi

* Handling format strings

* Trying to get tests to pass

* Trying to fix tests

* Ignoring test

* unignoring test

* Fixed weak table

* Removing addNewLine in sourcetext

* Fixing interactive checker tests

* Fixing more tests

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removed addNewLine

* Removing last addNewLine. It's done

* Better tests and small optimizations

* Adjusting comment

* Updating CompilerServiceBenchmarks

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

Successfully merging this pull request may close these issues.

7 participants