juin 07

Pour tout savoir sur cet évènement, rendez-vous sur le site dédié de l'évènement : http://www.journeeagile.be  ! Mais en quelques mots :   

Qu'est-ce-que c'est ?

Cette année, et pour la première fois en Wallonie, l'association DotNetHub, a décidé de mettre en place un grand évènement agile francophone.

L'objectif est simple :
Offrir aux spectateurs, en Belgique, et en français, une série de conférences et d'ateliers sur le thème de l'agilité.

Quand et comment cela se passera-t-il ?

L'évènement se passera le 16 Juin 2010 dans le centre TechnoFutur TIC à Gosselies, près de Charleroi, en Belgique.

L'évènement se déroulera de 13h à 19h30 sur deux salles :

  • une salle de conférence de 60/70 personnes
  • une salle de réunion de 20/30 personnes

Les sessions organisées dureront une heure, et seront faites en Français.

Quel est le programme ?

Pour savoir ce que vous pourrez découvrir lors de cet évènement, consultez simplement le programme ici.
Vous pouvez également découvrir une biographie des speakers que vous pourrez rencontrez lors des conférences !

Comment s'inscrire ?

Pour pouvoir participer à cet évènement, rendez-vous sur la page des inscriptions.
L'évènement est payant, et coûte 30€.
Ce prix d'entrée comprend :

  • La participation à l'évènement, à toutes les sessions que vous désirez
  • Un lunch en début d'évènement (sandwichs et boissons)
  • Un en cas en cours d'évènement (viennoiseries et boissons)
Tags: |
févr. 14
Pierre-Emmanuel Dautreppe
Session n°2 à Mons, Jeudi 04 Mars 2010
Conférence par Pierre-Emmanuel Dautreppe de Thales Belgium
Description de la session :

Alors que la sortie officielle de Visual Studio 2010 et du framework 4.0 est prévue pour le 12 Avril 2010, et que le langage arrive avec de nouvelles révolutions, il est temps d'en explorer les améliorations.

Au cours de cette conférence, nous aborderons donc les points suivants :

  • Co & Contra Variance des types génériques
  • Paramètres nommées et optionnels des méthodes
  • Types dynamiques
  • Simplification pour l'interopérabilité COM
  • Améliorations apportées à la BCL (Base Class Library)
    • Découverte de la classe Tuple
    • Quelques améliorations apportées à System.IO
    • Découverte des fichiers mappés en mémoire
    • Introduction à CodeContracts
    • Introduction à PFX (Parallel Framework Extensions)
    • Présentation du type BigInteger
Niveau requis :

La session est ouverte à tous, néanmoins:

  • une connaissance de C# 2.0 ou supérieure est fortement conseillée
  • avoir déjà travaillé avec la réflexion et l'interopérablité COM (excel / word / ...) est un plus pour suivre plus facilement les exemples
A propos de Pierre-Emmanuel Dautreppe :

Pierre-Emmanuel Dautreppe est un des co-fondateurs de DotNetHub.
Pour plus d'informations, rendez-vous sur le la page de présentation des fondateurs de l'association

Lieu de la session :
Adresse Microsoft Innovation Center (1er étage)
Boulevard Initialis, 1
7000 Mons
Horaires La salle sera ouverte à partir de 18h00
La session aura lieu de 18h30 à 20h30
Catering Une collation (sandwichs et boissons) sera proposée en cours de session
Un remerciement tout particulier au Microsoft Innovation Center de nous accueillir pour cette session !

Concours :

Les Tech Days 2010 ont bientôt lieu, et l'équipe de DotNetHub sera sur place avec un stand pour promouvoir son activité.
A cette occasion, nous avons le plaisir d'offrir une entrée aux Tech Days 2010 à l'un d'entre vous !
Un concours sera organisé de façon à choisir le vainqueur !

Tech Days 2010
Tags:
févr. 08

Le 20 Janvier, Jonathan 'Peli' de Halleux était parmi nous pour présenter Stubs, Moles et Pex.

Pour une première session, nous pouvons dire que c'était un succès ! Nous avons mis à jour la page descriptive de l'évènement afin que vous puissiez trouver les photos de l'évènement et les slides de la session.

Continuez à nous suivre et à parler de nous autour de vous !

Tags:
déc. 15

Searching for an english version to have details about this user group ? Go to look on the blog of Steve here

DotNetHub, c’est quoi ?

DotNetHub est un nouveau user group qui vient de voir le jour.
Créé par un groupe de francophones, ce user group a pour vocation l’apprentissage, le partage et l’échange de connaissance en Français autour des technologies .NET et des méthodologies Agile.
Notre objectif ? Parcourir la Wallonie et les terres francophones, pour partager avec vous et dans la langue de Molière les sujets brûlants qui feront de vous et de la Wallonie un partenaire majeur dans le monde informatique d’aujourd’hui.
Ce user group a deux vocations

  • Technique pour la partie .net à destination des développeurs, architectes, chefs de projets, ...
  • Méthodologique pour la partie agile toujours à destination des développeurs et profils techniques, mais également aux décideurs, responsables produits ou tout autre entrepreneur désireux de se lancer dans la création d’un outil informatique

Bref nous nous adressons à tout ceux qui de près ou de loin interragissent avec une équipe informatique et veulent collaborer sur le projet.Nous traiterons de sujets aussi variés que 

  • les langages de développement (C# par exemple)
  • les frameworks existants autour de .NET (Silverlight, ASP.NET MVC, Sync framework, …),
  • l’architecture (SOA, Domain Driven Design, Domain Specific Languages, …) 
  • les pratiques des méthodologies Agiles (eXtreme Programming, …)
  • le pilotage de projet, la gestion des relations client-fournisseur

DotNetHub, c'est qui ?

DotNetHub c'est un groupe de 6 francophones travaillant en .NET et / ou dans les méthodes Agiles depuis de nombreuses années, tous mus par une même passion : apprendre et transmettre !

Mais surtout, DotNetHub, c’est vous !
Vous qui travaillez déjà (ou qui travaillerez demain) en .NET en Agile.
Vous qui voulez apprendre et échanger autour de ces technologies.
Vous, qui viendrez vous connecter au Hub et le faire vivre !

DotNetHub, que proposons-nous ?

DotNetHub c’est beaucoup de choses, mais surtout un portail, des conférences, des dojos et des forums ouverts.

Un portail d’informations :
Sur le site de DotNetHub (http://www.dotnethub.be/), vous pourrez trouver toute une série d’informations via des news, blogging, articles, des supports de conférences ou encore des podcasts.
Ces différentes ressources seront publiées en Français ou en Anglais.

Des conférences :
A intervalle régulier, DotNetHub organisera des conférences traitant de nos différents sujets de prédilection. Ces conférences seront données soit par les membres de DotNetHub, soit par des speakers nationaux et internationaux, mais toujours en Français.
De même qu’un séisme arrive rarement seul, des répliques de ces conférences pourront se propager en Wallonie, à votre demande (Contactez nous sur board@dotnethub.be ?).
Attention, le nombre de place sera limité à chaque conférence.

Des dojos :
En arts martiaux, le dojo est la salle d’entrainement. Et comme la connaissance vient de la pratique, nous organiserons régulièrement des dojos (ou ateliers) où les différents participants mettront en application ensemble une technologie, un framework, …, et ce sous les conseils d’un facilitateur de session. On peut voir ces dojos comme des sessions de travaux dirigés.

Des forums ouverts :
L’association internationale Open Information Foundation a démocratisé les Open Space Discussion : séances de discussion ouvertes dont les participants sont avant tout les acteurs.
Comme nous pensons que le royaume est couvert d’experts (nous, vous, le développeur à côté de vous dont nous n’avions malheureusement pas l’adresse), et que l’on apprend encore plus efficacement avec un vrai retour d’expérience et une discussion à bâtons rompus, nous organiserons également ce type de session.
C’est vous qui pourrez proposer le sujet de ces sessions.

Vous voulez participer ?

Que ce soit comme participant (spectateur), speaker ou encore sponsor, vous êtes les bienvenus ! C'est vous qui ferez vivre DotNetHub. Aller sur notre site ou contactez-nous sur board@dotnethub.be !

Tags:
nov. 19

Introduction

In many scenario, you will want to generate fields in an existing class of an existing assembly. Let's imagine for example that you want to do some lazy loading in your classes. As a consequence, in all of your properties you will have some code checking if your private backing field has already been loaded or not. For that, you will have two solutions : look the nullity of your backing field, or look a boolean variable "hasBeenLoaded". This second solution is the best. Indeed the nullity can be a valid value and retreiving a "null" from your database shall prevent you from doing another get in your database.

Of course, this solution will result in a lots of cumbersome code that you will need to propagate in all of your classes. So you will probably think "aspect" and so use an AOP framework like PostSharp to do all of this plumbing code. You will find many posts on Internet speaking of dealing with LazyLoading functionality in PostSharp, but they usually deal with the nullity of the backing field.

So how can we use PostSharp (I will use the 1.5 version for this example. The version 2.0 of PostSharp will probably simplify this solution) to generate a boolean field ?

This example (that should be seen more like a proof of concept) will probably make you think of many other cases where you will need to generate some code in an existing class. Here we will generate a simple variable in a class, but the code can be easily adapted to generate a field per existing property.

Let's create an aspect

With PostSharp, many high-level aspects already exist and they will be sufficient for many of your scenarios. However for code generation, you will need to go a bit more low level.

So in your project you will need to add a reference to PostSharp.Public (in the GAC) and to PostSharp.Core (that can be found in the installation folder of PostSharp). Now you can create your attribute :

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]

[MulticastAttributeUsage(MulticastTargets.Class, AllowMultiple = false)]

[RequirePostSharp("InjectCodeAttributePlugin", "InjectCodeAttributeTask")]

public class InjectCodeAttribute : MulticastAttribute { }

With the AttributeUsage attribute, I specify that this attribute will target only classes, and the MulticastAttributeUsage attribute tells that only the tagged class will be "aspected" (I could here decide that when I put my attribute on a class, it will get automatically propagated to all properties). I also specify the RequirePostSharp attribute. Indeed as we work low-level, we need to tell PostSharp what to do when seeing this attribute. So in this atribute, we specify the plugin file and the task related to our attribute.

The plugin file can be seen like a configuration file, listing tasks to perform and dependencies between them. Let's see the file we will create in our case. In our attribute, we have specified InjectCodeAttributePlugin, so it means that PostSharp will look for a file named InjectCodeAttributePlugin.psplugin. Let's create such a file in our project:

<?xml version="1.0" encoding="utf-8" ?>

<PlugIn xmlns="http://schemas.postsharp.org/1.0/configuration">

   <SearchPath Directory="bin/{$Configuration}"/>

   <TaskType Name="InjectCodeAttributeTask" 

             Implementation="LowLevelAspect.InjectCodeAttributeTask, LowLevelAspect">

      <Dependency TaskType="CodeWeaver"/>

   </TaskType>

</PlugIn>

What does it say ? Simply that the task InjectCodeAttributeTask (the name we specified in the RequirePostSharp attribute) will be implemented by a class of the same name, in a specific assembly and namespace. We also specify that our task will depend on a task called CodeWeaver. This is an out-of-the-box task of PostSharp that allow us to re-use the current weaver process. It's a best practice for nearly all the low level tasks you will create.

Let's create a task

So what does the task ? In my view, it can be seen as an orchestrator (or provider) of advices. And an advice is the object that will inject (weave) code in our class. Remember that we are doing low level aspects. So when we speak of code, we mean IL code.

Our task is an IAdviceProvider, meaning that it will provide PostSharp with the different advices we want to define (only one in our case : the one responsible for generating a new field). So the task's responsability is limited to two things:

  • As the task knows on which specific member it's weaving (type, method, ...), it can extract everything our advices will need for injection (types, methods, ...)
  • Iterate thru all the attributes (and attribute's targets) we have specified in our code to create the advices. Here is how we deal with that :

internal class InjectCodeAttributeTask : Task, IAdviceProvider

{

   /// <summary>

   /// Initialize the task.

   /// This is where we should extract some types or methods our advices will use

   /// </summary>

   protected override void Initialize()

   {

      base.Initialize();

   }

 

   void IAdviceProvider.ProvideAdvices(Weaver codeWeaver)

   {

      // Gets the dictionary of all custom attributes and more specifically, extract our attribute

      var annotationRepository = AnnotationRepositoryTask.GetTask(this.Project);

      var customAttributeEnumerator

         = annotationRepository.GetAnnotationsOfType(typeof(InjectCodeAttribute), false);

 

      // For each instance of our InjectCodeAttribute

      while ( customAttributeEnumerator.MoveNext() )

      {

         // Gets a reference to the attribute and then the type to which it applies

         // (Remember the MulticastAttributeUsage targets types !)

         InjectCodeAttribute attribute

            = (InjectCodeAttribute)

               CustomAttributeHelper.ConstructRuntimeObject(customAttributeEnumerator.Current.Value,

                                                            this.Project.Module);

         var type = (TypeDefDeclaration)customAttributeEnumerator.Current.TargetElement;

 

         // And we can add our advices

         codeWeaver.AddTypeLevelAdvice(new AddFieldAdvice(this, attribute, type),

                                       JoinPointKinds.AfterInstanceInitialization,

                                       new Singleton<TypeDefDeclaration>(type));

      }

   }

Note that we will complete later on the Initialize method. The JoinPointKinds enum of the AddTypeLevelAdvice is useless in our case. Its goal is to tell PostSharp where we want to inject code in the methods or classes. In our case creating our fields is independant of the existing code so we can be agnostic of the present code and so we just choose one of type-level JoinPointKinds.

So what do we want to generate ? We said a boolean field that can logically be decorated with an attribute CompilerGenerated. This is typically the kind of information we need for the Initialize method. Let's extract these informations.

   internal ITypeSignature SystemBoolean;

   internal IMethod CompilerGeneratedAttributeCtor;

 

   /// <summary>

   /// Initialize the task.

   /// This is where we should extract some types or methods our advices will use

   /// </summary>

   protected override void Initialize()

   {

      base.Initialize();

 

      var module = this.Project.Module;

      //1. Extract the System.Boolean type

      this.SystemBoolean = module.FindType(typeof(bool), BindingOptions.Default);

 

      //2. Extract the constructor (ie the method named ".ctor") of the CompilerGeneratedAttribute

      var compilerGeneratedAttribute = module.FindType(typeof(CompilerGeneratedAttribute), BindingOptions.Default);

      this.CompilerGeneratedAttributeCtor = module.FindMethod(compilerGeneratedAttribute, ".ctor");

   }

Note that for an attribute, we are not interested by the type itself, but by its constructor.

Let's create our advice

So let's go to our advice ! This is the class that will generate the field. This is the easiest part of our job !

internal class AddFieldAdvice : IAdvice

{

   private InjectCodeAttributeTask task;

   private InjectCodeAttribute attribute;

   private TypeDefDeclaration type;

 

   public AddFieldAdvice(InjectCodeAttributeTask task, InjectCodeAttribute attribute, TypeDefDeclaration type)

   {

      this.task = task;

      this.attribute = attribute;

      this.type = type;

   }

 

   int IAdvice.Priority

   {

      get { return this.attribute.AttributePriority; }

   }

 

   bool IAdvice.RequiresWeave(WeavingContext context)

   {

      return true;

   }

 

   void IAdvice.Weave(WeavingContext context, InstructionBlock block)

   {

      //1. Create a new field

      FieldDefDeclaration field = new FieldDefDeclaration();

      field.FieldType = this.task.SystemBoolean;

      field.Name = "HasBeenLoaded";

      field.Attributes = FieldAttributes.Public;

 

      //2. Add the field to the class' fields

      type.Fields.Add(field);

 

      //3. Add the attributes

      //(the field must be added to the class' fields)

      var ctor = this.task.CompilerGeneratedAttributeCtor;

      var compilerGenerated = new CustomAttributeDeclaration(ctor);

      field.CustomAttributes.Add(compilerGenerated);

   }

}

Note that we must add the field to the class' fields before we can add the attribute to our field. Otherwise we would get an exception telling that the field's parent is not known.

Ready to use our attribute !

Our attribute is now finished and we can test it !

So I just create a separate project (our attribute will be typically created in a framework DLL and not in your business DLL) referencing the DLL where my attribute reside and I add a basic class like this one :

[InjectCode]

public class MyAspectedClass { }

and I build it. But it does not work ! I have the following compilation error : Error 2 PostSharp: The plug-in "InjectCodeAttributePlugin" required by the type "LowLevelAspect.InjectCodeAttribute" was not found.
What happen is simple. PostSharp is searching for the file ".psplugin" but it cannot find it. So what to do ? You must know that by default PostSharp knows about the plugin files that are deployed on the machine under the "Plugin" folder (typically in C:\Program Files\PostSharp 1.5\PlugIns). But you can also give him a hint of where to find it. To do so, just edit your project file to add this property :

<PropertyGroup>

   <PostSharpSearchPath>..\LowLevelAspect\bin\Debug</PostSharpSearchPath>

</PropertyGroup>

In my case, LowLevelAspect is the name of the project where I defined my aspect. Note that you could also replace "Debug" with $(Configuration) to target either the Debug or the Release folder depending of the configuration you are building in

For this to work, you need of course to deploy your psplugin file. So you can just update the properties of your file to specify Copy to Ouput Directory : Copy Always.

So let's try again to compile. This time, it's ok !

We can now look to our class in the reflector and here what we get :

public class MyAspectedClass

{

   // Fields

   [CompilerGenerated]

   public bool HasBeenLoaded;

 

   // Methods

   public MyAspectedClass();

}

Pretty cool no ?

Tags: |