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.
Let the installation begin!
Here are some screenshots from the installation process:


Once Visual Studio 2012 RC is installed, you can fire it up and start coding! It will require at least one reboot during the installation process.
Below are some screenshots from Visual Studio 2012 and as you can see, they’ve listed to the public and added at least some color to the icons.
Start screen of Visual Studio 2012

New project window

Running a Windows 8 Metro Applicaiton in the simulator

I am currently running Visual Studio 2012 RC in the Windows 8 Release Preview which was released at the same time as Visual Studio 2012 RC.
?>
Vote on HN
NDepend v4 has finally arrived
Posted by Filip Ekberg on May 31 2012 1 Comment
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!
NDepend is a complexity analysis tool that integrates into Visual Studio 2011, 2010 and 2008. It also comes with a standalone component for analyzing your projects.
I have been using NDepend v4 for a while now and I liked it so much that it gets a place in my upcoming book.
What makes NDepend so powerful is that you can customize the analysis to adapt to your own set of restrictions and you do this with what is called Code Query LINQ(CQLinq). This is one of the biggest changes in version 4 and it really takes the tool to another level, prior to version 4 you used another way to customize your queries.
Here is an example(example taken from NDepend Features page) of a CQLinq statement that looks for methods that do not have enough comments:
from m
in Application
.Methods
where m
.CyclomaticComplexity > 15 && m
.PercentageComment < 10
select new { m, m
.CyclomaticComplexity, m
.PercentageComment }
I made an analyze of the ASP.NET Web Stack project and this is what the report look like in the stand alone program called Visual NDepend:

In the image above it shows the dependency graph you have a lot of other views that you can use to find complexity in your solution. You can also see a list of the different CQLinq results such as:
- Types that are too big
- Methods that are too complex
- Methods that takes too many parameters
When composing this analysis you also get an HTML Report that looks like this:

It essentially contains the same information as you would get from Visual NDepend, but it is very handy to be able to pass this report on to fellow co-workers.
Another Very powerful thing is that you can integrate NDepend with for instance CruiseControl.NET, which is a build server. This means that every time the build server builds your project, it can also analyze the solution and compare how your complexity increases or decreases.
You can get a 14 day trial, I really suggest you do, you do not want to miss out on this! There will also be much more content regarding NDepend in the book I am currently writing, stay tuned for more information about that.
?>
Vote on HN
What is your prefered size on a programming book?
Posted by Filip Ekberg on May 6 2012 1 Comment
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).
However, before the book goes off to print, I want to know what trim size you guys prefer, meaning the size of a page(the book when it’s closed). The poll below lists the standard trim sizes available.
So please cast your vote to make this book perfect! Here’s a PDF that compares a lot of different trim sizes.

Loading ...
?>
Vote on HN
Creating a Windows Metro style application in C++
Posted by Filip Ekberg on May 2 2012 2 Comments
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:

As you can see, there are a lot of powerful ways to create both metro style and desktop applications. Notice that in Metro style applications, XAML is connected to both C++ and C#/VB.
During my years of .NET development, the reason for using C# or VB has been; RAD(Rapid Application Development). In a world filled with consultants where the customers only see the end result, it can often be hard to convince that putting down 200% more time using C++ is a great idea.
Because let’s face it, it takes a lot more time creating a desktop application in C++ using MFC than what it would to use C# and XAML. Before someone throws a stick at me I have to say that it of course depends on what kind of application you are creating.
The downside from using a managed programming language is that it tends to be a bit slower; in some cases this is critical. Most customers do not care if they have to wait a couple of extra nano-seconds for a control to render.
What does this have to do with Windows 8 and the Windows Runtime?
I really got a nice tingly feeling in my stomach when I first saw that you could use XAML with C++ in Windows 8. But that is not the best part, the best part is that it is fully native!
This means that the designers can make the interface in expression blend and we can dig down into C++ on the backend.
Let us have a look at this! You will need to have Windows 8 Consumer Preview and Visual Studio 11 beta installed (or later) in order follow these examples.
Start off by creating a new blank Windows Metro style application, this is found under “Other languages -> Visual C++”:

When the project is created, you will see some files that have been generated, these are pretty similar to what we are used to see in a normal XAML application in .NET:

Open up the file “BlankPage.xaml”, this will bring you into the designer view of the XAML file. Add a TextBlock to the page:

As you can see in the preview, it shows a tablet with the current view inside it. Remember that we are working with a Metro application, the idea is that you have a metro application in fullscreen or pinned to one of the sides on your screen.
By only adding the TextBlock, this is the XAML that we have now:
<Page
x:Class="WinRTDemo.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinRTDemo"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<TextBlock x:Name="MyTextBlock"></TextBlock>
</Grid>
</Page>
If we now navigate to the file “BlankPage.xaml.cpp”, this is where we can actually access the TextBlock. When you compile your solution, the XAML will also be compiled to C++, just like the XAML in a normal .NET application is compiled.
However, to access the TextBlock and set the text of it to the current date, what do we write?
The TextBlock is actually a TextBlock^, the “^” is called a “hat”. Think of this as a pointer, but a pointer that you do not have to worry about disposing.
This means that you do not have to do delete on the object yourself, because it will be automatically removed once the context of it has been exited.
So in order to set the value of the TextBlock we do:
MyTextBlock->Text = "Hello World!";
We can test-run this before we display the current time. First, let’s select to run it in a simulator like this:

This will bring up a tablet emulator that mirrors your system:

Now let’s take a look at how to get the current date there instead of that “Hello World!” text. In WinRT you can access an object called Calendar which you can use to get the date and time.
In order to get a pointer/hat, you need to modify the instantiation a tiny bit. Instead of just writing this:
You write:
This lets the compiler know that this will in fact be a hat/”managed pointer”. Something that I have missed a lot when not working in C# is the keyword var and this has finally come to C++ with the more appropriate name auto.
So in order to get a calendar object, calibrate it to the current time and then set the text to the current date we can simple do it like this:
auto calendar
= ref new Windows
::Globalization::Calendar();
MyTextBlock
->Text
= calendar
->YearAsString
() + " " +
calendar
->MonthAsString
() + " " +
calendar
->DayAsString
();

This has been a short post about how to create your first C++ Metro style application in Windows 8 and I hope you enjoyed the read, if you have any questions do not hesitate to leave a comment, tweet or e-mail.
?>
Vote on HN