Arrays in .NET are curious beasts. They are the only built-in collection types in the CLR, and SZ-arrays (single dimension, zero-indexed) have their own commands and IL syntax. One of their stranger properties is they have a kind of built-in covariance long before generic variance was added in .NET 4. However, this causes a subtle … Read more
In this post we finally get on to how basic generic methods are implemented in IL. First of all, we should briefly cover how a generic method is declared in IL. Declaring a generic method The basic syntax for a generic method is fairly straightfoward. The following C# generic method definition: corresponds to the following … Read more
Next up is a look at the details of callvirt and what happens when you call a virtual method. However, in order to do that, we first need to understand some of the low-level CLR datastructures, and what exactly an object instance is. Object instances Object instances are actually suprisingly small and lightweight things – … Read more
Today, I’ll be starting a new series of blog posts on ‘Subterranean IL’ – a look at the low-level IL commands available to .NET compilers, what each command does (or at least the more interesting commands) and why each command does what it does. One of the first things I’ll be looking at are the … Read more
There can only ever be one Application.ThreadException handler. Yes, you read that correctly. To give some context, the core of our error reporting code in SmartAssembly adds event handlers to AppDomain.CurrentDomain.UnhandledException (for general exceptions) and Application.ThreadException (for winforms exceptions) to display our error reporting dialog, or send the unhandled exception details back to the application … Read more
As some of you may know, executable projects created in Visual Studio 2010 now default to the x86 build target rather than AnyCPU, as was the case in VS2008. I personally am quite annoyed by this decision, and so I looked for ways to change it back. A poke through the VS options screen proved … Read more
Creating a delegate to a method is normally quite a cheap operation. However, there are some reflection-based situations where you have to create a delegate dynamically using Delegate.CreateDelegate. As you can expect, such a method is many times slower than using the type-safe delegate constructor. Using open instance delegates can help alleviate this performance penalty. … Read more
To recap from my previous post, we’re trying to create a class that has the same behaviour as an explicit interface implementation, in which we can change the return type to a more specific type, but for class overrides instead of interface implementations. (Ab)using explicit overrides To implement explicit interface implementations on the CLR, the … Read more
So, C# doesn’t allow us to change the return type when overriding methods. Could we do it in IL? For reference, here is a C# version of the initial example in my previous blog post, and the resulting IL class & method signatures generated by the C# compiler: Attempt 1: Implicit method overrides in IL … Read more
All throughout the EAP and beta versions of Schema Compare for Oracle, our main request was support for Oracle 9i. After releasing version 1.0 with support for 10g and 11g, our next step was then to get version 1.1 of SCfO out with support for 9i. However, there were some significant problems that we had … Read more
My previous blog post went into some detail as to why calling MoveNext on a BCL generic collection enumerator didn’t quite do what you thought it would. This post covers the Reset method. To recap, here’s the simple wrapper around a linked list enumerator struct from my previous post (minus the readonly on the enumerator … Read more
If you’ve ever poked around the .NET class libraries in Reflector, you probably would have noticed that the generic collection classes all have implementations of their IEnumerator as a struct rather than a class. As you will see, this design decision has some rather unfortunate side effects… As is generally known in the .NET world, … Read more
If you’ve emailed us about a bug you’ve encountered with the EAP or beta versions of Schema Compare for Oracle, we probably asked you to send us a query snapshot of your databases. Here, I explain what a query snapshot is, and how it helps us fix your bug. Problem 1: Debugging users’ bug reports … Read more
In developing Schema Compare for Oracle, one of the issues we came across was the size of the databases. As detailed in my last blog post, we had to allow schema pre-filtering due to the number of objects in a standard Oracle database. Unfortunately, this leads to some quite tricky situations regarding object dependencies. This … Read more
SQL Compare is one of Red Gate’s most successful SQL Server tools; it allows developers and DBAs to compare and synchronize the contents of their databases. Although similar tools exist for Oracle, they are quite noticeably lacking in the usability and stability that SQL Compare is known for in the SQL Server world. We could … Read more