public override string ToString() { ScriptWriter writer = new ScriptWriter(); // write imports at the very top HashSet <string> imports = new HashSet <string>(); CollectImports(ref imports); foreach (string imp in imports) { writer.WriteFullLineFormat("using {0};", imp); } writer.NewLine(); Write(writer); writer.Finish(); return(writer.ToString()); }