Are using directives really harmless?
Chapter 1: The changing face of C# development: 1.4.2
Last updated: 1/22/2008
Snippy is a simple beast. It has a set of namespaces configured, and will emit a
using directive for each of them when compiling code. I claim in the book that this is harmless - but is it really?
In the context of Snippy, it's reasonably okay - but it's worth being aware of the consequences of
using directives in C# 3, where they not only introduce types, but also extension methods.
It's fairly easy to come up with examples where the presence or absence of a
using directive can drastically affect behaviour - and it's not obvious that this is the case just from the directive itself. Personally I like to trim unnecessary
using directives wherever I can in real code.