{"id":226071,"date":"2019-08-08T10:43:21","date_gmt":"2019-08-08T17:43:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=226071"},"modified":"2019-08-08T10:43:21","modified_gmt":"2019-08-08T17:43:21","slug":"async-loaded-net-projects-may-impact-visual-studio-extensions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/async-loaded-net-projects-may-impact-visual-studio-extensions\/","title":{"rendered":"Async loaded .NET projects may impact Visual Studio extensions"},"content":{"rendered":"<p>In Visual Studio 2019 version 16.3, the CSProj project system (C#\/VB non-SDK style) introduces a new way of loading called Partial Load Mode (PLM). After the solution loads, the project system is doing design time builds in the background, leaving the UI responsive and interactive. However, for the time it takes to run the design time build, certain features may not be working as they used to. Extenders, read on.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-226072\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-IntelliSense.png\" alt=\"\" width=\"584\" height=\"124\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-IntelliSense.png 584w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-IntelliSense-300x64.png 300w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><\/p>\n<p>Today, CSProj projects block the UI thread and wait for design time build and Roslyn initialization before firing the project load event. To further reduce solution load time, CSProj will now fire the project load event immediately after evaluation, since that is early enough to display the project tree in Solution Explorer and provide project and source code files to Roslyn.<\/p>\n<p>Design time builds will happen on a background thread. This means that IntelliSense, code navigation, and designers will be in the Partial Load Mode after solution load and until the design time build results are ready.\u00a0Most users will not even notice this happening beyond faster loading solutions.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-226073\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-progress.png\" alt=\"\" width=\"497\" height=\"258\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-progress.png 497w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/08\/PLM-progress-300x156.png 300w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/p>\n<p>This will match the current behavior of .NET SDK-style projects that has had this capability since Visual Studio 2017. Now the experience is consistent between CSProj and SDK-style projects.<\/p>\n<h2>Breaking change<\/h2>\n<p>Calls to Roslyn APIs, such as <em>Workspace.CurrentSolution<\/em> or <em>ProjectItem.FileCodeModel<\/em>, may return an incomplete code model in PLM because project references are not yet known to Roslyn. You may have to update your extension if it\u2019s calling on the Roslyn API shortly after solution load.<\/p>\n<p>Here\u2019s how:<\/p>\n<pre><code>var operationProgressStatusService = await this.GetServiceAsync(typeof(SVsOperationProgressStatusService)) as IVsOperationProgressStatusService;\r\nvar stageStatus = operationProgressStatusService.GetStageStatus(CommonOperationProgressStageIds.Intellisense);\r\n\r\nawait stageStatus.WaitForCompletionAsync();<\/code><\/pre>\n<p>Learn more in the <a href=\"https:\/\/github.com\/microsoft\/VSSDK-Extensibility-Samples\/tree\/master\/OperationProgress\">OperationProgress sample<\/a>.<\/p>\n<p>Editor owners should make an explicit decision regarding delaying the initialization of documents when IntelliSense is in progress.<\/p>\n<p>To opt-out of deferring document creation, set the following in the .pkgdef file:<\/p>\n<pre><code>[$RootKey$\\Editors\\&lt;Editor-type-Guid&gt;]\r\n\"DeferUntilIntellisenseIsReady\"=dword:00000000<\/code><\/pre>\n<p>To opt into deferring document creation (this is the current default behavior to avoid breaking compatibility with extensions depending on Roslyn data), set the following in the .pkgdef file:<\/p>\n<pre><code>[$RootKey$\\Editors\\&lt;Editor-type-Guid&gt;]\r\n\"DeferUntilIntellisenseIsReady\"=dword:00000001<\/code><\/pre>\n<h2>Test your extension<\/h2>\n<p>This change brings a feature currently used by SDK-style projects to the CSProj based ones. As such, it is unlikely going to cause issues for most extensions unless they have different code paths for each of the two project systems. We therefore regard this as low impact for the extension ecosystem, but it could have a big impact on an individual extension.<\/p>\n<p>To find out if this change affected your extensions, download Visual Studio 2019 v16.3 Preview 1 today.<\/p>\n<p>Then drop a .json file containing the below code into <strong>%LocalAppData%\\Microsoft\\VisualStudio\\RemoteSettings\\LocalTest\\PersistentActions<\/strong><\/p>\n<pre><code>{\r\n  \"ActionPath\": \"vs\\\\core\\\\remotesettings\",\r\n  \"ActionJson\": {\r\n    \"FeatureFlags\": {\r\n      \"CPS.UseOperationProgress\": 0,\r\n      \"CSProj.PartialLoadMode\": 1,\r\n      \"Designer.PartialLoadMode\": 1,\r\n      \"Completion.PartialLoadMode\": 1,\r\n      \"Roslyn.PartialLoadMode\": 1\r\n      }\r\n  },\r\n\r\n  \"TriggerJson\": null,\r\n  \"MaxWaitTimeSpan\": \"14.00:00:00\",\r\n  \"Categories\": [\r\n  ]\r\n}<\/code><\/pre>\n<p>Then restart Visual Studio twice. Yes, twice. This will enable PLM for CSProj based projects.<\/p>\n<p>To revert the feature flags change \u2013 delete the .json file and restart Visual Studio twice. Disabling PLM is only an option in the initial preview of Visual Studio 2019 v16.3. The option will be removed in a future update.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Visual Studio 2019 version 16.3, the CSProj project system (C#\/VB non-SDK style) introduces a new way of loading called Partial Load Mode (PLM). After the solution loads, the project system is doing design time builds in the background, leaving the UI responsive and interactive. Extensions may need to adjust for this behavior change.<\/p>\n","protected":false},"author":642,"featured_media":226073,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1388,155],"tags":[294,12],"class_list":["post-226071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extensibility","category-visual-studio","tag-extensions","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>In Visual Studio 2019 version 16.3, the CSProj project system (C#\/VB non-SDK style) introduces a new way of loading called Partial Load Mode (PLM). After the solution loads, the project system is doing design time builds in the background, leaving the UI responsive and interactive. Extensions may need to adjust for this behavior change.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/226071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/642"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=226071"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/226071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/226073"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=226071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=226071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=226071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}