{"id":243,"date":"2014-04-03T16:00:00","date_gmt":"2014-04-04T00:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2014\/04\/03\/taking-a-tour-of-roslyn\/"},"modified":"2024-07-05T12:38:24","modified_gmt":"2024-07-05T19:38:24","slug":"taking-a-tour-of-roslyn","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/taking-a-tour-of-roslyn\/","title":{"rendered":"Taking a tour of Roslyn"},"content":{"rendered":"<p>It\u2019s a big day for us on the Managed Languages team! As announced at the \/\/BUILD conference earlier today, and <a href=\"http:\/\/blogs.msdn.com\/b\/somasegar\/\">as posted by Soma on his blog<\/a>, we are not just delivering a new preview of Roslyn to all of you, but are in fact moving all of the compiler code to <a href=\"http:\/\/roslyn.codeplex.com\">open source<\/a>! The code will be released and maintained by <a href=\"http:\/\/msopentech.com\">MS Open Tech<\/a>, who are our partners in this endeavor. <\/p>\n<p>The goal of open-sourcing the compilers is something that we\u2019ve been working towards for just over a year, and we\u2019re really excited that it\u2019s finally time to make the \u201cbig reveal.\u201d (Best of all, we no longer have to try to keep a poker face every time we\u2019re asked about whether or not the compilers will ever be open sourced!) And as this momentous day drew closer, I found myself struggling a bit to write a blog post which could capture the enormity of this moment on behalf of our team. Although Microsoft has actively embraced openness as a part of day-to-day operations for quite some time now, it\u2019s nevertheless very difficult to put into words how exciting <i>this<\/i> particular change is for us, given how it takes our participation in the world of open source to an entirely new level. <\/p>\n<p>In a vain effort to capture all of that emotion, I inflicted (which is really the only word for it) several drafts on my team and my management, none of which really added anything to the basic facts already planned to be revealed in Soma\u2019s blog. Finally, Jay Schmelzer (our PM director) took me aside and wisely said, \u201cLook, we\u2019ve got your back on the \u2018big reveal;\u2019 don\u2019t worry about that. Why don\u2019t you take everyone the rest of the way and show us how it actually <i>works<\/i>?\u201d<\/p>\n<p>Of course, he was exactly right, and so, here we go\u2026<\/p>\n<h2>Installing the preview<\/h2>\n<p>Before jumping into the open source code, you should first install the Roslyn preview. To do this, follow these steps:<\/p>\n<p>(1) Browse to the <a href=\"https:\/\/aka.ms\/roslyn\">preview site<\/a>. You\u2019ll be asked to sign in with a Microsoft account (and will have the opportunity to create a free one if you don\u2019t have one already).<\/p>\n<p>(2) Once you are signed in, you\u2019ll be taken to a survey page, where you will just need to fill in your name, preferred e-mail address, and country \u2013 this is just so we can stay in touch with folks installing the preview in order to get feedback from them and send new information to them.<\/p>\n<p>(3) After filling out the survey, your Microsoft account will be given permission to access the preview. A \u201cThank you\u201d page will appear; click the <b>Go to .NET Compiler Platform (\u201cRoslyn\u201d)<\/b> link that appears on it, as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2553.clip_image001_thumb_48EF3C6C.png\"><img decoding=\"async\" title=\"clip_image001\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image001\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2553.clip_image001_thumb_48EF3C6C.png\" width=\"457\" height=\"83\"><\/a><\/p>\n<p>(4) The .NET Compiler Platforms (\u201cRoslyn\u201d) main page will be presented to you with a couple of options, as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2475.clip_image002_thumb_41CFFFF4.png\"><img decoding=\"async\" title=\"clip_image002\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2475.clip_image002_thumb_41CFFFF4.png\" width=\"467\" height=\"58\"><\/a><\/p>\n<p>Click the \u201cDownload\u201d button. This will take you to a standard Connect download details page that describes the download and shows the options for obtaining it. Click the Download button on that page to actually download the preview.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/8322.clip_image003_thumb_21B4F337.png\"><img decoding=\"async\" title=\"clip_image003\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image003\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/8322.clip_image003_thumb_21B4F337.png\" width=\"317\" height=\"47\"><\/a><\/p>\n<p>(5) Once downloaded, now you can install it! The team has worked hard to make the installation as absolutely quick and painless as possible. After downloading &amp; running it, you\u2019ll be presented with the following dialog:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2068.clip_image004_thumb_5D748BEA.png\"><img decoding=\"async\" title=\"clip_image004\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2068.clip_image004_thumb_5D748BEA.png\" width=\"373\" height=\"281\"><\/a><\/p>\n<p>Clicking \u201cInstall\u201d will cause the older compiler &amp; IDE pieces in Visual Studio to be turned off and the Roslyn versions to be installed and turned on in their place. This takes mere seconds to complete. (The old pieces are not deleted, so if you choose to uninstall the VSIX, you\u2019ll safely revert back to using them.)<\/p>\n<p>(6) Once the installation is finished, you\u2019ll need to restart your instance of Visual Studio (assuming it was open during the installation).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/3630.clip_image005_thumb_2867FCBA.png\"><img decoding=\"async\" title=\"clip_image005\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image005\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/3630.clip_image005_thumb_2867FCBA.png\" width=\"347\" height=\"261\"><\/a><\/p>\n<p>After installing &amp; relaunching Visual Studio, you should now be able to see Roslyn-specific improvements. For example, consider the following reasonably-common code in C#:<\/p>\n<p><pre class=\"code\"><span style=\"background: white;color: black\">        <\/span><span style=\"background: white;color: blue\">static void <\/span><span style=\"background: white;color: black\">Main(<\/span><span style=\"background: white;color: blue\">string<\/span><span style=\"background: white;color: black\">[] args)\r\n        {\r\n            <\/span><span style=\"background: white;color: blue\">int <\/span><span style=\"background: white;color: black\">n1;\r\n            <\/span><span style=\"background: white;color: blue\">if <\/span><span style=\"background: white;color: black\">(<\/span><span style=\"background: white;color: blue\">int<\/span><span style=\"background: white;color: black\">.TryParse(args[0], <\/span><span style=\"background: white;color: blue\">out <\/span><span style=\"background: white;color: black\">n1))\r\n            {\r\n                <\/span><span style=\"background: white;color: #2b91af\">Console<\/span><span style=\"background: white;color: black\">.WriteLine(n1);\r\n            }\r\n        }<\/span><\/pre>\n<p>Using one of the new language features in Roslyn (inline declaration expressions), you can now simplify this to:<\/p>\n<pre class=\"code\"><span style=\"background: white;color: black\">        <\/span><span style=\"background: white;color: blue\">static void <\/span><span style=\"background: white;color: black\">Main(<\/span><span style=\"background: white;color: blue\">string<\/span><span style=\"background: white;color: black\">[] args)\r\n        {\r\n            <\/span><span style=\"background: white;color: blue\">if <\/span><span style=\"background: white;color: black\">(<\/span><span style=\"background: white;color: blue\">int<\/span><span style=\"background: white;color: black\">.TryParse(args[0], <\/span><span style=\"background: white;color: blue\">out var <\/span><span style=\"background: white;color: black\">n1))\r\n            {\r\n                <\/span><span style=\"background: white;color: #2b91af\">Console<\/span><span style=\"background: white;color: black\">.WriteLine(n1);\r\n            }\r\n        }\r\n    }<\/span><\/pre>\n<p>An example for VB which demonstrates a new feature would be:<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"background: white;color: black\">    <\/span><span style=\"background: white;color: blue\">Sub <\/span><span style=\"background: white;color: black\">Main()\r\n        <\/span><span style=\"background: white;color: blue\">Dim <\/span><span style=\"background: white;color: black\">s <\/span><span style=\"background: white;color: blue\">As String <\/span><span style=\"background: white;color: black\">= <\/span><span style=\"background: white;color: #a31515\">\"This is a multiline\r\n            string literal.\"\r\n    <\/span><span style=\"background: white;color: blue\">End Sub<\/span><\/pre>\n<\/blockquote>\n<p>which was impossible using the old VB compiler.<\/p>\n<p>Your older projects should build fine against the new compilers (obviously, speak up if they don\u2019t!), though you should be aware that any changes you make to them which use the new language features won\u2019t work if you uninstall the preview.<\/p>\n<p>Beyond examples of how the language is evolving, the Roslyn preview also showcases many examples of how we are using the new Roslyn compilers to provide stronger IDE functionality. One of my personal favorites is inline renaming: select any symbol or method name, right-click and choose <b>Rename<\/b> (or just press F2), and start typing a new name right in the program file. Your name changes will be reflected instantly throughout all uses of that name in your solution, all at once, without affecting any other symbols\/methods that coincidentally have the same name but in a different context.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/4628.clip_image006_thumb_7D2365B2.png\"><img decoding=\"async\" title=\"clip_image006\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/4628.clip_image006_thumb_7D2365B2.png\" width=\"824\" height=\"246\"><\/a><\/p>\n<p>In this case, there is no guessing about which names refer to the same symbol; that information is known and exposed, without having to resort to string comparisons bolted on top of the text buffer (as used to be the case), all thanks to the new compilers.<\/p>\n<p>Here\u2019s the fine print: please be aware the set of features that end up in the final version is subject to change before an official version is released \u2013 features can and will be added, removed, or modified in the interim, often due to getting feedback from <i>you<\/i> as to what works and what needs to be improved (see the end of this post for details on how to give feedback). Similarly, the language features showcased in the preview are not locked down, and should be viewed as examples of things that are being considered for the final version. Finally, you may sometimes notice that one language might showcase an IDE or language feature in the preview while the other language doesn\u2019t. You shouldn\u2019t worry about that; although it might be because a given feature simply doesn\u2019t make sense for the other language, it\u2019s far more likely that the developers just haven\u2019t gotten around to it yet, as such things are generally implemented serially from one language to the other. (FWIW, I\u2019m already planning to go into more detail as to how features are vetted and scheduled in a future blog post, in case anyone is curious about that.)<\/p>\n<h2>Enlisting in the open source project<\/h2>\n<p>Now, if you\u2019d like to take it a step further, you can enlist in the open source project to view and experiment with the code yourself. Here are a couple of important points:<\/p>\n<ul>\n<li>NuGet is used for packaging, and it\u2019s important to use using version 2.8.1 (or later) of it. If you don\u2019t have that extension (or that version) installed on Visual Studio yet, you can add it by selecting <b>Tools<\/b><b>\u2192Extensions and Updates<\/b>, and then in the <b>Online<\/b> section, select and install \u201cNuGet Package Manager for Visual Studio 2013.\u201d You can also install it from <a href=\"http:\/\/visualstudiogallery.msdn.microsoft.com\/27077b70-9dad-4c64-adcf-c7cf6bc9970c\">here<\/a>, and that\u2019s a great site to visit if you encounter any problems with NuGet.\n<li>Also, you\u2019ll also need the Visual Studio 2013 SDK in order to open the projects \u2013 you can download that from <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=40758\">here<\/a>. <\/li>\n<\/ul>\n<p>Once you\u2019ve got those set up, open Team Explorer in Visual Studio (<b>View<\/b><b>\u2192Team Explorer<\/b>). At top of that window, you\u2019ll see a dropdown labeled \u201cHome\u201d listing whatever your current workspace is.&nbsp; (Mine happens to be our internal Roslyn TFS project, as shown below, but your default workspace will be different or possibly even \u201coffline\u201d \u2013 the important thing to note and use is the dropdown arrow to the far right of what I\u2019ve circled in the image.)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2806.clip_image007_thumb_5891D82E.png\"><img decoding=\"async\" title=\"clip_image007\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image007\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2806.clip_image007_thumb_5891D82E.png\" width=\"405\" height=\"158\"><\/a><\/p>\n<ul>\n<li>In the dropdown menu, select <b>Projects and My Teams<\/b><b>\u2192Connect to Team Projects<\/b>.\n<li>At the bottom of the resulting view, you\u2019ll see a section labeled \u201cLocal Git Repositories.\u201d Drop-down the Clone list. You\u2019ll see a dialog similar to this:<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/6281.clip_image008_thumb_51729BB6.png\"><img decoding=\"async\" title=\"clip_image008\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image008\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/6281.clip_image008_thumb_51729BB6.png\" width=\"411\" height=\"326\"><\/a><\/p>\n<ul>\n<li>In the first field, type in <b>http:\/\/git01.codeplex.com\/roslyn<\/b> (as shown in the picture), and in the second field, specify the location on your local machine where you\u2019d like to store the code.\n<li>Press \u201cClone.\u201d<\/li>\n<\/ul>\n<p>You can now open the solution and build it exactly like any other solution. Furthermore, Visual Studio supports the typical Git commands, so that you can (for example) use the <b>Unsynced Commits<\/b> pane in Team Explorer keep your enlistment up-to-date with any changes that have gone in by using <b>Pull<\/b>, as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/6204.clip_image009_thumb_0D32346A.png\"><img decoding=\"async\" title=\"clip_image009\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image009\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/6204.clip_image009_thumb_0D32346A.png\" width=\"364\" height=\"218\"><\/a><\/p>\n<p>I encourage you to run <b>Pull<\/b> often \u2013 by keeping your enlistment up-to-date, you\u2019ll be able to see the direction that the compiler work is headed, and to provide feedback on it in our forums. <\/p>\n<p>If you try building Roslyn from an enlistment, please note that Roslyn is built using <i>itself <\/i>as a requirement, so make sure that you\u2019ve installed the Roslyn preview first before trying that. Don\u2019t try building Roslyn using the old compilers that shipped with VS 2013 \u2013 you\u2019ll just get lots of interesting errors which won\u2019t make a lot of sense.<\/p>\n<h2>Making local changes in the compilers<\/h2>\n<p>When making local changes in the compilers, you\u2019ll want to first create a fork of the code. (The main branch is never modified directly; it only takes pulls coming from forks.) You\u2019ll need to have a <a href=\"https:\/\/www.codeplex.com\/site\/register?associate=None\">CodePlex<\/a> account to do this first, however. Once you\u2019ve got that, then launch your browser, navigate to <a href=\"https:\/\/roslyn.codeplex.com\/SourceControl\/latest\">https:\/\/roslyn.codeplex.com\/SourceControl\/latest<\/a>, and click on the \u201cFork\u201d link:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/5226.clip_image011_thumb_34004AAA.jpg\"><img decoding=\"async\" title=\"clip_image011\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image011\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/5226.clip_image011_thumb_34004AAA.jpg\" width=\"441\" height=\"261\"><\/a><\/p>\n<p>Give your fork some meaningful name and description, and press \u201cSave\u201d:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/3005.clip_image012_thumb_0CC60175.png\"><img decoding=\"async\" title=\"clip_image012\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image012\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/3005.clip_image012_thumb_0CC60175.png\" width=\"411\" height=\"302\"><\/a><\/p>\n<p>You now have your own fork of the code that you can experiment with &amp; update as you see fit without changing your copy of the \u201cmain\u201d source. You can clone it locally using the Team Explorer, just as I showed in the previous section, except that you would specify the forked location (e.g., <font face=\"Consolas\">https:\/\/git01.codeplex.com\/forks\/mattgertz\/testfork<\/font> using my example) as the source, and some other appropriate local disk location for where the code would be stored. (Note that you may see a couple of warnings in the build regarding linking to <font face=\"Consolas\">Syntax.xml.Generated.*<\/font> files. These warnings are benign and will eventually be addressed; you can safely ignore them for now.)<\/p>\n<p>After building your updated compilers, you\u2019ll find the outputs below the Binaries directory off of the root of the enlistment (e.g., in BinariesDebug, if that\u2019s the configuration you built), and you can use <strong>rcsc.exe<\/strong> (for C#) and <strong>rvbc.exe<\/strong> (for VB) to compile any test programs that you want to create.<\/p>\n<p>If, at some point in the future, you want to submit one of your changes for consideration in the main source code repository (as opposed to your own fork of it), you\u2019ll be able to send a pull request to the team from inside CodePlex. (Note that the devs are heads down on finalizing this first version of the new compilers, and so during that remaining time, only simple fixes are likely to be accepted in order to avoid churn. You can expect a blog post later on regarding the types of changes that would be accepted, the procedure for verifying stability before submitting, and so on.)<\/p>\n<blockquote>\n<h3><b>ADVANCED USAGE<\/b><\/h3>\n<p>It is also possible to update your copy of Visual Studio to use your own built version of Roslyn (for example, to see how the IDE reacts to your changes), but it\u2019s slightly complicated:<\/p>\n<p>First of all, you\u2019ll need to use the release fork, <b><i>not<\/i><\/b> the master fork. This is because the compiler code is constantly changing in reaction to feedback, and that includes changes to the APIs that are used by the non-open IDE bits in the Roslyn preview in order to access compiler information (until the APIs get locked down as we get closer to completion). When these APIs change, the ability to communicate between the two is lost. The release fork, however, accurately reflects the state of the code at the time that the Roslyn preview was snapped, and so is safe to use as a baseline for this sort of thing. (You can see the fork on the Roslyn CodePlex site by choosing \u201cSource Code\u201d and then opening the \u201cBrowsing changes in\u201d dropdown \u2013 it\u2019s called \u201creleasesbuild-preview.\u201d)<\/p>\n<p>To switch to this fork in Git, you will need to execute the following two commands from an appropriate Git prompt in your enlistment:<\/p>\n<p><font face=\"Consolas\">&gt; Git fetch<\/font><\/p>\n<p><font face=\"Consolas\">&gt; Git checkout \u2013 track origin\/releases\/build-preview<\/font><\/p>\n<p>Your git repository will now have the contents of the releases\/build-preview branch.&nbsp; Once you\u2019ve done this, you can switch back and forth between the branches using Git checkout master and git checkout releases\/build-preview. (Details on Git usage are beyond the scope of this blog; see <a href=\"http:\/\/www.git-scm.com\/book\/en\/Git-Branching-Remote-Branches\">http:\/\/www.git-scm.com\/book\/en\/Git-Branching-Remote-Branches<\/a> for more information on branching in Git.)<\/p>\n<p>Second, you\u2019ll need to disable Visual Studio\u2019s strong-name assembly checking for the relevant assemblies first. There\u2019s a script to help with that, which you can find checked into the source code at <b>Src\/Tools\/Microsoft.CodeAnalysis.Toolset.Open\/Scripts\/Prepare.bat<\/b>.<\/p>\n<p>Finally, you need to create\/set the environment variable OpenSourceDebug to true in your build environment, so that the code is built with the proper key. In a command line build, you can actually do this while building your changes using <b>msbuild \/p:OpenSourceDebug=true<\/b>. For building inside Visual Studio, you can open a command prompt window, enter <b>set OpenSourceDebug=true<\/b>, and then launch Visual Studio from there. <\/p>\n<p>With all of that done, make your changes. After building, you\u2019ll find the resultant VSIXs to install under your Binaries directory (e.g., BinariesDebug).<\/p>\n<p>Please note that we will never accept pull requests for the release fork \u2013 we need to keep it pristine and accurately reflecting the state of the code relative to the Roslyn preview bits. Anything you actually want considered for submission would need to be ported to a fork created from the master first.<\/p>\n<\/blockquote>\n<h2>Example of updating the compiler<\/h2>\n<p>For those who attended the \/\/BUILD conference, you may have seen Anders demonstrate one example of a change to the language, in which he added support for French quotes in the language. I\u2019ll go through that example in detail here, so that you can replicate it yourself:<\/p>\n<p>(1) Open your fork of the Roslyn codebase in Visual Studio<\/p>\n<p>(2) The next steps depend on which language you want to alter:<\/p>\n<p>(3) For C# developers:<\/p>\n<blockquote>\n<p>a. Open the file SrcCompilersCSharpSourceParserLexer.cs<\/p>\n<\/blockquote>\n<blockquote>\n<p>b. Scroll down to the method <b>ScanSyntaxToken<\/b>, and<b> <\/b>copy &amp; paste in the code that is highlighted below. This will add the character <b>\u00ab<\/b> (Unicode 0x00AB) as a token which can start a string scan:<\/p>\n<\/blockquote>\n<pre class=\"code\"><span style=\"background: white;color: green\">            \/\/ Start scanning the token\r\n            <\/span><span style=\"background: white;color: black\">character = TextWindow.PeekChar();\r\n            <\/span><span style=\"background: white;color: blue\">switch <\/span><span style=\"background: white;color: black\">(character)\r\n            {\r\n                <\/span><span style=\"background: white;color: blue\">case <\/span><span style=\"background: white;color: #a31515\">'\"'<\/span><span style=\"background: white;color: black\">:\r\n                <\/span><span style=\"background: white;color: blue\">case <\/span><span style=\"background: white;color: #a31515\">'''<\/span><span style=\"background: white;color: black\">:\r\n                <\/span><span style=\"background: yellow;color: blue\">case <\/span><span style=\"background: yellow;color: #a31515\">'\u00ab'<\/span><span style=\"background: yellow;color: black\">:\r\n<\/span><span style=\"background: white;color: black\">                   <\/span><span style=\"background: white;color: blue\">this<\/span><span style=\"background: white;color: black\">.ScanStringLiteral(<\/span><span style=\"background: white;color: blue\">ref <\/span><span style=\"background: white;color: black\">info);\r\n                   <\/span><span style=\"background: white;color: blue\">break<\/span><span style=\"background: white;color: black\">;<\/pre>\n<p><\/span><\/p>\n<blockquote>\n<p>c. Next, scroll down to the method <b>ScanStringLiteral<\/b>, and copy &amp; paste the in code that is highlighted below. The character will now become a valid beginning to a string.<\/p>\n<\/blockquote>\n<p><pre class=\"code\">        <span style=\"background: white;color: blue\">private bool <\/span><span style=\"background: white;color: black\">ScanStringLiteral(<\/span><span style=\"background: white;color: blue\">ref <\/span><span style=\"background: white;color: #2b91af\">TokenInfo <\/span><span style=\"background: white;color: black\">info, <\/span><span style=\"background: white;color: blue\">bool <\/span><span style=\"background: white;color: black\">allowEscapes = <\/span><span style=\"background: white;color: blue\">true<\/span><span style=\"background: white;color: black\">)\r\n        {\r\n            <\/span><span style=\"background: white;color: blue\">var <\/span><span style=\"background: white;color: black\">quoteCharacter = TextWindow.PeekChar();\r\n            <\/span><span style=\"background: white;color: blue\">if <\/span><span style=\"background: white;color: black\">(quoteCharacter == <\/span><span style=\"background: white;color: #a31515\">''' <\/span><span style=\"background: white;color: black\">|| quoteCharacter == <\/span><span style=\"background: white;color: #a31515\">'\"' <\/span><span style=\"background: yellow;color: black\">|| quoteCharacter == <\/span><span style=\"background: yellow;color: #a31515\">'\u00ab'<\/span><span style=\"background: white;color: black\">)\r\n            {\r\n                TextWindow.AdvanceChar();<\/span><\/pre>\n<pre class=\"code\"><span style=\"background: white;color: black\">&nbsp;<\/pre>\n<p><\/span><\/p>\n<blockquote>\n<p>d. Finally, scroll further down in the same method, and copy &amp; paste the in code that is highlighted below. The <b>\u00bb<\/b> character (U+00BB) will now become a valid terminator to a string, but only if it matches a corresponding earlier <b>\u00ab<\/b> character.<\/p>\n<\/blockquote>\n<pre class=\"code\"><span style=\"background: white;color: black\">                    <\/span><span style=\"background: white;color: blue\">else if <\/span><span style=\"background: white;color: black\">(ch == quoteCharacter <\/span><span style=\"background: yellow;color: black\">|| (ch == <\/span><span style=\"background: yellow;color: #a31515\">'\u00bb' <\/span><span style=\"background: yellow;color: black\">&amp;&amp; quoteCharacter == <\/span><span style=\"background: yellow;color: #a31515\">'\u00ab'<\/span><span style=\"background: yellow;color: black\">)<\/span><span style=\"background: white;color: black\">)\r\n                    {\r\n                        TextWindow.AdvanceChar();\r\n                        <\/span><span style=\"background: white;color: blue\">break<\/span><span style=\"background: white;color: black\">;\r\n                    }<\/pre>\n<p><\/span><\/p>\n<blockquote>\n<p>e. Build the Roslyn solution. The output will be in the BinariesDebug directory off of the root of your enlistment.<\/p>\n<\/blockquote>\n<blockquote>\n<p>f. Navigate to the BinariesDebug directory, and create a file there called <strong>Program.cs<\/strong>. Paste the following text into it:<\/p>\n<\/blockquote>\n<pre class=\"code\"><span style=\"background: white;color: blue\"><font color=\"#000000\">     <\/font>using <\/span><span style=\"background: white;color: black\">System.<\/span><span style=\"background: white;color: #2b91af\">Console<\/span><span style=\"background: white;color: black\">;\r\n     <\/span><span style=\"background: white;color: blue\">class <\/span><span style=\"background: white;color: #2b91af\">Program\r\n     <\/span><span style=\"background: white;color: black\">{\r\n         <\/span><span style=\"background: white;color: blue\">static void <\/span><span style=\"background: white;color: black\">Main(<\/span><span style=\"background: white;color: blue\">string<\/span><span style=\"background: white;color: black\">[] args)\r\n         {\r\n             WriteLine();\r\n             WriteLine(\u00ab<\/span><span style=\"background: white;color: #a31515\">Welcome to my version of Roslyn!\u00bb<\/span><span style=\"background: white;color: black\">);\r\n         }\r\n     }<\/pre>\n<p><\/span><\/p>\n<blockquote>\n<p>g. Open a command prompt, change directory to the Binaries directory, and enter <b>rcsc.exe Program.cs<\/b><\/p>\n<\/blockquote>\n<blockquote>\n<p>h. Now, enter <b>program.exe<\/b> and see <font face=\"Consolas\">Welcome to my version of Roslyn!<\/font> successfully print out!<\/p>\n<\/blockquote>\n<p>(4) For VB developers, it\u2019s a similar process. However, Visual Basic is trickier because double quotes can also be used in escape sequences for the quotes themselves, which adds a lot of more cases to support. Supporting that would make this example much longer; therefore, humbly begging the reader\u2019s indulgence, I will leave that remainder as an exercise for them. In the meantime\u2026<\/p>\n<blockquote>\n<p>a. Open the file <font face=\"Consolas\">SrcCompilersVisualBasicSourceScannerCharacterInfo.vb<\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p>b. Scroll down to the <b>IsDoubleQuote<\/b> function, and change its contents to the highlighted line below (code comments removed for brevity\u2019s sake):<\/p>\n<\/blockquote>\n<pre class=\"code\"><span style=\"background: white;color: black\">        <\/span><span style=\"background: white;color: blue\">Friend Shared Function <\/span><span style=\"background: white;color: black\">IsDoubleQuote(c <\/span><span style=\"background: white;color: blue\">As Char<\/span><span style=\"background: white;color: black\">) <\/span><span style=\"background: white;color: blue\">As Boolean\r\n            Return <\/span><span style=\"background: white;color: black\">c = <\/span><span style=\"background: white;color: #a31515\">\"\"\"\"c <\/span><span style=\"background: white;color: blue\">OrElse <\/span><span style=\"background: white;color: black\">(c &gt;= DWCH_LSMART_DQ <\/span><span style=\"background: white;color: blue\">AndAlso <\/span><span style=\"background: white;color: black\">(c = DWCH_DQ <\/span><span style=\"background: white;color: blue\">Or <\/span><span style=\"background: white;color: black\">c = DWCH_LSMART_DQ <\/span><span style=\"background: white;color: blue\">Or <\/span><span style=\"background: white;color: black\">c = DWCH_RSMART_DQ))\r\n                             <\/span><span style=\"background: yellow;color: blue\">OrElse <\/span><span style=\"background: yellow;color: black\">c = <\/span><span style=\"background: yellow;color: #a31515\">\"\u00ab\"c <\/span><span style=\"background: yellow;color: blue\">OrElse <\/span><span style=\"background: yellow;color: black\">c = <\/span><span style=\"background: yellow;color: #a31515\">\"\u00bb\"c\r\n<\/span><span style=\"background: white;color: black\">        <\/span><span style=\"background: white;color: blue\">End Function<\/pre>\n<p><\/span><span style=\"background: white;color: blue\"><\/span><\/p>\n<blockquote>\n<p>c. Build the Roslyn solution. The output will be in the Binaries directory off of the root of your enlistment.<\/p>\n<\/blockquote>\n<blockquote>\n<p>d. Navigate to the Binaries directory, and create a file there called Program.vb. Paste the following text into it:<\/p>\n<\/blockquote>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">Imports System.<\/span><span style=\"background: white;color: #2b91af\">Console\r\n<\/span><span style=\"background: white;color: blue\">Module Module1\r\n    Sub Main()\r\n        WriteLine(vbCrLf &amp; \u00ab<\/span><span style=\"background: white;color: #a31515\">Welcome to my version of Roslyn!\u00bb)\r\n    <\/span><span style=\"background: white;color: blue\">End Sub\r\nEnd Module<\/pre>\n<\/blockquote>\n<p><\/span><\/p>\n<blockquote>\n<p>e. Open a command prompt, change directory to the Binaries directory, and enter <b>rvbc.exe Program.vb<\/b><\/p>\n<\/blockquote>\n<blockquote>\n<p>f. Now, enter<b> program.exe<\/b> and see <font face=\"Consolas\">Welcome to my version of Roslyn!<\/font> successfully print out!<\/p>\n<\/blockquote>\n<h2>Saving changes back to the server<\/h2>\n<p>Of course, once you\u2019ve finished building and testing your code modifications, you\u2019ll want to push your changes back to server. The typical usages of Git are supported in Visual Studio \u2013 code that you\u2019ve modified will be marked with a checkmark, and you can (for example) create a commit (which I tend to think of as a local shelveset, being used to TFS) by right-clicking on a changed file in the solution explorer and choosing <b>Commit<\/b>, or by using the <b>Changes<\/b> pane in Team Explorer, as shown below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2018.clip_image013_thumb_05A6C4FD.png\"><img decoding=\"async\" title=\"clip_image013\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image013\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/2018.clip_image013_thumb_05A6C4FD.png\" width=\"244\" height=\"194\"><\/a><\/p>\n<p>Team Explorer also lets you push your changes back to the server at the same time (and bring down any other changes pushed by others) by choosing <b>Commit and Sync<\/b>, or you can do that separately afterwards from the <b>Unsynced Commits<\/b> pane in Team Explorer by either doing a full synch with the server, or else pushing individual commits:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/1351.clip_image014_thumb_41665DB0.png\"><img decoding=\"async\" title=\"clip_image014\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image014\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/1351.clip_image014_thumb_41665DB0.png\" width=\"244\" height=\"168\"><\/a><\/p>\n<p>Changes that you push will also be reflected on the CodePlex site, and you can also see them in Visual Studio by choosing the <b>View History\u2026<\/b> action in the Changes pane in Team Explorer:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/1856.clip_image015_thumb_55EBAD2E.png\"><img decoding=\"async\" title=\"clip_image015\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto\" border=\"0\" alt=\"clip_image015\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2014\/04\/1856.clip_image015_thumb_55EBAD2E.png\" width=\"244\" height=\"77\"><\/a><\/p>\n<h2>It\u2019s a brave new world<\/h2>\n<p>And so, a new chapter begins for the C# and VB compilers, which will lead to more innovation, more transparency, and the strongest .NET experience for everyone involved. We are really looking forward to partnering together with you in that environment!<\/p>\n<p>As part of that partnership, I want to note that hearing back from you on the preview and the open source code is really important to us, and is what will lead to the best products for you. Furthermore, the (anonymous) telemetry coming back from preview will be of tremendous help as well to gauge the performance and reliability of the code. The <b>Discussions<\/b> and <b>Issues<\/b> tabs on the <a href=\"http:\/\/roslyn.codeplex.com\/\">Roslyn CodePlex<\/a> site are great places to make your voice heard, as well as the comments sections in this blog and the <a href=\"http:\/\/connect.microsoft.com\/VisualStudio\">Connect<\/a> site. The <a href=\"http:\/\/msopentech.com\/\">MS Open Tech site<\/a> is a great place to learn more about their open source investments and to provide feedback about that. Finally, I encourage you look at the <b>Help<\/b>\u2192<b>Customer Feedback Options<\/b> dialog in Visual Studio to learn more about on how your telemetry information is used.<\/p>\n<p>There is no doubt that there\u2019s still a lot for us to learn about being part of the open source community, but we\u2019re glad to have all of you along for that ride.<\/p>\n<p>Now, go off and have fun with the preview and the codebase!<\/p>\n<p>&#8211;Matt &amp; the Managed Languages Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s a big day for us on the Managed Languages team! As announced at the \/\/BUILD conference earlier today, and as posted by Soma on his blog, we are not just delivering a new preview of Roslyn to all of you, but are in fact moving all of the compiler code to open source! The [&hellip;]<\/p>\n","protected":false},"author":258,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6,195],"tags":[101,107,115,130],"class_list":["post-243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-visual-basic","tag-matt-gertz","tag-ms-open-tech","tag-open-source","tag-roslyn"],"acf":[],"blog_post_summary":"<p>It\u2019s a big day for us on the Managed Languages team! As announced at the \/\/BUILD conference earlier today, and as posted by Soma on his blog, we are not just delivering a new preview of Roslyn to all of you, but are in fact moving all of the compiler code to open source! The [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/258"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}