Microsoft Visual Studio 2012 RC Released!

Posted by Filip Ekberg on 31 May 2012

I just wanted to make a short post about some very exciting news, Visual Studio 2012!

Visual Studio 2012 RC was just released and can be downloaded together with .NET 4.5!

So it seems the name changed from the "code name" Visual Studio 11 to Visual Studio 2012, not too surprising. [...]

NDepend v4 has finally arrived

Posted by Filip Ekberg on 31 May 2012

It is truly a great pleasure to finally be able to spread the word about NDepend version 4. For those of you that do not know what NDepend is, you have truly missed out on something great. But not to worry, you can catch up in an instant! [...]

What is your prefered size on a programming book?

Posted by Filip Ekberg on 06 May 2012

As you might already know I am currently authoring a book called "A C# Smorgasbord". The work on the book is going great and will, if everything goes as planned, be released later this summer (mid/late July). [...]

Creating a Windows Metro style application in C++

Posted by Filip Ekberg on 02 May 2012

I am going to step out of my comfort zone a bit and write a post that touches the surface of C++ in Windows 8. Let us start off by looking at an image of what the new WinRT(Windows Runtime) look like:

[...]

ASP.NET MVC, Web API & Web Pages released as open source on CodePlex

Posted by Filip Ekberg on 28 Mar 2012

Microsoft have just released a lot of code openly on CodePlex.

I don't think I need to stress how amazing this is! [...]

Video trailer for A C# Smorgasbord

Posted by Filip Ekberg on 27 Mar 2012

Watch the first video trailer for my upcoming book A C# Smorgasbord.

The work on the book is going great, almost 50% of the work is done and the deadline is approaching, stay tuned for more information, trailers and competitions to win a free copy! [...]

Watch my live stream from #webbdagarna!

Posted by Filip Ekberg on 22 Mar 2012

I'm live coding from #webbdagarna, watch me now:

Tweet me if you've got any questions or if there are any problems with the stream! [...]

Introducing the ASP.NET Web API

Posted by Filip Ekberg on 19 Mar 2012

In the new version of ASP.NET you can use something called ASP.NET Web API. This allows you to expose your data in many different formats, such as XML or JSON. The idea is to provide a REST API where you use HTTP for real. Meaning that you use GET/POST/PUT/DELETE. [...]

Don't miss me coding on stage for 2 days at Webbdagarna!

Posted by Filip Ekberg on 17 Mar 2012

There's a Swedish event in Stockholm 22-23 March called Webbdagarna (translation: web days). The focus of the event is to talk about e-commerce, social media, mobile development and much more. It's not so much programming focus, in fact the only coding part of the event is what me and my colleuge will do.

The idea is that we are going to sit on stage for 2 days right next to the speakers to create a very cool mobile app, live! My main focus on this will be to create the API for the application, I will of course use the latest technology for this [...]

Visual Studio 11 Beta

Posted by Filip Ekberg on 01 Mar 2012

Yesterday on February 29, Visual Studio 11 Beta was released and with it comes a beta version of .NET 4.5. You can download Visual Studio 11 Ultimate Beta from Microsofts website.

There has been some changes to the UI that has gotten a lot of attention the last couple of weeks, let's take a closer look at what we can expect from the Visual Studio 11 Beta. [...]

Creating a NuGet Package

Posted by Filip Ekberg on 26 Feb 2012

I put together a short video that shows how you can create your own NuGet Package. This requires that you download the NuGet Package Explorer. Be sure to check out the NuGet documentation, it is very good. [...]

Getting started with a Mocking Framework

Posted by Filip Ekberg on 30 Jan 2012

In previous articles we've looked at how to increase code quality by either introducing test drive development for new features or using inversion of control. There are of course many other aspects that come into play when you want to reach high-quality code and this article is going to introduce you to mocking that will help you along the way.

You might have come across the word "mock" before, when for instance a UI designer for a Windows Phone application on your team puts together a picture of how the application might look when it is finished: Where do the buttons go? What text might be displayed when the button is pressed? [...]

A summary of 2011 and a look at what is about to come

Posted by Filip Ekberg on 05 Jan 2012

Happy 2012 folks! I hope you all had a wonderful new years eve!

The year 2011 has been very interesting, we've had the opportunity to see some very exciting things that is about to reach the market. I'd like to summarize what I've been writing about in 2011 and breifly tell you guys what's about to expect from me in 2012. [...]

Adapting to Inversion of Control and Dependency Injection

Posted by Filip Ekberg on 20 Dec 2011

You might have come across the phrases IoC, Dependency Injection, Mocking among others, these are commonly used when talking about "Inversion Of Control" which is the full meaning of the abbreviation IoC. So what is this "IoC" that everyone is talking about?

Inversion of control is a principle in Software Engineering, let's just take a look at the Wikipedia definition of this [...]

Hosted Execution of smaller code snippets with Roslyn

Posted by Filip Ekberg on 08 Dec 2011

Lately a lot of my time has been spent on playing around with Roslyn, if you have no idea what Roslyn is I suggest that you go and >read my previous posts on it. One of the things that I challenged myself into doing was creating some soft of service that could execute a code snippet like the interactive window and give me the result back to me. First off I just want to say that I completely Love the C# Interactive Window, I've got two posts dedicated to it already!

With that said, let's step on the gas a bit, a while back there was a blog post about how to replicate the c# interactive window outside visual studio, hence creating a REPL that didn't require you to run visual studio. This is pretty awesome if you ask me. However the code that you write into the REPL is assumed to be trusted, it doesn't run in a completely different security context which makes it dangerous if you want to expose it to others. [...]

Using the C# Interactive Window that comes with Roslyn - Part 2

Posted by Filip Ekberg on 25 Nov 2011

In the previous post we looked over an introduction to the C# Interactive Window that comes with Roslyn, now let's have a look at some things in the c# interactive window that will increase your productivity! I want to thank Kevin Pilch-Bisson ( @Pilchie ) for pointing some of these things out.

One question that arise when I showed off the C# Interactive Window at work was: This looks great, but can we use types in our current solution? [...]

Using the C# Interactive Window that comes with Roslyn

Posted by Filip Ekberg on 14 Nov 2011

I often find myself wanting to explore new options and see what is possible to do and what is not, at other times I might really need to test something fast just to see if my concept will work. In the past I've either created a test for this, mocking the stuff that I need and then finding myself debugging the test. Or I just write a method and use my test-extension to invoke the method that I right click ( cool feature from TestDriven.NET ). [...]

Exploring how to write a code analyzer with Roslyn

Posted by Filip Ekberg on 23 Oct 2011

In the previous post we looked at the documentation that came with Roslyn and how to create your first code analyzer. Now let's take this a step further and start refactoring the code and look for more errors. Start off by create a new solution, don't worry we're going to re-use bits of the code from the previous post, but in a refactored manner! [...]

Creating a basic code analysis with Roslyn

Posted by Filip Ekberg on 23 Oct 2011

If you've installed the Roslyn CTP, you can go to the installation folder and look inside the Documentation folder, there's a lot of interesting information here that you can make use of. I've got my documentation here:

C:\Program Files (x86)\Microsoft Codename Roslyn CTP\Documentation

Now there's one document here that is a bit extra interesting, at least for me, it talks about how we can make basic code analysis with Roslyn ( How to Write a Quick Fix (CSharp).docx ). The basic idea is to identify whenever a variable can be made const. So for those of you that haven't had the time to download and install Roslyn yet, I'll show you how to do exactly that with the help of their sample. It's essentially the same outcome and code as they use in their documentation, but I will try explain a little bit more about each piece and add some extra things as well. But be sure to check out the documentation that comes with Roslyn as well! [...]

Getting all methods from a code file with Roslyn

Posted by Filip Ekberg on 21 Oct 2011

In the previous post we started looking at Roslyn and let's continue on this topic and see what else we can get out of it! I want to take a look at how we can retrieve all methods and get some information about them. I've added another method to the Person-class so it looks like this now [...]

Using Roslyn to parse C# code files

Posted by Filip Ekberg on 20 Oct 2011

A couple of days ago Microsoft released something called the Roslyn Project and it is now in it's CTP state, just as Async! But what is Roslyn and what can it be used for? In the previous post I talked about how I wrote assembler that was generated from an application that parsed some programming language, but what I didn't do was the actual parsing of code. Actually parsing code is not only relevant when you want to write a compiler, it is also useful when you want to evaluate how good a certain chunk of code is. [...]

When can knowing about IL and the internals be useful?

Posted by Filip Ekberg on 19 Oct 2011

Lately we've been looking a lot on how you can use IL to create types at runtime, the same IL that we have emitted at runtime is what the C# compiler compiles the C# code to. So the first thing that comes to mind when someone asks me when knowing about IL and the internals of C# can be useful is when you want to write a compiler. Let's say that you for educational purposes want to create a very simple language and you want to be statically typed and usable by other .NET languages, then compiling the code to MSIL will allow you to do just that. [...]

Creating a Dynamic Method that uses a Switch

Posted by Filip Ekberg on 18 Oct 2011

We've looked at some very interesting Dynamic Method creation in the last posts and let's keep this up! We've looked at how we can compare values and then jump somewhere if the comparison is evaluates to true. Now let's take a look at how we can implement a switch! [...]

Creating a recursive dynamic method that calculates factorial

Posted by Filip Ekberg on 17 Oct 2011

In the last post we looked at how we could call a dynamic method, now let's have a look at how we can create a recursive method that calculates factorial for non-negative integers! First of all we should take a look at what factorial means, usually it's written like this:

5!

[...]

Calling a dynamic method from a dynamic method

Posted by Filip Ekberg on 16 Oct 2011

Let's take a look at how we can call a method from a dynamic method. In the last post we looked at how we called a static method in our current context, but let's take a look at how we can call another dynamically created method that takes an integer parameter and then does some math operation on it and then returns it.

First off we need to create this method, we're just going to use IL that we've seen before and I am going to add the input parameter with 2. The dynamic method will look like this with the emitted IL [...]

Exploring OpCodes with DynamicMethod and looking at the evaluation stack

Posted by Filip Ekberg on 16 Oct 2011

In the previous post we looked at how our DynamicMethod could pass a value to another method, let's take a look at something a little bit more interesting! Consider that I want to have a method that takes an integer and this integer is manipulated and then printed out by this method. In this case, the manipulation is a multiplication and the second method is just a method to print the result in a nicely formatted way. [...]

Calling a non-dynamic method with parameters from a dynamic method

Posted by Filip Ekberg on 14 Oct 2011

I think it's time that we explore some more OpCodes and in this post I will look at how we can call methods with parameters passed to them!

There are two OpCodes that we can use to execute a method these are [...]

How Dynamic Methods affect resources like memory and disk space

Posted by Filip Ekberg on 13 Oct 2011

We've seen how we can create static methods at runtime and one of the benefits that I've been talking about is that the methods will be disposed when they don't have a reference anymore. This can be crucial if you work in an environment where memory resources are limited. So what I will do is I will allocate a couple of million methods and see what happens with my memory usage! [...]

Getting information about a method and its local variables

Posted by Filip Ekberg on 12 Oct 2011

Sometimes it can be useful to get information about a method such as getting all the local variables. We've looked at how we can retrieve information about known types and setting / getting their values. Now let's take a look at how we can get information about a method and it's local variables in runtime! [...]

Creating static methods at runtime

Posted by Filip Ekberg on 11 Oct 2011

Lately we've been looking at how we can get and set information on known structures during runtime, we've also looked at how we can invoke methods in our classes. Let's kick it up a notch and look at how we can add static methods during runtime. This means that we want to add a method with a known return value and known parameters. It's not always the case that you know the return type nor the parameter types, but in this example we will. [...]