DavidSpot Blog

Developer, super curious, a dog lover, sports fan and techie guy


Browsing .NET Framework Source code powered by Roslyn

If you're like me you and like to learn from the best in our fields in high hopes that one day you to can be a guru in your field, Microsoft released some time ago the source code for all .NET Framework in cool site witch is powered by the new compiler Roslyn and where you can see how the c# gurus program.

It's very useful when you trying to understand what's happening behind the scenes and learn how to code well and follow great standards, all you have to do is navigate in your browser to http://referencesource.microsoft.com/, type a class name or any .net component and explore.

For instance in the image below, I typed "String" in the search box and the string class that every .net developer utilizes shows up and it's a enormous the amount of code in a "simple" class that we use in our day-to-day dev work.



You can check a short video on how to use this tool provided by Microsoft and their team.


Kudos for the .NET team and Microsoft's change of thinking on how to deliver tools and frameworks to the dev community and embrace the open source and cross-platform world.



Swagger.NET - Powerful Web API Documentation

If you are a Web Developer and you're working on aweome and powerful RESTFull API that does wonders but you're struggling on way to create a documentation there are some great tools available out there.

You may use the HelpPage nuget package and that's pretty good one, but not as complete as the Swagger.

It's easy to use so in this post I decided to add documentation using Swagger for a simple ASP.NET Web API project which contains a single controller with different HTTP methods

You can see a live demo API explorer here, and the source code can be found on GitHub. The final result for the API explorer will look as the image below:


Swagger is language-agnostic so there are different implementations for different platforms. For the ASP.NET Web API world there is a solid open source implementation named “Swashbuckle

Let's start...

Step 1 - Install Swashbuckle Nuget package

Install Nuget package by opening NuGet Package Manager Console and install the below package:


When the installation ends you can see a new class named swaggerconfig.cs inside your folder App_Start


Step 2 - Enable generating xml docs

Next right click in you your project (in my case WebApplication1) and select properties


When you are in the project properties select the build tab and then check the box that says XML documentation file and build your solution.

And that's it... to see your new REST API Documentation simply hit F5 and navigate to http://yourhost/swagger and voilá (in my case the url is http://localhost:56593/swagger)

Happy coding.