Click here to Skip to main content
13,051,447 members (50,941 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 25 Apr 2013

C# Snippet Sharing with Roslyn and SignalR

, 5 Jun 2013
Rate this:
Please Sign up or sign in to vote.
Share code online with Visual Studio-like interactive features.

Editorial Note

This article is an entry in our Windows Azure Developer Challenge. Articles in this sub-section are not required to be full articles so care should be taken when voting. Create your free Azure Trial Account to Enter the Challenge.

Update :  

The site has launched at 

Unfortunately, I was building the site instead of writing.  I don't have time to go back and re-do the completed parts of the contest (which stinks because I'd love to write about knockout.js/SignalR/Azure Websites/Azure SQL).   Also, the app doesn't even apply to the last 2 challenges since I'm not a virtual machine and I don't support mobile.  Needless to say the contest is a wrap for me! 

I just wanted to make an update for anyone interested in the initial idea; I think I've delivered what I promised and more!   


There isn't really a killer code snippet sharing site, and definitely not one that has as many language integrated features as what I'm planning to build in a specifically C# snippet sharing site.  The initial release will have syntax highlighting, intellisense-like documentation on hovering for built in types and methods, and real time updates with WebSockets.   

The goal is to make a code snippet sharing site for C# with enough C# specific features to stand above other snippet sharing sites.  

The Application    

Here's an example of a bit of pasted code with code formatting.  All of the data is sent to a SignalR hub, run through Roslyn, and the nicely formatted HTML is sent back.   

Snippet sites like github's gist are excellent, but I'd like to expand upon the code snippet uploading model by adding features that work specifically with C#. I'm hoping this will allow users to analyze short pieces of code more easily than sites that are no more than a text dump of the code you pasted in.   Being able to hover over a Base Class Library or Framework Class Library type and seeing the documentation is something I've never seen on any site. 

There will be enough social features to make it an enjoyable site to spend some time on (and hopefully learn) but not so social it's overbearing on the experience of reading useful code.   

I'd also like to be able to allow users to search by language feature / usage. (Example : show me  all snippets that use implicitly typed local variables by utilizing 'var') 


A snippet sharing site (with Visual Studio-like features) would not be very feasible without the creation of Roslyn.  Roslyn is the white-boxing of the C# compiler to  allow you to write code that makes sense of C# code. I've used Roslyn in the past to write a Visual Studio plugin that will find opportunities to make your code more concise and refactor out methods.     

Why Windows Azure

WebSocket support, no upfront cost, and no server configuration are the major reasons I chose Azure. Having to worry about security only at the application level is a major plus for me as well.

Azure SQL Database 

Azure SQL Database will be utilized as the data store. The confidence of security out of the box (IP restricted by default), hot standbys in the same data center, and the fact that Azure SQL database is mostly compatible with SQL Server 2012 sold me on it.  Being able to deploy to a non-Azure environment gives peace of mind, even if it will likely never happen. 

Libraries/Frameworks to be utilized  

  • ASP.NET MVC 4 
  • SignalR (hubs) 
  • Knockout.js 
  • Metro UI CSS 
  • Entity Framework 5
  • ELMAH 

Update : 

Now that the contest has been extended, here are a few screenshots showcasing more design.  I also forgot to mention that I'm using CoffeeScript for the JavaScript!   Recent snippets update in real time (and as time goes on, older ones fall off the front page) 

Okay Final Update screenshot before the next leg of the contest.  Can't wait to deploy to Azure!  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
.NET Developer and blogger at

You may also be interested in...


Comments and Discussions

QuestionWhy SignalR? Pin
Dewey25-Sep-14 1:25
memberDewey25-Sep-14 1:25 
AnswerRe: Why SignalR? Pin
Afzaal Ahmad Zeeshan23-Nov-14 8:26
professionalAfzaal Ahmad Zeeshan23-Nov-14 8:26 
GeneralMy vote of 5 Pin
roscler5-May-13 0:08
professionalroscler5-May-13 0:08 
GeneralMy vote of 5 Pin
Rumnha27-Apr-13 17:31
memberRumnha27-Apr-13 17:31 
GeneralRe: My vote of 5 Pin
BrianRosamilia29-Apr-13 14:38
memberBrianRosamilia29-Apr-13 14:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Jun 2013
Article Copyright 2013 by BrianRosamilia
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid