"Go shorty its ya birthday!"

by brunofig 30. September 2008 14:26

Today I turn 30! :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Lutz Roeder’s .NET Reflector acquired by Red Gate

by brunofig 26. September 2008 02:46

I've been off somehow to have miss that 5 days ago Red Gate announced the acquisition of the Lutz Roeder’s .NET Reflector. Has my good friend Paulo refers, some improvement can be made in the UI.

These are my suggestions:

  • One of the most annoying things when performing a search in code it that it doesn't highlight;
  • Docking panels, like the ones found on Visual Studio, would also improve usability.

It seems that these, together with Paulo's suggestions would improved greatly the .NET Reflector usability.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software

TIP: Conditional code execution with the ConditionalAttribute and the #IF ... #ENDIF Preprocessor Directive

by brunofig 25. September 2008 17:51

While developing an application, you need to execute some code only when a defined condition is meet, for example, you have a product and you want to have specific code execution for both a release version and a trial version. You could change the code and compile different code for each version, or you could use one (or both) of the following solutions:

  • The ConditionalAttribute indicates that a method is callable if a specified preprocessing identifier is applied to the method.
  • The #IF ... #ENDIF Preprocessor Directive conditionally includes source code at compile-time if a specified preprocessing identifier is defined.

The ConditionalAttribute class

An practical example of the usage of this attribute is the framework itself. The System.Diagnostics.Debug class uses in its methods this attribute so that when you are debugging your assembly, the debugging information is output:

image

 

Let build a simple example:

using System;
using System.Collections.Generic;
using System.Diagnostics;

public class MyConditionalSample
{
    public static void Main()
    {
        Debug.WriteLine("Some debug info!");
        ExecuteIfRelease();
        ExecuteIfDebug();
    }
    
    [Conditional("RELEASE")]
    private static void ExecuteIfRelease()
    {
        Console.WriteLine("Hello world! I'm a release assembly!");
    }
    
    [Conditional("DEBUG")]
    private static void ExecuteIfDebug()
    {
        Console.WriteLine("Hello world! I'm a debug assembly!");
    }
        
}

This is a straight forward example. In the Main method we call the Debug.WriteLine method to output some debug info, and call both ExecuteIfRelease and ExecuteIfDebug methods.

Looking at these methods, notice that they have the Conditional attribute with the conditional compilation symbols RELEASE and DEBUG.

So, on our command line we will first simple compile and execute our code:

image

As you can see, no output was wrote, this because no conditional symbols were defined in our compilation. Let's change our compilation command to include the RELEASE symbol:

image

Now that we added the RELEASE symbol, the runtime now executes our ExecuteIfRelease method.

Changing the symbol to DEBUG will now make the runtime execute the ExecuteIfDebug method and also output our debug message, that we can trace in the DebugView:

image

image

If we look at our compile code in the .NET Reflector we will see that both methods are declared on the code but only the ExecuteIfDebug method is declared on the Main method:

image

#IF ... #ENDIF Preprocessor Directive

The #IF...#ENDIF preprocessor takes this to another level. When using this directive, you are telling the compiler to include/exclude code from the compiled assembly.

So, taking our example and changing it to use instead this directive:

using System;
using System.Collections.Generic;
using System.Diagnostics;

public class MyConditionalSample
{
    public static void Main()
    {
        Debug.WriteLine("Some debug info!");
        #if(RELEASE)
        ExecuteIfRelease();
        #elif(DEBUG)
        ExecuteIfDebug();
        #endif
    }
    
    #if(RELEASE)
    private static void ExecuteIfRelease()
    {
        Console.WriteLine("Hello world! I'm a release assembly!");
    }
    #elif(DEBUG)
    private static void ExecuteIfDebug()
    {
        Console.WriteLine("Hello world! I'm a debug assembly!");
    }
    #endif
        
}

Now let's compile and execute our code using the DEBUG symbol:

image

The code executed has expected, with no visible difference from the prior sample. So what's the catch?

The catch, has told, is in the compiled code itself:

image

Notice that our compiled code doesn't include the ExecuteIfRelease method.

Conclusion

So there you have it. To simple ways of call conditional code. One more thing: although we used the command line compiler to define de conditional symbols, the same can be made using Visual Studio. Simply go to the project's properties, and on the Build tab set your custom compilations symbols, or use the DEBUG and/or TRACE symbols:

image

I would like to say thanks to my good friend Paulo for pointing me into the right direction on this matter.

kick it on DotNetKicks.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | Tips&Tricks

Wish list [Updated]

by brunofig 23. September 2008 20:12

Well, I'm getting old....next Tuesday I turn 30 ("Go, Go, Go Shorty. It's Yo Birthday. We Gonna Sip Bacardi Like It's Yo Birthday"). The big T3. So...for the next year this is my geek wish list:

 

 

[UPDATE]

Seems I forgot some gadgets:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Contact form now working

by brunofig 4. September 2008 02:16
It seems that the email system for the blog wasn't working. I'm using the smtp from google and it seems that one of the available ports is throwing timeouts, so all of you that tried to reach me using the contact form did not succeed. Sorry.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

BlogEngine.NET

Introducing Ubiquity and my contribution to it.

by brunofig 3. September 2008 22:14

The guys at Mozilla Labs released another cool extension for Firefox named Ubiquity. In their own words:"Ubiquity is an experimental Firefox extension that gives you a powerful new way to interact with the Web. You're used to telling Firefox where you want to go by typing Web addresses into the URL bar:2421200474_1bf74ef498_o.png.
With Ubiquity installed, you'll be able to tell Firefox what you want it to do by typing commands into a new Ubiquity input box."

If your are using firefox to see this post, you will notice that on the top there's a notification that this site has Ubiquity commands. This is my test on how easy it is know to create a extension to Firefox. This command allows you to subscribe (using Google Reader) to the feed on the visiting page using the 'subscribeThis' command.

So go on and give it a try!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Client-Side | FF-Extensions

[PT] Procuras um novo desafio profissional?

by brunofig 1. September 2008 19:44

A empresa onde actualmente trabalho anda a procura de recursos para integrar em novos projectos. Procuramos pessoas com perfil Sénior, na vertente web, com  conhecimento profundo de .NET e/ou OutSystems.

Se conhecerem alguém que ande a procura de um novo desafio, agradeço que enviem o seu CV para brun...@reditus.pt.

Para qualquer esclarecimento adicional não hesitem em me contactar.
Obrigado.

O Grupo Reditus desenvolve um conjunto alargado de serviços integrados nas áreas das Tecnologias de Informação, Business Process Outsourcing, Contact Center, Consultoria, Desenvolvimento e Manutenção de Software e Soluções de Engenharia e Mobilidade destinados na sua maioria a médias e grandes empresas tendo, tradicionalmente, uma forte presença no sector financeiro, segurador e das telecomunicações.

A Reditus II – IT Consulting é uma empresa do Grupo Reditus, que actua numa área estratégica de IT Consulting em que a oferta de serviços inclui "Application Management in-site", "Outsourcing Especializado" e "Desenvolvimento Aplicacional", assim como a "Software Factory".

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.7
Theme by Mads Kristensen

About the author

Hi!

My name is Bruno and I'am a senior consultant. When I'm not working, you can catch me playing with my daugther, taking photos and hanging out with my wife and friends. :)

You can also check my dark side or have fun with my vision of the world.

View Bruno Figueiredo's profile on LinkedIn

TwitterCounter for @brunoshine
 
Creative Commons License

 
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
 

Ads

    Page List

      Most comments

      Busby SEO Test Busby SEO Test
      2 comments
      kh Cambodia
      laptop cases laptop cases
      2 comments
      Busby SEO Test Busby SEO Test
      1 comments

      RecentComments

      Comment RSS

      Popuri.us

      My Popularity (by popuri.us)