Compiler aided overloading

I was playing with xUnit.net for a pet project of mine. I wasn’t writing test cases with xUnit rather I was using the underlying xUnit engine to discover test cases and invoke calls that execute desired test cases. Forget the details of what I was doing, let us talk about it in a different post. But for now, I was consuming xUnit’s backend library.

XunitFrontController is the gateway to xUnit’s world; AFAIK. You create an instance of the controller specifying the target assembly.

var xfc = new XunitFrontController(
  AppDomainSupport.IfAvailable,
  "{full path of the assembly where the test cases reside}"
);

Continue reading Compiler aided overloading

Advertisements

JINQ

In his talk at the CppCon 2014, Bjarne Stroustrup explained, politely and brilliantly, how to write succinct expressive yet intent-ful code. The task is especially hard when there are parties interested in trolling1 rather than contributing. Like Stroustrup explains back, it is difficult to find the real meaning out of a large block of (legacy) code.

Continue reading JINQ

.NET for the next generation

It was about a decade ago when Visual Studio .NET 2002 was launched. Having worked with Visual Studio 6 until then, the new interface was refreshing and powerful along with .NET and the suite of languages, tools and technologies. If you were there, you would have felt times were changing. Beyond the cool and modern interface, Visual Studio .NET 2002 had a lot more to offer compared to Visual Studio 6 — .NET. It was an exciting time for me back then.

Continue reading .NET for the next generation

Mutating Strings

Today, we question our beliefs! Is string really immutable?

string message = "Hello World!";

Console.WriteLine(message);        // Prints "Hello World!"

unsafe {  
    int length = message.Length;

    fixed (char *p = message) {
        for (int index = 0; index < length; ++index) {
            *(p + index) = '?';
        }
    }
}

Console.WriteLine(message);     // Prints what? See for yourself!

Continue reading Mutating Strings

.NET Reflection Extravanganza !!!

Over the past few weeks, I have been involved with this module that got the best of both worlds – .NET and I, 😁.

Ok, this was the problem. We have a COM server, let us name it Server. I had to write an assembly in C#, let us call it Bridge, that will listen to all of the events fired by the Server and perform an action Action. To keep that Action simple, let us assume we have to log them to the database. But the Server fires hundreds of events, and it is not wise to write up static event handlers for all of them. Also, if more events are (ever) added in the future, the Bridge should be able to support it without code changes.

The twist in the game was that this was an brown + green field development project. That demanded a wise solution – learn from the past and better the future.

Continue reading .NET Reflection Extravanganza !!!