Cloud Foundry: Design and Architecture
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Jonathan Allen on Oct 25, 2011
Yesterday we talked about the Rosyln Compiler and Workspace APIs. Today we take a look at the Rosyln Service APIs and how they can be used to extend Visual Studio. The extensions we will look at today are Code Issue, Code Refactoring, Completion Provider, and Outliner.
Like all modern Visual Studio extensions, Service APIs are registered using MEF. This means developers simply need to implement certain interfaces and include matching MEF-style attributes, a much welcomed change from previous versions of Visual Studio which required code signing and COM registration.
Code Issue
The Code Issue extension allows developers to write their own compiler warnings and errors. The sample project included with the CTP shows compiler warnings wherever the letter ‘a’ appears in the syntax tree. As you can see from the images below, they integrate quite nicely into Visual Studio’s overall workflow.


The ICodeIssueProvider interface is quite simple, consisting only of three variants of the GetIssues method. Each variant receives an IDocument containing all of the information about the file being processed including the raw text, the syntax tree, the semantic model, and a back-reference to the containing project. A cancellation token is also included in case the IDE needs to abort analysis, perhaps because the user edited a file.
The three overloads also accept one of the three types of syntax: a node, a token, or a trivia. Most of the analysis work will probably be done at the node level. Trivia represents information not needed by the compiler such as whitespace and comments and tokens lack the context to be informative. Nodes, on the other hand, represent everything from the top level namespace declaration down to the smallest expression.
When errors are detected they can be returned to the IDE via an enumeration of CodeIssue. A CodeIssue consists of a severity level (Information, Warning, or Error), a Span object indicating where the error is located, and a description of the error.
Quick Fix
Code Issues may also include one or more ICodeAction objects. These objects allow developers to provide auto-correct options much like what is seen in the below image.

Building an ICodeAction and matching ICodeActionEdit is significantly more difficult than creating code issues. One needs to learn how to edit syntax trees and publish the updates via the IWorkstation interface. The Rosyln site includes a walk-through for writing Quick Fixes.
Code Refactoring
The support for Code Refactoring looks a lot like the “quick fix” support correction for Code Issues, but it is applied at the text level. The ICodeRefactoringProvider is supplied with a document and TextSpan and is expected to return a CodeRefactoring object. This object simple contains a collection of ICodeAction objects just a like the CodeIssue object discussed above.
The project template for code refactoring doesn’t include a usable demo, but the same techniques shown in the Quick Fix walkthrough can be used here.
Completion Provider
The ICompletionProvider interface has a single method called GetItems. This accepts an IDocument and a position parameter represented as an integer. From this an enumeration of CompletionItem is returned. Each CompletionItem requires the text to be displayed. Developers may also include an icon, description, and/or alternate text to be inserted. (Presumably the insertionText, if not supplied, defaults to the display text.)
While nowhere near as useful as the other providers, one could still do interesting tricks like build templates that are too complex for the normal code snippet infrastructure.
Outlining
The final project template is the Syntax Outliner, exposed via the ISyntaxOutliner interface. This is used to create collapsible outlines in the text editor much like we have for regions, classes, and methods. The interface receives a Syntax node and is expected to return an enumeration of OutliningSpan objects, each of which has a TextSpan to encompass, HintSpan (for mouse-over text), banner text, and the option to AutoCollapse.
Automating Error Reporting for .NET Applications
Visual Studio vNext: ALM features for Agile Planning, Team Collaboration
Using ALM to Drive Business/IT Alignment
How ALM Supports Business Processes
Troubleshoot Java/.NET performance while getting full visibility in production
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
Andrew Watson talks about the work of the OMG, where CORBA is alive and well (hint: in your car), UML and UML Profiles vs. custom Modeling languages, DDS and other middleware, and much more.
Sohil Shah discusses creating iPhone and Android enterprise mobile applications based on cloud services using the open source platform OpenMobster.
Paul Sanford presents the transformations supported by data throughout its life cycle, and how that can be better done with Splunk, an engine for monitoring and analyzing machine-generated data.
A common “best practice” for unit tests is to only write a one assertion in each test. I intend to question this advice by showing that multiple assertions per test are both necessary and beneficial.
John Rauser presents the architectural and technological evolution of Amazon retail websites starting with 1994 and ending with adopting Amazon Web Services.
Michael Stal discusses system architecture quality, how to avoid architectural erosion, how to deal with refactoring, and design principles for architecture evolution.
Every developer has had to integrate with another system, API or component. Tis article provides strategies to handle the change and for he separating system boundaries.
No comments
Watch Thread Reply