AzureConf – An Azure Community Event

An Azure Community Event

We’ve received such a great response from the community about AzureConf 2013 that we’re proud to let you know the community conference is coming back!

On September 25th, 2014, Microsoft will be hosting AzureConf, another free event for the Azure community. This event will feature a keynote presentation by Scott Guthrie, along with numerous sessions executed by Azure community members. Streamed live for an online audience on Channel 9, the event will allow you to see how developers just like you are using Azure to develop robust, scalable applications on Azure. Community members from all over the world will join known speakers such as Michael Collier, Mike Martin, Rick Garibay, and Chris Auld in the Channel 9 studios to present their own inventions and experiences. Whether you’re just learning Microsoft Azure or you’ve already achieved success on the platform, you won’t want to miss this special event.

Register for AzureConf

If you’d like to be reminded of the upcoming event and to receive updates via email about AzureConf, please register using the form below. Registration for the event isn’t required for you to attend, but we’d love to send you some preliminary information about the event and to keep you informed as to how the event’s progressing. Once you register, we’ll give you an .ICS file you can download to block some time on your calendar to attend this free, live event online.


See more in

Survey for Web App developers or Cordova developers

Developer Experiences Building Hybrid and/or Web Apps 

The Visual Studio team is looking for developers building hybrid apps using Apache Cordova™  and developers building web apps to provide feedback on their experiences. Your input will provide direct feedback to support changes in future versions of Visual Studio.


This survey can take as little as 5-10 minutes to complete. We are also looking for people to join 30 minute feedback sessions to talk about their experiences in a phone call. If you are interested in joining a feedback session please let us know in the survey. If you are selected to participate in a feedback session, a coordinator will contact you with details regarding scheduling and gratuity. When completing this survey you may also opt in to our survey sweepstakes* for a chance to win a $100 or $50 gift card.


The information you provide is entirely voluntary. If you do not wish to provide us with any information, please disregard this survey. By filling out and returning this survey, you agree that we can use, disclose, reproduce, or otherwise distribute your feedback at the aggregated level. Your personal information will remain confidential. Please check for Microsoft Privacy Statements.

*See details on the next page on how to qualify


[C#] Generic Xml Serialize & Deserialize

Here are some methods to help in serialize an object to xml string and then deserialize from xml string to the object.

The Serialize method:

 /// <summary>
        /// The serialize.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="xmlWriterSettings">
        /// The xml writer settings.
        /// </param>
        /// <typeparam name="T">
        /// The object of the type T.
        /// </typeparam>
        /// <returns>
        /// The value in <see cref="string"/> that correspond the xml.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// The value cannot be null.
        /// </exception>
        public static string Serialize<T>(T value, XmlWriterSettings xmlWriterSettings = null)
            if (value == null)
                throw new ArgumentException("value");

            var serializer = new XmlSerializer(typeof(T));

            var settings = xmlWriterSettings ?? new XmlWriterSettings
                Encoding = new UnicodeEncoding(false, false),
                Indent = false,
                OmitXmlDeclaration = false

            using (var textWriter = new StringWriter())
                using (var xmlWriter = XmlWriter.Create(textWriter, settings))
                    serializer.Serialize(xmlWriter, value);

                return textWriter.ToString();


The Deserialize method:

        /// <summary>
        /// The deserialize.
        /// </summary>
        /// <param name="xml">
        /// The xml.
        /// </param>
        /// <param name="xmlReaderSettings">
        /// The xml Reader Settings.
        /// </param>
        /// <typeparam name="T">
        /// The object of the type T.
        /// </typeparam>
        /// <returns>
        /// The object of the type <see cref="T"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// The xml value cannot be null.
        /// </exception>
        public static T Deserialize<T>(string xml, XmlReaderSettings xmlReaderSettings = null)
            if (string.IsNullOrEmpty(xml))
                throw new ArgumentException("xml");

            var serializer = new XmlSerializer(typeof(T));

            var settings = xmlReaderSettings ?? new XmlReaderSettings();

            // No settings need modifying here
            using (var textReader = new StringReader(xml))
                using (var xmlReader = XmlReader.Create(textReader, settings))
                    return (T)serializer.Deserialize(xmlReader);



Class that inherits from other class should be defined using the attributes



[XmlInclude(typeof( ... ))]

For example:

public class Father
  // something

public class Child : Father
  // something

Azure & Windows Phone and Windows Store Apps Technical Guru – July 2004

The The Microsoft TechNet Guru Awards! (July 2014) from TechNet Wiki is out!

I won

  • Windows Phone and Windows Store Apps Technical Guru – July 2014  (Gold)
  • Microsoft Azure Technical Guru – July 2014  (Bronze)

Here are the comments

guru windows
guru azure

I am really happy! :)

You can read my article here:


Creating framework documentation with GhostDoc

GhostDoc is a Visual Studio extension that automatically generates XML documentation comments for methods and properties based on their type, parameters, name, and other contextual information.

ghostdoc in visual studio

GhostDoc has two versions: Free and Pro, for see the difference see this reference.

One advantage about the GhostDoc Free is, if you follow good naming conventions in your code, then you will get very decent results on the summary GhostDoc generates.  When we see code that is not documented, it is as simple as hit Ctrl-Shift-D to have GhostDoc document it.

Let’s see an example!

We will use an open source project, the Xamarin-Forms-Labs

The PhoneService has a method without comments:
without comments
Using GhostDoc Free, we can use Ctrl-Shift-D to comment that method, here is the result:
with comment

With this tools there isn´t reason for don´t have comments in your code.

GhostDoc Pro, has more feature about it, like

  • XML Comment Preview
  • Document This
  • Document File
  • Document Type

and others….

After the code is commented is great to have a helper for provide with the framework, and GhostDoc Pro has the Build Helper File feature for generate helper files based in the comments.

Here is the “Build Help File” for Xamarin-Forms-Labs

build helper

Like we can see in the image, we can

  • Define the output folder
  • Define the type of the helper file to be generate
  • Scope
  • Define the header and the footer
  • Select the project we want to include in the project

The chm file is good for offline usage and the website is useful for publish the framework online. In this case, in Xamarin-Forms-Labs project, there isn´t any website and only exist the Github repository and for help to expose the helper online, was used the

GitHub & BitBucket HTML Preview

For see the results, see the following reference:


If you want to see GhostDoc in practice, see this overview

Win the C# Corner Most Valuable Professional Award

In the last months I have been participate in C# Corner, here I published some articles.

This week I was suprissed when I saw the C# Corner Q2, 2014 MVPs Announced and my name is in the list of the new C# Corner MVPs! Really Nice 🙂

C# Corner MVP Logo

Analyzing C# code using NDepend


Best practices in Software Development is the right way to have a good quality in Software and nowadays the developers/architects/managers has more consciousness about it or should have!

There are a lot of different tools for measuring the quality of software development, NDepend is one of these tools.

This article has the goal to show the analyse  made by NDepend and the main focus are query and rules, metrics and dependency graph, but NDepend has more features.



NDepend is a Visual Studio static analyzer: analyse layering, specify design rules, plan refactoring, compare different versions of the code, software metrics, dependency graphs, dependency matrix, declarative code query, and more!

ndepend visual studio

There is a trial version for 14 days, we can get it here and there is a Visual Studio Extension that can be find here.
This tool will analyse the dll output from the project and at the end it allow to show different metrics, graphics, diagrams and rules. Here are what the analyse of NDepend can tell us:

  • Application Metric: This section gives you an idea of the topology of your application.
  • Assembly Metric: This section gives you an idea of the size of each assembly within your application in terms of #IL instructions and others metrics.
  • VisualNDepend View: This section illustrates the size of your assemblies, namespaces, types and methods in terms of #IL instructions. You can browse this view dynamically by clicking the Launch Visual NDepend on this Project icon in the NDepend.Project UI.
  • Assembly Abstracness vs. Instability: This section illustrate the Abstracness/Instability principle explained in the assemblies metrics section.
  • Assembly Dependencies: This section shows all dependencies between assemblies of your application in a table.
  • Assembly Dependency Diagram: This section shows all dependencies between assemblies of your application in a diagram
  • Assembly build order: This section gives you one of the possible build order for your assemblies. If a cycle exists in your assemblies dependencies graph, this section will report it.
  • NDepend information and warnings: This sections gives you advices about your code:
    • It warns you when an assembly depends on a less stable assembly than itself.
    • It warns you when the visibility of a type or of a member is not optimal (in the context of the analysed application).
    • It warns you when a type or a member is not used (in the context of the analysed application).
  • CQLinq Queries and Rules: This section reports default CQLinq rules which have been violated. More about CQLinq here.
  • Type Metrics: This section recaps type metrics in a table. A link to the documentation is provided for each metric.


This article will use an Azure Mobile Service as a demo project, but could be another project type.

After opened the project, we should attach the NDepend project to the Azure Mobile Service project
ndepend attach project

After attach the project, we can choice the output folder and which dll we want to analyse

ndepend choice output

For help to understood each dll, here is an overview:

  • CustomersSample.Service is the dll output for the project that contains the Azure Mobile Service that will be deploy to the server.
  • CustomersSample.Pcl is the dll that contains the entities that can be used in client apps (like Windows Phone, Windows Store Apps, Xamarin or in Tests.)
  • CustomersSample.Tests is the dll that contains tests for help to understand if the service is working correctly. This project simulate a client app doing requests to the service.

Note: For help in development, the Pcl contains the dtos file from Service, but these files are “added as linked”, and was used directives (#if !PCL #else #endif) for change the names and for remove the base class from dtos (each dto is a EntityData).

During the analyse we can see the analysis error list:

during the analyze

Is a little strange to have this message

WARNING: No application or third party assembly found in directory {C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF}

Because we are analyzing an Azure Mobile Service and there is nothing related with WPF. It make me sense for WPF project not for this project.


After the analyse, is showed a windows that allow to choose what we want to see


But after this choose we can see the other options, using the Visual Studio menu

visual studio menu

All output can be seen in Visual Studio, but after the analyse, an html page will be open in our default browser that contains an overview about the output.

Yes, there are two ways to see the results, in browser and in Visual Studio. This is a good thing for managers, for example.

See the output in project folder, for this project look like this

output folder

In the browser it looks like it

ndepend output in browser

See the output for this demo here.

In Visual Studio, is recommended to open the dashboard, because it contains an interesting overview.
queries and rules

This overview allow to make some conclusion about the code, for example this sample has 81,77% of comments that is not bad. The graphics don´t have so much information because was the first time we ran the NDepend for this project.

For understood the metrics in dashboard, see this reference.

Note: Code Coverage by Tests is empty because is needed to import this information.  NDepend can import coverage data from:


Code Rules section has some violations, rules that are ok and inactive. And there is one rule that should be seen, because there is a Critical Rule Violated! Really?

Let’s see it!

We can click in “Critical Rule Violated” and a window will be opened

critical rule violated

The rule violated is “Avoid having different types with same name” and we can click in the “Avoid having different types with same name” for see more details. And in the right windows we will see that. There are two classes that has repeated name, see it in solution explorer

solution explorer

Is true, is used the same name in different dlls, but these dlls will never use together and the NDepend should be smart enough for understand these types are not used in the same context.

Is possible to see the query used to verify this rule

The question in this moment is can I change this query to support this specific case?

Yes, we can change the query used and should create the query for support this.

Later we will see a simple case where we will change the query.


Let’s see other violation, for it click in left menu:

queries and rules

Is possible to filter for see, for example, the Rules Violated, here is the list

filter rule violated

There are rules that should be fixed, for example:

  • Methods too big
  • UI layer shouldn’t use directly DAL layer
  • UI layer shouldn’t use directly DB types

and others…

But there are rules that not make sense, for example:

Instance fields should be prefixed with a ‘m_’ : some developers use the keyword “this” and other uses “_” as a prefix for the field name.

And the question is, why “m_”? This reference help in that response, and we can change it for that we want!

change query

With it, is very simple to change the rules for that we want!

There are more queries that need to be changed, another example is

  • Class with no descendant should be sealed if possible: this is another great rule, but if the model is related with database and is using EF and the properties are virtual, the class cannot be sealed.

See more about change queries rules here and here.

NDepend generate a Dependency Graph, that is very interesting, Visual Studio Ultimate has this feature too. Here is the result for this project

This graph should be clean, if it show a lot of connection and looks confuse it means your code has a lot of dependencies and maybe something is not ok. If you are using dependency injection your graph will be clean and beautiful.

Note: This project don´t use DI, but it is a small project for this reason not looks confuse and gives the idea that all is ok.

NDepend has more diagrams: Dependency Matrix, Treemap Metric View and Abstractness vs. Instability, but they are complex, because in a first attempt is not easy to understand what they mean.

See the complete list of feature here.

For finalize, is important to define all options related with this tool. For example, define when the NDepend report should be done

See more about it in this reference Rules Execution Options.



In conclusion, NDepend is a great tool for measuring the quality of software development for a .Net projects. In this article we only generated twice the reports but for a real project it can be useful for follow the metrics, violated rules… The possibility of editing the queries rules is a plus for this tool.


See Also