Roslyn (compiler)

{{Short description|Set of open-source compilers}}

{{Use mdy dates|date=May 2014}}

{{more citations needed|date=June 2016}}

{{Infobox software

| name = .NET Compiler Platform (Roslyn)

| logo = Roslyn.png

| author = Microsoft

| developer = .NET Foundation and the open source community

| released =

| latest release version = .NET 7.0.0

| latest release date = {{Start date and age|2022|11|8}}{{cite web |title=Release .NET 7.0.0

|url=https://github.com/dotnet/roslyn/releases/tag/v4.0.1 |publisher=GitHub |access-date=5 May 2022 |date=14 December 2021}}

| repo = {{URL|https://github.com/dotnet/roslyn}}

| programming language = C#, Visual Basic

| operating system = Windows, Linux and macOS

| platform = IA-32, x86-64

| genre = Compiler

| license = MIT License

| website = {{URL|https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/}}

}}

.NET Compiler Platform, also known by its codename Roslyn,{{Cite web|url=https://msdn.microsoft.com/en-us/magazine/dn879356.aspx|title=C# and Visual Basic - Use Roslyn to Write a Live Code Analyzer for Your API|website=msdn.microsoft.com|date=July 24, 2015 |access-date=2019-01-07}} is a set of open-source compilers and code analysis APIs for C# and Visual Basic (VB.NET) languages from Microsoft.[https://github.com/dotnet/roslyn .NET Compiler Platform ("Roslyn")] on GitHub

The project notably includes self-hosting versions of the C# and VB.NET compilers – compilers written in the languages themselves. The compilers are available via the traditional command-line programs but also as APIs available natively from within .NET code. Roslyn exposes modules for syntactic (lexical) analysis of code, semantic analysis, dynamic compilation to CIL, and code emission.Neil McAllister, [http://www.infoworld.com/d/application-development/microsofts-roslyn-reinventing-the-compiler-we-know-it-176671 Microsoft's Roslyn: Reinventing the compiler as we know it], DEVELOPER_WORLD, 2011-10-20

Features

Features of Roslyn include:

History

The code name "Roslyn" was first written by Eric Lippert (a former Microsoft engineer{{Cite web|url=https://ericlippert.com/about-eric-lippert/|title=Fabulous adventures in coding|website=About Eric Lippert|date=November 29, 2012|publisher=Eric Lippert}}) in a post{{Cite web|url=https://blogs.msdn.microsoft.com/ericlippert/2010/12/16/hiring-for-roslyn/|title=Hiring for Roslyn|date=2010-12-16|website=Eric Lippert's MSDN blog|publisher=Eric Lippert}} that he published in 2010 to hire developers for a new project. He first said that the origin of the name was because of Roslyn, Washington, but later in the post he speaks ironically about the "northern exposure" of its office; the city of Roslyn was one of the places where the television series Northern Exposure was filmed.{{cite news|url=http://www.yakimaherald.com/photosandvideos/localphotos/2542464-8/roslyn-hopes-new-tv-show-brings-15-more|newspaper=Yakima Herald|access-date=1 Nov 2014|date=5 Oct 2014|title=Roslyn hopes new TV show brings 15 more minutes of fame|last=Muir|first=Pat|url-status=dead|archive-url=https://archive.today/20141102014033/http://www.yakimaherald.com/photosandvideos/localphotos/2542464-8/roslyn-hopes-new-tv-show-brings-15-more|archive-date=2014-11-02}}

Microsoft made a community technology preview (CTP) available for public download in October 2011. It installed as an extension to Visual Studio 2010 SP1.[http://www.microsoft.com/download/en/details.aspx?id=27746 Microsoft "Roslyn" CTP] {{Webarchive|url=https://web.archive.org/web/20120418055027/http://www.microsoft.com/download/en/details.aspx?id=27746 |date=April 18, 2012 }}, Microsoft Download Center

The CTP was updated in September 2012[http://www.microsoft.com/en-us/download/details.aspx?id=34685 Microsoft "Roslyn" CTP], Microsoft Download Center to include many updates to the Roslyn APIs introduced in the June 2012 and October 2011 CTPs, including breaking changes.[http://social.msdn.microsoft.com/Forums/en-US/roslyn/thread/5a56122b-d6e5-40e0-8912-60eba3fc9a01 What's New in the Microsoft "Roslyn" September 2012 CTP], Visual Studio vNext Forums While the June 2012 CTP API is complete for the compilers, not all features were implemented for the C# and VB.NET languages.[http://social.msdn.microsoft.com/Forums/en-US/roslyn/thread/f5adeaf0-49d0-42dc-861b-0f6ffd731825 Known Limitations and Unimplemented Language Features], Visual Studio vNext Forums

At the Build 2014 conference in San Francisco April 2014, Microsoft made the "Roslyn" project open-source and released a preview of the language integration for Visual Studio 2013. {{as of|2014|4|3|df=US}}, Roslyn is under the Apache License 2.0. The project was effectively transferred under the stewardship of the newly founded .NET Foundation.[http://www.dotnetfoundation.org/ .NET Foundation – Open Source Foundation for the .NET Community] At the same conference, Xamarin announced that they are working on integrating the new compilers and tools in Xamarin Studio.{{Cite web|title=Highlights from Build 2014's Second Keynote|url=https://www.infoq.com/news/2014/04/Build-2014-Keynote-2/|access-date=2021-12-26|website=InfoQ|language=en}}

The compilers were not feature-complete in this release. Each of the compilers contains features that are planned for the coming language versions (C# 6 and Visual Basic.NET 14). The APIs are also available through the NuGet package manager.{{citation needed|date=June 2016}}

{{as of|2013}}, Roslyn supports VB and C#, and the compilers are written in their respective languages.[https://stackoverflow.com/a/7854697/72720 Microsoft Roslyn vs. CodeDom] Roslyn's first release to manufacturing (RTM) was with Visual Studio 2015.[https://www.visualstudio.com/en-us/news/vs2015-vs.aspx#ManLang Visual Studio 2015 RTM], 2015-07-20

In January 2015, Microsoft moved the Roslyn source code from CodePlex to GitHub.[http://blogs.msdn.com/b/vbteam/archive/2015/01/10/we-re-moving-to-github.aspx We're moving to GitHub!] {{Webarchive|url=https://web.archive.org/web/20151201195326/http://blogs.msdn.com/b/vbteam/archive/2015/01/10/we-re-moving-to-github.aspx |date=December 1, 2015 }}, MSDN VBTeam Blog, 2015-01-10

Architecture

Traditionally .NET compilers have been a black box for application developers.{{Cite web|url=https://www.microsoft.com/en-us/download/details.aspx?id=27744|title = Whitepaper: Roslyn Project Overview| website=Microsoft }} With increasing complexity and demands for source code analysis in modern integrated development environments, however, compilers need to expose application programming interfaces (APIs) that will help developers to directly perform phases of compilation such as lexical and syntactic structure analysis of source code. Roslyn was designed with that intent from the beginning. This reduces the barrier in developing tools specifically designed for source code analysis. APIs of Roslyn are of three types: feature APIs, work-space APIs and compiler APIs. Feature APIs allow source code tool developers to do code refactoring and fixes. Work-space APIs allow plugin developers to perform actions specifically required in integrated development environments (IDEs) like Visual Studio such as finding references of a variable or code formatting. Compiler APIs allow even more sophisticated analysis of source code, by exposing direct calls to perform syntax tree and binding flow analysis.[https://github.com/dotnet/roslyn/wiki/Roslyn%20Overview Overview of Roslyn] from GitHub documentation Using an open-source implementation of Common Language Infrastructure (CLI) such as .NET Core, Roslyn will be able to compile in a platform-agnostic manner capable of running CLI code in Linux, OS X, and Windows.{{citation needed|date=June 2016}}

See also

{{Portal|Free and open-source software}}

References

{{Reflist}}

Further reading

  • {{cite book|author-first=Manish|author-last=Vasani|year=2017|title=Roslyn Cookbook: Compiler as a Service, Code Analysis, Code Quality and more|publisher=Packt Publishing|isbn=978-1787286832}}
  • {{cite book|author-first=Nick|author-last=Harrison|year=2017|title=Code Generation with Roslyn|publisher=Apress|isbn=978-1484222102}}
  • {{cite book|author-first=Sudipta|author-last=Mukherjee|year=2017|title=Source Code Analytics With Roslyn and JavaScript Data Visualization|publisher=Apress|isbn=978-1484219249}}