Sunday, December 2, 2012

[Event] Initiation of new Agile DotNet Association in France

We recently created a new association with the goal to promote Agile methods in the Microsoft environment in France. It is a non-profit association open to anyone who is interested in this absorbing subject. I am one of the founders and an active member of the association.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVBKv8BJZhAtPgbnaiBPzHGrcQykdKAxCb8DgH8VRl1JWze8AGNXgsvx2xQMHrI-n9ykkve5FUGj8DeJ_Fm5e-A_z_wFar8XY_Cmqw3y9u0hdNouhzm42lfSU7k4R-QGN9t6Gwcy9swFk/s259/agiledotnetfrance.png

Next Monday 3rd of December 2012 will be a the initiation of this new association with the help of our first sponsors (Microsoft, Axones, Ineat Conseil, D-Cube, Cellenza). I am sure that other sponsors will join us soon !

The initiation will take place at the Microsoft Conference Center in France in Paris. Jeff Sutherland, Creator of Scrum and sponsor of the association, has accepted to come and to help us in promoting the association. He will honor us with his presence and he will be available for questions during the evening !!!

The agenda will be as follows:

18:30:
Reception and Welcome

18:45:
Presentation of the Agile DotNetFrance association by its president Arnaud Hego (Cellenza)

19:00:
Presentation of the Agile & Microsoft ecosystem by Benoit Launay (Microsoft)

19:15:
Keynote by Jeff Sutherland, Creator of Scrum and sponsor of the Agile DotNet France association

20:15:
Cocktail

So if you live around Paris and are able to come, I hope to see you see there. We already have more than 250 registered visitors, so I think that this will be a quite interesting event !


Share/Save/Bookmark

Wednesday, November 14, 2012

[Information] New adventure begins ! Cellenza here I come !

Just a quick note to inform you that I am leaving Capgemini Sogeti to work for Cellenza as CTO. This is going to be quite an adventure and I thank Cellenza in trusting me with this high responsibility.

logo-cellenza

You will see much activity around Cellenza in the next weeks. I am glad to announce that there are some very bright and intelligent people that I am going to work with. Also we are hiring so please contact me if you are interested in joining us !


Share/Save/Bookmark

Monday, November 5, 2012

[Publication] Article in French Programmez Magazine on Portable Class Library with Visual Studio 2012

You can find an article of 3 pages on how to use the Portable Class Library (PCL) with Visual Studio 2012 in the French Programmez magazine No.157 written by me and Fathi Bellahcene.

00001

First Page and Second Page (low resolution)

Third Page (low resolution)

The article is written in French, but this time I have already written a blog post in English on how to use the PCL with Visual Studio 2012 on my blog, which you can find here.


Share/Save/Bookmark

Thursday, October 25, 2012

[Tutorial] Test Driven Development with Visual Studio 2012
Part4: Full cycle of TDD using Visual Studio 2012

The last blog post in the series introduced some of the new features within Visual Studio 2012, applicable to Test Driven Development (TDD). This blog post is going to show you how to practically use all of those new features and apply them to Test Driven Development. You are going to see a full cycle of TDD using Visual Studio 2012, during the implementation of a simple calculator example!

Phase 1: Write a unit test for a new functionality  

Respecting the Test Driven Development approach, you have to create your unit tests before starting with any implementations. In our example we have to write some unit tests for the methods “Addition” and “Multiplication”. But first of all, we have to add a project of type “Unit Test Project” to our solution (if you do not already have one).

Fig8_UniTestProject

You may now add the necessary unit tests.Here is an example of the unit tests you could add based on the unit test framework NUnit:

Tdd_Code

Please note that the “Calculator” class and its methods “Addition” and “Multiplication” do not exist at this stage yet.

Visual Studio 2012 provides the possibility to generate the missing code in an automatic way. For that you just have to right-click on the “new Calculator” definition in the unit test project and choose to generate the class via the “Generate/New Type“ option in the menu.

Fig9_GenerateType

A wizard opens and you are now able to configure multiple options such as the type (classe, struct, interface, enum), the access (public, internal), the destination project and the file name for the generation of the missing class.

Fig10_NewType

The next step, after having auto-generated the “Calculator” class, consists of auto-generating the missing methods within this class. This can be achieved in almost the same way as it was done for the missing class. You do a right-click on the method calls "calculator.Addition(…)” and “calculator.Multiplication(…)” in the unit test project and you generate them via the “Generate/Method Stub” option in the menu.

Here is the auto-generated source code of those two methods:

Autogenerated

In the last step of this phase you have to open the “Test Explorer” window where you may now execute all your unit tests. This can be done by clicking on the “RunAll” button or by using the already explained “Post Build Test Runs” option (see the previous blog post in the series).

As expected your unit tests will fail, since the corresponding source code has not been implemented yet. We will see how to do that in the next phase.

Fig11_FailedTests

Phase 2: Implement the minimum code necessary to pass the test

Now in this phase, the only thing that needs to be done, is to implement the expected functionalities. The idea is to develop the minimum code necessary, which responds to the functional requirements. Everything that concerns optimization and amelioration must not be addressed since it will be treated later in the next phase (refactoring).

Modified

Following the implementation you may now restart your unit tests by clicking on the “RunAll” button or by using the already explained “Post Build Test Runs” option (see the previous blog post in the series). Your should see that you unit tests have been terminated successfully. If this is not the case you have to review your code and iterate until all of your unit tests pass successfully.

Fig12_PassedTests

At this stage the source code corresponds exactly to the functional needs and it provides the expected behavior. The final project structure includes a unit test project as well as an application implementation project.

Fig13_SolutionExplorer

But the source code might not be optimized. Its quality might not adhere to your quality standards, so it has to be ameliorate. The refactoring can be done without any problems since the unit test assure that there are no regressions. Moreover, regressions can be detected very quickly and thus can be handled as soon as possible. This is going to be explained in the next phase.

Phase 3: Refactor and optimize the source code

The process of improving your source code after the initial implementation phase (Phase 2)  is called “Refactoring”. The source code structure is modified internally without any modifications to the external behavior (very important!!). A source code that just “works” is now transformed into a source code that works in an optimal way. Most of the time, the resulting source code is executing with better performance, using less memory and/or with a better software design.

The refactoring consists of the following steps (non-exhaustive list):

  • Detect and eliminate all code duplication
  • Limit complexity and the number of classes
  • Simplify and optimize method algorithms
  • Relocate, rename and harmonize methods
  • Improve code readability
  • Remove not used code (also called “dead code”)
  • Add comments to complex code sections

In our simple example there is nothing to be refactored, since there are neither enough methods nor enough classes. But this last step has to be done in bigger developments at the end of each cycle. Afterwards, a new development cycle starts with  new functionalities from Phase1 on.


Share/Save/Bookmark

Wednesday, October 24, 2012

[Tutorial] Test Driven Development with Visual Studio 2012
Part3: New features in Visual Studio 2012 (2/2)

The last blog post in the series introduced some of the new features within Visual Studio 2012, applicable to Test Driven Development (TDD). This blog post is going to continue to further present some more features of Visual Studio 2012 in this domain.

Management of unit tests via Test Explorer

The first impression when opening the “Test Explorer” window is a very positive one. Here are the principal changes when compared to Visual Studio 2010:

  • The “Test View” and “Test Results” windows have been deleted and consolidated into the “Test Explorer” window. This is going to streamline the interaction between development (the code) and tests.
  • The interface is simple but efficient: all information is accessible via a simple mouse click in a very intuitive way.
  • Unit tests are grouped by their status (failed, passed,…), failed tests are shown on top, a double mouse click allows for accessing the code source of a test (no need to open an external window anymore).
  • It is now much easier to execute a code coverage analysis. In previous versions this was not handled in a very intuitive way, since you had to create a configuration file, start the analysis via the Visual Studio menu and then open the adequate results window. In Visual Studio 2012 everything was consolidated and is now integrated in the “Test Explorer” interface.

Post Build Test Runs

A best practice when adhering to TDD principles is to execute unit tests as soon and as much as possible for being able to identify bugs, misbehaviors and regressions. There is a new feature, called “Post Build Test Runs”, in Visual Studio 2012, which allows for automatically unit test execution after each compilation. The feature can either be activated via the menu under “Test/Test Settings” or directly from within the “Test Explorer” window. When using this features, unit test are executed on a separated and dedicated thread, so there is no impact on developer efficiency.

Fig7_RunTestsAfterBuild

Migration of unit tests from Visual Studio 2010 to Visual Studio 2012

As you might know, there a multiple difficulties and bugs, when migrating unit tests from Visual Studio 2008 to Visual Studio 2010, because the migration is not very transparent and sometimes even somewhat complex. In some cases you even have to migrate to the .NET 4.0 Framework to make everything work correctly!

I can assure you that there are no such migration problems, when trying to migrate from Visual Studio 2010 to Visual Studio 2012. This is partly due to the fact that most of the unit test components are the same between those two versions of Visual Studio. The library is still Microsoft.VisualStudio.QualityTools.unitTestFramework.dll in its version 10.0.0.0, which is still based on .NET runtime v2.0.50727.

Fakes Framework (Stubs and Shims)

The “Fakes Framework” based on the  “Moles” project, created by the Microsoft Research team, is now exclusively integrated into the “Ultimate” version of Visual Studio 2012 (and sadly only in this version!).

The goal of this framework is to aid development teams in producing unit tests rapidly and easily. For this, the “Fakes Framework” adds 2 notions:

  • Stubs: they provide automatic mock implementations of interfaces or abstract classes, that can be used in unit tests for being able to isolate parts that need to be unit tested.
  • Shims: they allow for runtime interception and redirection of method calls to specific objects. For example , they may be used to mock objects, which normally can’t be mocked due to access restrictions in the .NET framework. By using Shims it is possible to redirect calls to these objects with calls to objects that provide your own implementations.

There are however some restrictions. One restriction is that classes included in the “mscorlib” namespace cannot have any “Fake Assemblies”. Unfortunately, you cannot create any Shims for the “System.Configuration.ConfigurationManager” class for example.

The “Fakes Framework” provides some real advantages, when compared to existing mock testing frameworks such as RhinoMock, because developers do not need to modify their functional code for being able to execute unit tests.

In my next blog post I am going to show you how to practically use all of those new features and apply them to Test Driven Development. You are going to see a full cycle of TDD using Visual Studio 2012 !


Share/Save/Bookmark

Wednesday, October 17, 2012

[Tutorial] Test Driven Development with Visual Studio 2012
Part2: New features in Visual Studio 2012 (1/2)

The last blog post in the series introduced Test Driven Development (TDD). This blog post is going to talk about some of the new features in Visual Studio 2012, that allow you to successfully apply the TDD approach in your daily work.

Visual Studio 2012 external test framework support

The previous version Visual Studio 2010 already provides the possibility of using external test frameworks. But unfortunately with multiple limitations such as:

  • Dependency on third party applications for being able to execute unit tests. For example Gallio needs Icarus Runner if you want to run your unit tests.
  • Code coverage analysis does not work natively, only by using third party products (such as NCover for example).
  • Execution of unit tests is specific to certain plugins : for example there is a difference if you run your MSTest unit tests from within Visual Studio 2008 or by using Resharper, which may result in problems when trying to apply continuous integration processes.

As you can see, you have to multiply plugins and tools, that might not always be compatible with each other, when using Visual Studio 2010 with external test frameworks. Really not an optimal situation, when you want to benefit from specialized external test frameworks and their advanced functionalities !

One of the major updates of Visual Studio 2012 is the support of several external unit test frameworks for multiple languages without any of the limitations mentioned above.

Here are some of the unit test frameworks that you can now use easily:

For .NET :

For Javascript/HTML :

For C++ :

How to use NUnit as external test unit framework 

Lets see how to use NUnit as external test unit framework. First you have to install NUnit (currently as Prerelease) via NuGet.

Fig2_NUnit

Then you have to install the test adapter plugin for NUnit (currently as Beta) via the Extension Manager, which you can now find under “Tools/Extensions and Updates…”. Note that all test adapters are free of charge and that the functionality to search and download those adapters is fully integrated in Visual Studio 2012.

Fig4_Menu

Fig3_Extensions

After installing the NUnit test adapter plugin, you are able to use all Visual Studio 2012 unit test functionalities together with NUnit. You may for example execute your NUnit unit tests directly from within the Visual Studio 2012 IDE, display the test results in the standard view “Test Explorer” and run a code coverage analysis on your code.

Fig5_CodeCoverage

Support for C++ in native MSTest

Another big feature of Visual Studio 2012 is that it now supports native MSTest unit tests for C++ applications. Good news for C++ developers, who may now also apply Test Driven Development using native MSTest as unit test framework.

Fig6_NativeUnitTestProject

Following is an example implementation of a unit test in Visual C++ using the native MSTest unit test framework:

image

Support for async and await in VS 2012 and its unit test framework

Windows 8 and .NET 4.5 introduce a major feature that will have a high impact on software development as we know it: Asynchronous Programming. Visual Studio 2012 and its unit test framework support this new approach perfectly. The async and await keywords, available in .NET 4.5, may now be used for creating unit tests of asynchronous methods.

Lets say that you want to create a unit test for the following asynchronous example method:

16-Oct-12 16-49-01

The corresponding NUnit test method could be:

16-Oct-12 17-09-08

In my next blog post I am going to further show you other new features of Visual Studio 2012, which will make your life easier when trying to apply Test Driven Development.


Share/Save/Bookmark

Thursday, October 11, 2012

[Tutorial] Test Driven Development with Visual Studio 2012
Part1: Introduction to TDD

In one of my blog posts series, I showed you how to increase the quality of your code and how to make it much easier to maintain by applying the S.O.L.I.D. principles. I then focused on the Liskov Segregation Principle (LSP) by using Code Contracts in .NET 4.0. This blog series is going to talk about Test Driven Development (TDD) in an Agile environment using the latest Visual Studio 2012 features and how that is going to help you to be more efficient and productive.

The goal of this series will be to show you some of the new features within Visual Studio 2012, that are going to help you when trying to apply the TDD approach. The first parts of the series are more theoretical, while as the last part will be fully practical, since we are going to implement some example code using TDD.

Contrary to traditional software development methodologies and processes, where writing unit test is often done as last step after code implementation, TDD consists of writing unit test upfront as first step in the software development cycle. No development can be started without having implemented the corresponding unit tests. You understand that TDD has large impacts on the organization of your teams.

The following are the different steps when applying Test Driven Development :

image

  1. Write a unit test for a new functionality, then validate that the test fails, since its implementation has not been realized
  2. Implement the minimum code necessary to pass the test, then validate that the test passes successfully, meaning that the expected behavior is now provided by the implementation
  3. Refactor and optimize your code, the unit tests ensure the coherence of the functionalities

Using TDD helps in obtaining a code source that is very reliable, predictable, robust - and after refactoring - highly optimized. Unit tests ensure a correct behavior, independently from where it is going to be used, resulting in a code source that will work as expected under any circumstances.

For being able to create good unit tests, you have at first to think about the conception and software design of your application. You must not hurry into doing your implementations, before being clear about your objectives (which should be true for any development, but sadly often it is not).

Conceptual errors can be detected and resolved much quicker and in a much more efficient way. As explained the implementation is started only after the conceptual phase has been validated and tested via thorough unit tests. In this case, your unit tests become much than just tests. They become some sort of general specification, describing  “units of functionality” for your application.

When refactoring and optimizing your code, you may restructure your code without any risks, since all your modifications are now verifiable. Unit tests ensure that there are no technical or functional regressions and furthermore the coherence of behavior. They validate that your application will always behave in the same way, if they are executed with success.

Additionally if you combine TDD with Extreme Programming (XP) and pair programming, you obtain a code with a very high degree of quality.

The next blog post in the series is going to talk about some the new features in Visual Studio 2012, that allow you to apply TDD quickly and easily, stay tuned!


Share/Save/Bookmark

Monday, October 1, 2012

[Publication] Article in French Programmez Magazine on Window 8 Development and how to build your first application

You can find an article of 3 pages on how to start developing applications for  Windows 8 in the French Programmez magazine No.156 written by Jonathan Pamphile and me.

First Page and Second Page (low resolution)

Third Page (low resolution)

The article is written in French but as always I will write some English articles on my Blog in the next weeks. So stay tuned if you are interested in getting to know how to start programming application for Windows 8 and publish them on the Windows Store.


Share/Save/Bookmark

Monday, September 3, 2012

[Publication] Article in French Programmez Magazine on Test Driven Development with Visual Studio 2012

You can find an article of 4 pages concerning Test Driven Development with Visual Studio 2012 in the French Programmez magazine No.155 written by me and Fathi Bellahcene.

00001

First Page and Second Page (low resolution)

Third Page and fourth Page (low resolution)

The article is written in French but as always I will write some English articles on my Blog in the next weeks. So stay tuned if you are interested in getting to know how to start using Test Driven Development (TDD) with Visual Studio 2012 when building your applications.


Share/Save/Bookmark

Saturday, August 11, 2012

[Certifications] Now ITIL V3 Foundation certified !

Just to let you know that I passed the ITIL V3 Foundation exam lately. I am happy to announce that I am now ITIL V3 certified !

For more information concerning ITIL please consult the official ITIL website of the APMG Group : http://www.itil-officialsite.com/.


Share/Save/Bookmark

Wednesday, August 8, 2012

[VS 2012 - .NET 4.5] Visual Studio 2012 & .NET 4.5 RTM in August

The RTM-versions of Visual Studio 2012, .NET 4.5 and Windows 8 will be available in less than a week on 15 August 2012. This is a very important date for all you developers out there !

image

image

Developers subscribing to MSDN will be able to download the Windows 8 RTM version on August 15. Microsoft announced that Visual Studio 2012 and .NET Framework 4.5 will also be available via MSDN on the same date.

Note that the RTM-versions (release to manufacturing) contains already everything that the final version for the customers will contain ! So from this date on you may validate your applications in a real production environment.

In the meantime download the Release Candidate versions and Release Preview versions and familiarize yourself with all the new features of those products.


Share/Save/Bookmark

Thursday, July 19, 2012

[C# and EF] Tutorial: Entity Framework Code First Migrations 2/2

This second part of the series shows how to activate EF Code First Migrations and either handle them manually in code or – even more interesting - letting EF handle them automatically for you.

Manual Code-based EF Code First Migrations

The first possibility is to handle those changes manually from within your code. Here is how that works.

  • Open the Package Manager Console from the Tools menu within Visual Studio 2012.

image_thumb2

  • Activate the manual EF Migration features by entering the command “Enable-Migrations”.

image_thumb4

  • This adds a new folder Migrations and also the auto-generated classes Configuration.cs  and [SOMEDATE]_InitialCreate.cs to your project.

image_thumb5

  • The Configuration.cs class allows you to configure the EF Code First Migrations options and seed data after migration (very useful for testing purposes during development).

image

  • The other class contains all the code necessary to create the database (Up) and also drop it (Down) if necessary.

image

  • Here is an example of what can be found in the Up() method.

image

  • Here is an example of what can be found in the Down() method.

image

From here you may start to implement you own code in C# for handling EF Code First and database schema changes.

Automatic EF Code First Migrations

Being able to handle database schema changes related to EF Code First changes from C# code is great, you won’t need to be an expert of database development anymore. But you still need to know what to change and you still need to allocate some time for it.

What if there would be a fully automated way of handling those changes without any effort? Well there is and you just have to activate it. Here is how that works.

  • Open the Package Manager Console from the Tools menu within Visual Studio 2012.

image_thumb2

  • Activate the automatic EF Migration features by entering the command “Enable-Migrations -EnableAutomaticMigrations”.
  • If you try that on a project where you have already activated the manual EF Code First features, you just need to delete the Migrations folder first.

image

  • If you look into the Configuration.cs file you will see that the flag to activate automatic migrations is now enabled.

image_thumb7

  • When you now change the EF Code First model as explained in the first post of the series, you may start the automatic migration of the database via the Package Manager console by entering “Update-Database”.

image

  • And you see that the automatic migration was not applied because it would result in data loss. By default it is not allowed to apply automatic migrations if there is data loss implied. This is a security feature to not accidently delete important data from the database. Mind that you may revert back to an old database schema but you won’t get back deleted data!
  • So now it is up to you to either review the changes or allow automatic migrations if there is data loss (really use this with percaution!!).
  • To allow data loss you just set the flag AutomaticMigrationsDataLossAllowed to true in the Configuration constructor.

image

  • When you restart the automatic migration of the database via the Package Manager console by entering “Update-Database” (you may want to add the “–Verbose” flag) you see all the changes that were applied.

image

  • You can now use your application as expected. The modifications in the database reflect the EF Code First model changes.

Share/Save/Bookmark

[C# and EF] Tutorial: Entity Framework Code First Migrations 1/2

I showed you how to use the Entity Framework Code First approach in one of my last blog posts. This approach is very useful if you want to begin with the implementation and there is no database yet. You want to concentrate on the code and not worry about the database at all, therefore letting Entity Framework auto-generate the database for you.

This is especially interesting for developers not having too much experience in database development or in cases where you have to deliver very quickly and you just don’t want to bother with database design.

The problem : Lack of handling Code First model changes in the DB

Code First works very well and is very easy to use. But it lacks an important feature as I have already pointed out in one of my other blog posts – the handling of database schema changes (add/delete/modify columns, add/delete/modify data types, add/delete/modify constraints, etc…) related to EF Code First model changes .

When you change the underlying EF Code First model expressed in your code (via POCO classes for example) and/or its restrictions you either have to re-create the whole database, meaning that all your data gets lost in the process (not acceptable in production use), or code the database changes manually via SQL upgrade scripts.

In this case the developer still needs to have good database development skills and spent time to create, test and execute the upgrade scripts. This is a tedious task, which the new version of Entity Framework 5.0 integrated in .NET 4.5  is going to greatly simplify and automate.

The solution: Code First Migrations

Microsoft heard the customer requests concerning this problem and added what is called Entity Framework Migrations. It is very easy to activate, and though not perfect, serves very well for applying necessary database schema changes if you work with EF Code First.

Let me show you how it works by providing an example in Visual Studio 2012.

  • Create a new project (for the example a console project but you may as well use any other type of project).

image

  • Now do a right click on the project in the Solution Explorer and select to manage the NuGet packages for it.

image

  • In the Nuget packages window search for Entity Framework and select version 5.0 (currently as a release candidate, this won’t be necessary in the future since it will be fully integrated in .NET 4.5).

image

  • This will allow you to use Code First and do an example implementation : a POCO class Person.
  • When you run your application and use the DataContext, the database and all its columns and constraints get automatically generated. Everything works fine and your application works as expected.

image

  • Now you get an application change request and you decide to change the EF Code First model by changing the POCO class.

image

  • But if you try to change the underlying POCO classes of an already generated database and execute your application, you will get the following exception.

image

  • This is the expected behavior since the new EF Code First Migrations features are not activated by default. You have to activate them manually and configure them according to your needs.
  • To do this open the Package Manager Console from the Tools menu within Visual Studio 2012 and activate the EF Code First Migration features from there.

image

In the next part of the series I am going to explain how to activate either the manual or the automatic features of EF Code First Migrations so stay tuned.


Share/Save/Bookmark

Saturday, June 30, 2012

[.NET 4.5] Windows Identity Foundation 4.5 in NET 4.5

Windows Identity Foundation 4.5 (WIF) is a framework for building identity-aware and more specifically claims-aware applications. It furthermore provides an abstraction  to the underlying protocols (ex: WS-Trust, WS-Federation, etc …) and therefore encapsulates and standardizes application security.

Developers do not need to know how to exactly implement and use those protocols anymore. Instead they may use API calls to the WIF Toolkit for implementing secure applications, thus resulting in applications which are loosely coupled to their security implementations. Tokens issued from a large scale of different security providers (including  ADFS 2.0, ACS and custom Security Token Services) can be handled.

The default configuration and behavior works great and with ease you will be able to implement it in no time. But the best of all : the WIF Toolkit is highly customizable. You may completely override and customize the default behavior on some or on all the step of the process (Protocol Module, Session Module, Claims Authorization Module, Token, STS, etc..).

WIF in its first version (1.0) is available as a runtime and as an external SDK for .NET 3.5 and .NET 4.0. You have to install it separately for being able to using it in your applications. The WIF Training Kit contains everything necessary to start with claims based security (explication, tutorials, examples, etc…).

WIF 4.5 and .NET 4.5

So what’s new in WIF 4.5 ? Well first of all WIF is now part of the .NET framework. You do not need to install it manually anymore. It is shipped and installed with .NET 4.5, which means that it is now an integral part of the framework ! Most of the classes and methods are now part of Mscorlib.dll !

Also it is now much easier and straightforward use WIF and to query for claims. Let me show this in the following example.

Create a new web application, right click on your project in the Solution Explorer and select "Identity and Access…” from the list.

ProjectMenu

You will see a new configuration wizard, which will guide you through the process of setting up a STS reference. You may either use a development STS, a business provider based on ADFS2 or Windows Azure Access Control Service (ACS).

For the example I use the development STS :

AuthenticationOptions

You may now run your web application and the development STS gets started automatically. When you see the little icon in the tray area you know that everything working correctly.

LocalSTS

Now lets see how to query for a claim by using the ClaimsPrincipal in the System.Security.Claims namespace and calling its FindFirst(…) method.

ClaimEmail

Where you had to write at least 3 lines of code and do casting operations in WIF 1.0, you now have everything in a single line ! Much easier to implement, to understand, to maintain and also to extend !

Note that there are a variety of other utility methods to aid you in working with claims (FindAll, FindFirst, HasClaim, etc…) and that you have access to almost everything just by using the  ClaimsPrincipal.

Another improvement is the seamless integration of WCF 4.5 and WIF 4.5. You now can use both together much more easily. Custom service host factories or federation behaviors are not needed anymore. This can be achieved via the useIdentityConfiguration switch.

WIF 4.5 and WebFarms

Great news for all developers using WIF in a WebFarms environment (including  Windows Azure). With .NET 4.5 it is finally possible to use WIF without implementing complicated and time consuming workarounds to encrypt your WIF cookies with a single encryption key.

You just configure a new MachineSessionSecurityHandler by setting it in your Web.config file and it will work without any further changes ! This has even been added to the wizard as a checkbox ! How easy is that compared to the old way of resolving this problem !

image

WIF 4.5 and Windows Server 2012

Windows Server 2012 Domain Controllers are going to support the claims based model and provide extra claims via Kerberos (User Claims and Device Claims), which you may then query for within your WIF 4.5 implementations. This is actually a quite interesting feature. I might do another blog post and give  you more details on that in the next weeks.

WIF 4.5 and Visual Studio 2012

The integration of WIF tools has been completely re-designed, as you saw in my quick example above. This has been done to simplify the whole process and to render it much more comprehensive. So it is now easier to understand with less steps and quicker configuration.

As you saw above the new tools contain a local development STS which simulates a real STS (comparable to the development fabric within the Windows Azure SDK). The development STS is by the way completely configurable (Token format, port, test claims, etc..).

Furthermore, the WIF 4.5 tools and all samples are now distributed as VSIX via the Visual Studio Extensions Gallery.

Conclusion

As you can see WIF 4.5 has been greatly enhanced and industrialized. It will become the the primary choice when working with application security. Come on and give it at try,  test all these new features by downloading the Windows Identity Foundation Tools for Visual Studio 2012 RC.


Share/Save/Bookmark