Tag: .net framework

NDepend – You must have this tool!


I’m a .NET developer since v1.0 at 2002, and as you may guess, I’ve used a lot of tools to help me doing my job. How many times you realize that you are always doing the same thing over and over, in the same way, and sometimes you don’t even notice that you are letting some “little” bugs or “little” bad practices that in the long run will damage your code? And, how about projects with lots of assemblies, methods, complex behaviors, is this familiar to you? If it is, you want to check this tool NDepend

The first thing you probably note it’s the name, which lead us to think that this tool its about dependencies between components, assemblies, methods. Well, its true! But its much more than that! How many of us don’t need to visualize the dependencies from all angles in our project? How much do you value seeing the relations between your classes, assemblies, methods? How great its to know which method it’s the more complex, or more used, or more critical? Probably this “.net method” should be the more unit tested and optimized! In a team, a tool like this has great value, either for developers either for team leaders who want to know how the technical aspects of the project are going.

But this tool, its not only about dependencies, its about code complexity, metrics and very good warnings and advices to improve your code quality, too. In some tests I’ve made with this tool in one of my projects, I discovered that some of my code should be improved (almost saying fixed!), NDepend has show where there was some source code problems and why they were problems! I’m learning from this tool, besides my senior professional experience as a team leader, developer and Certified Trainer!

In NDepend you will find a lot of interactive visual graphs, matrix, trees of your code and its relationships, but besides the visual features of this tool, which are great, you have access to an advanced tool CQLinq(Code Query Linq) which allows you to build Linq queries to query YOUR CODE! Yes, querying your code!

I think it’s a beautiful feature, and a pertinent add-on to any tool which aspires to analyze code.

An example:

A Linq query to return all my public methods with more than 30 lines of code!

You can use all the Linq operators, such as Take, Except, and have access to a very rich API to query your code by a lot of different metrics, such as:

What are the 10 most complex methods?

As a first experience with this tool, I was very impressed, it’s a very productive tool, improves the quality of my code and of my team developers too. This tools its used by a lot of great companies like: ThoughtWorks, Microsoft, HP, Siemens, Google, Redgate and hundreds of others, they are not wrong about choosing it!

I’ will keep exploring this tool for my projects, my first impressions were great, so, why stop? If you are a professional developer I think you should give yourself an opportunity to improve the quality of your projects trying this wonderful tool! You can use it as either a Visual Studio Extension or as an Application outside Visual Studio.

For now I’m really enjoying what I have seen so far. In the future, I will certainly dig more deeply in specific features of this tool and post about my experiences,

Silverlight 4–Out of Browser Authentication

One of the things that was very difficult to find, even in silverlight forums, was a way to know, in a simple way, what user is authenticated when a Silverlight 4 application is running Out-Of-Browser. I’ve found many information about using WCF, RIA, etc, buts it was not what I wanted. So, I investigated a little more about trying to find out how isolated was Silverlight from windows.


At first sight, Silverlight should act as flash, isolated  as possible from the OS, but when running in Windows (as out-of-browser, thank you Microsoft for this “Air” copy”), I should access windows stuff, since I’m exclusively running in Windows, so the isolated thing doesn’t matter anymore! Wrong! I can access only some windows stuff! The .NET framework for Silverlight it’s a little bit “small” in features!


My first try, was to connect to SharePoint using ClientContext from Sharepoint Client API for Silverlight (My application needs some SharePoint list items). When inside SharePoint I just ask about “who am I”, and SharePoint , running in a windows domain, should respond to me with the authenticated user! Was successful! But with some hick ups every time someone from systems staff changed IIS Windows Authentication configuration or some SharePoint tweaks. The problem: I want to run an application and I need to use a SharePoint just to ask about “Who I am”? Yes, you are right! As we say in Portugal, “A cannon to kill a fly”.


Since my Silverlight app its running out of browser I needed to find a way to use directly windows. I thinks it’s a logic thinking!

When a Silverlight App its running outside browser with Elevated Privileges it can access COM stuff! Well, with this “opening”, the sky it’s the limit!


Thanks to “dynamic” word from C# we can do this:



As you may see, I use a COM Object that returns Active Directory information, including the User logged in.  (OK, the format it’s the AD CN=xxx,CN=xxx, but I now we have a door to the windows, very useful!

Bad Behavior has blocked 154 access attempts in the last 7 days.

Hyper Smash