public static UsingDeclaration add_Using(this CompilationUnit compilationUnit, string @namespace) { @namespace = @namespace.remove(";").trim(); var currentUsingDeclaration = compilationUnit.@using(@namespace); if (currentUsingDeclaration != null) { // these UsingDeclaration & Using classes are a bit of a mess (need to normalize this later) return(new UsingDeclaration(currentUsingDeclaration.wrapOnList())); } var newUsing = new UsingDeclaration(@namespace); compilationUnit.insert(newUsing); return(newUsing); }