{"id":17415,"date":"2018-05-08T11:22:06","date_gmt":"2018-05-08T18:22:06","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/?p=17415"},"modified":"2019-03-31T08:59:08","modified_gmt":"2019-03-31T15:59:08","slug":"f-language-and-tools-update-for-visual-studio-2017-version-15-7","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/f-language-and-tools-update-for-visual-studio-2017-version-15-7\/","title":{"rendered":"F# language and tools update for Visual Studio 2017 version 15.7"},"content":{"rendered":"<p>We\u2019re excited to share updates about <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/releasenotes\/vs2017-relnotes#fsharp\">changes to F# and F# tools which shipped with the Visual Studio 2017 version 15.7 release<\/a>. Let\u2019s dive in!<\/p>\n<h3>Type Providers now support .NET Standard<\/h3>\n<p>For those who aren\u2019t familiar with <a href=\"https:\/\/docs.microsoft.com\/dotnet\/fsharp\/tutorials\/type-providers\/\">Type Providers<\/a>, they are a feature of F# which allow you to get IntelliSense for data. When pointed at a data source, a Type Provider can produce an object model for that data. This object model is read by the F# compiler, which can then be used to power IntelliSense.<\/p>\n<p>Type Providers can now be .NET Standard components. What this means is that you can use Type Providers in .NET Core apps, .NET Standard libraries, and .NET Framework apps without depending on specific packages for each target!<\/p>\n<p>One example Type provider targeting .NET Standard is the HtmlProvider from <a href=\"https:\/\/www.nuget.org\/packages\/FSharp.Data\">FSharp.Data<\/a>. Getting started is very easy in Visual Studio:<\/p>\n<ol>\n<li>File | New Project<\/li>\n<li>Select .NET Core application (or .NET Standard Class Library)<\/li>\n<li>Add a NuGet package reference to FSharp.Data 3.0.0-beta (if you use the NuGet UI, check \u201cIncude Prerelease\u201d)<\/li>\n<\/ol>\n<p>Type Providers are extremely useful for data access, data exploration, and more. For example, here is how you can easily find information about the filmography of Donald Duck. The code sample is very simple:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/cartermp\/4a2a24de2d2711572d7f9cf59d47e9f4.js\"><\/script><\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.11.40.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-17585\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.11.40-1024x466-1.png\" alt=\"\" width=\"879\" height=\"400\" \/><\/a><\/p>\n<p>Note that IntelliSense names have been generated based on the actual HTML data being read! When run, the application prints out all of the data selected:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-17435\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run.1.png\" alt=\"\" width=\"974\" height=\"304\" \/><img decoding=\"async\" class=\"alignnone size-full wp-image-22172\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run-1.png\" alt=\"\" width=\"974\" height=\"304\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run-1.png 974w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run-1-300x94.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/dd-run-1-768x240.png 768w\" sizes=\"(max-width: 974px) 100vw, 974px\" \/><\/a><\/p>\n<p>Although the above screenshots show Windows and Visual Studio, you can use Type Providers on any OS where .NET Core runs, and with any editor tooling you like.<\/p>\n<p>We are very excited about this and look forward to the coming months when all of the Type Providers in the F# ecosystem upgrade to support .NET Standard.<\/p>\n<h3>ASP.NET Core, Docker, and Azure tooling support<\/h3>\n<p>Starting with version 15.7 of Visual Studio 2017, F# officially supports creating ASP.NET Core projects via the same UI that C# supports. Additionally, all tooling for Docker, CI\/CD with Visual Studio Team Services, and publishing to Azure App Service is supported.<\/p>\n<p>When you use <strong>File | New Project<\/strong> to create a new F# project, you\u2019ll notice a new tab called <strong>Web<\/strong> under <strong>Visual F#<\/strong>. The template there is also present under .NET Core:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/new-proj.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-22176\" src=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/new-proj.png\" alt=\"\" width=\"974\" height=\"468\" \/><\/a><\/p>\n<p>When you create a project with this template, it will launch the ASP.NET dialog with F# template options, including scaffolding Docker support:<\/p>\n<p>You can always add Docker support later with <strong>Right Click &gt; Add &gt; Docker Support<\/strong> on the project node in the UI.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/add-docker.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-22176\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/add-docker.png\" alt=\"\" width=\"974\" height=\"468\" \/><\/a><\/p>\n<p>This will work for all F# projects, not just ASP.NET ones:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/docker-compose.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-22177\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/docker-compose.png\" alt=\"\" width=\"566\" height=\"343\" \/><\/a><\/p>\n<p>Additionally, if you are inclined to use the Visual Studio UI to publish applications or set up CI\/CD with Visual Studio Team Services, you can do so with any F# project which uses the <strong>Microsoft.NET.Sdk.Web<\/strong> attribute.<\/p>\n<p>For example, you can add Docker support to an existing <a href=\"https:\/\/github.com\/giraffe-fsharp\/Giraffe\">Giraffe<\/a> project and use the UI to publish it to a container registry of your choosing.<\/p>\n<ol>\n<li>Right-click the project node and select <strong>Add &gt; Docker Support<\/strong>.<\/li>\n<li>Rick-click the project node and select <strong>Publish<\/strong>.<\/li>\n<li>Select the <strong>Container Registry<\/strong> tab.<\/li>\n<li>Select the registry you prefer (Azure Container Registry, Docker Hub, or Custom).<\/li>\n<li>Fill out the form data and publish to a container registry!<\/li>\n<\/ol>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50.png\"><img decoding=\"async\" class=\"alignnone size-large wp-image-17595\" src=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50.png\" alt=\"\" width=\"879\" height=\"504\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50.png 1106w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50-300x172.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50-768x440.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/Screen-Shot-2018-05-08-at-10.19.50-1024x587.png 1024w\" sizes=\"(max-width: 879px) 100vw, 879px\" \/><\/a><\/p>\n<p>We\u2019re very excited about this tooling support, especially because it makes it so much easier to get started with F# for server and cloud programming in Visual Studio.<\/p>\n<h3>Performance improvements<\/h3>\n<p>The 15.7 update for Visual Studio 2017 comes with significant performance and responsiveness improvements. This work involved major contributions from Microsoft Mobile Tools (who provide support for F# in Xamarin and <a href=\"https:\/\/docs.microsoft.com\/dotnet\/fsharp\/get-started\/get-started-with-visual-studio-for-mac\">Visual Studio for Mac<\/a>) and the F# community.<\/p>\n<h4>Reduction in data structure sizes<\/h4>\n<p>Visual Studio uses the F# Compiler Service, which is an API that exposes different layers of the F# compiler, including some of its data structures. What\u2019s interesting about this is that performance characteristics of these data structures and functions are different when compiling F# code versus using F# tooling.<\/p>\n<p>Many data structures used by the F# Compiler Service contained data that was rarely used and were kept in memory for a longer time than necessary. The data structures still exist (otherwise needless re-computations are done), but the size of the data structures has been reduced by splitting them up into \u201cnecessary\u201d and \u201coptional\u201d data.<\/p>\n<p>What this means is that in many situations, usage of the tools will consume less memory that before because the optional data in these data structures won\u2019t be filled. There can still be some situations where optional data is computed and stored in memory, but generally speaking, usage patterns in the F# tools will require less memory.<\/p>\n<p>This work was entirely a collaboration between Microsoft and the F# community after a series of discussions about the kinds of data structures which could be reduced in size. In particular, one of our long-time contributors, <a href=\"https:\/\/github.com\/aviavni\">Avi Avni<\/a>, contributed significant work. We\u2019re extremely grateful for his contributions and are excited to continue working with him.<\/p>\n<h4>Moving metadata into virtual memory<\/h4>\n<p>One of the largest contributors to memory usage for F# tooling has been in what is called a ByteFile, which is a data structure that holds data in memory when it is read from referenced assemblies. If you are working in a project with a significant amount of dll references (project to project references, NuGet package references, etc.), then this could significantly increase memory usage in previous Visual Studio releases. This increased memory usage could reach a threshold in large solutions where the F# compiler service entered a \u201cloop of doom\u201d: caches were flushed, then filled, then flushed, then filled . . . all while the GC churned endlessly, rendering Visual Studio unusable.<\/p>\n<p>Starting with the 15.7 update, we now store this data in virtual memory, backed by the <a href=\"http:\/\/source.roslyn.io\/#Microsoft.VisualStudio.LanguageServices\/Implementation\/ProjectSystem\/MetadataReferences\/VisualStudioMetadataReferenceManager.cs,dac4ccf13451b4c4\">Visual Studio Metadata Reference Manager<\/a> that C# and VB use. This significantly reduces memory usage over time for large F# projects in Visual Studio, or projects which read a lot of data from assembly references. As metadata is read into virtual memory and used, memory usage will increase. But rather than stay in memory indefinitely, the data will be written to the backing memory-mapped file and incur a significant reduction in memory usage after some time. When using the 15.7 release against the Visual F# compiler and tools codebase, we observe significant memory reductions and no longer experience a \u201cloop of doom\u201d. We hope that this can be true for the many large F# codebases out there as well.<\/p>\n<h4>Adding a priority to document diagnostic analyzers<\/h4>\n<p>With Visual Studio 2017, F# tools use a Roslyn mechanism to analyze documents when they change. There are multiple analyzers which run for F#, depending on what you have turned on:<\/p>\n<ul>\n<li>Unused open statement analysis<\/li>\n<li>Unused declaration analysis<\/li>\n<li>Name simplification analysis<\/li>\n<li>Error diagnostic analysis<\/li>\n<\/ul>\n<p>In past releases, these were run serially and in an arbitrary order. This means that unused open statement analysis may run before error diagnostics, thus forcing you to wait longer for an error to appear. We now assign a priority to each analyzer, with error diagnostics set at the highest priority. This means that error messages will appear consistently from a timing perspective. We have also made the unused opens analyzer significant faster than in previous releases.<\/p>\n<p>Additionally, the Unused open statement analyzer has been modified to cache results more efficiently.<\/p>\n<p>We\u2019re quite happy with this change, as it addresses an issue with editor responsiveness that people have been experiencing ever since the release of Visual Studio 2017.<\/p>\n<h3>Conclusion<\/h3>\n<p>Overall, the 15.7 release of Visual Studio 2017 represents one of the largest performance improvements to F# tooling in Visual Studio in a long time. We are very excited about this because it is the number one issue people have when they use F# for large solutions. We\u2019re looking forward to spending more time on tooling performance in the next year, and doing so not only for Visual Studio, but in the F# Compiler and F# Compiler Service so that all F# tooling in any editor can benefit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re excited to share updates about changes to F# and F# tools which shipped with the Visual Studio 2017 version 15.7 release. Let\u2019s dive in! Type Providers now support .NET Standard For those who aren\u2019t familiar with Type Providers, they are a feature of F# which allow you to get IntelliSense for data. When pointed [&hellip;]<\/p>\n","protected":false},"author":678,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,196,636,646],"tags":[],"class_list":["post-17415","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-dotnet-core","category-fsharp","category-visual-studio"],"acf":[],"blog_post_summary":"<p>We\u2019re excited to share updates about changes to F# and F# tools which shipped with the Visual Studio 2017 version 15.7 release. Let\u2019s dive in! Type Providers now support .NET Standard For those who aren\u2019t familiar with Type Providers, they are a feature of F# which allow you to get IntelliSense for data. When pointed [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/17415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/678"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=17415"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/17415\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=17415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=17415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=17415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}