Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Conversation

@kzu
Copy link
Member

@kzu kzu commented Sep 23, 2018

No description provided.

kzu added 15 commits September 23, 2018 02:55
The reasons to go with an out of process console app are:
- We need to use the latest 2.9 Roslyn MSBuildWorkspace which properly
  supports decoupling with the MSBuild version and locating it via the
  MSBuildLocator
- We cannot bundle that Roslyn in a VS extension because it might conflict
  with the built-in version
- Resolving the Roslyn assemblies from within the MSBuild process proved
  very challenging: resolving to the VS-installed versions caused errors,
  would require maintaining a pre-2.9 version too, and ultimately never
  properly matched assemblies to the MSBuild resolved versions.

This reading uses Mono.Options to configure the parameters (a total joy
to use!) and by default will emit the XML with the project metadata needed
to load it programmatically to a workspace via the output stream, unless a
file is specified with -o.
The external process should be longer lived so that the MSBuildWorkspace.Create
call (by far the most expensive since it needs to set up a whole new MEF host
with all Roslyn services, in addition to resolving the MSBuild framework assemblies
and all SDK-style targets and assemblies too) can be reused across calls to
ReadProject (renamed to OpenProject).

By switching to the JsonRpc style, the external process can live as long as the
build (or the AppDomain?) and maintain a single instance of the MSBuildWorkspace,
which then is reused across OpenProject calls. The RPC interface exposed allows
creating new workspaces on demand (disposing the existing one automatically, so
that it can live for the entire duration of the VS AppDomain eventually.

In addition, the console app now triggers a background resolving of all the
relevant assemblies and MEF eagerly, so that by the time the actual project
reading happens, all of the Roslyn components have already warmed up.

This combination of optimizations brought down the time for reading the test
project and all its project references from 20+ seconds (with the single-use
commandline for each project) to ~5 seconds (not counting the warm-up period
of ~2 seconds).
Also, since build-time works great now, we don't need to generate
warnings for missing and outdated mocks. Those can be just Info,
and Warning only when AutoCodeFix is enabled.
The project reader moved over to the AutoCodeFix repository
This happens on CI for example, because the nuget cache may
not be populated.
@kzu kzu merged commit f3e2dac into master Sep 23, 2018
@kzu kzu deleted the buildtime branch September 23, 2018 06:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants