private void GenerateCompileUnitStart(CodeCompileUnit e)
{
if (e.StartDirectives.Count > 0)
{
GenerateDirectives(e.StartDirectives);
}
Output.WriteLine("//------------------------------------------------------------------------------");
Output.Write("// <");
Output.WriteLine(SR.AutoGen_Comment_Line1);
Output.Write("// ");
Output.WriteLine(SR.AutoGen_Comment_Line2);
Output.Write("// ");
Output.Write(SR.AutoGen_Comment_Line3);
Output.WriteLine(Environment.Version.ToString());
Output.WriteLine("//");
Output.Write("// ");
Output.WriteLine(SR.AutoGen_Comment_Line4);
Output.Write("// ");
Output.WriteLine(SR.AutoGen_Comment_Line5);
Output.Write("// </");
Output.WriteLine(SR.AutoGen_Comment_Line1);
Output.WriteLine("//------------------------------------------------------------------------------");
Output.WriteLine();
// CSharp needs to put assembly attributes after using statements.
// Since we need to create a empty namespace even if we don't need it,
// using will generated after assembly attributes.
var importList = new SortedSet<string>(StringComparer.Ordinal);
foreach (CodeNamespace nspace in e.Namespaces)
{
if (string.IsNullOrEmpty(nspace.Name))
{
// mark the namespace to stop it generating its own import list
nspace.UserData["GenerateImports"] = false;
// Collect the unique list of imports
foreach (CodeNamespaceImport import in nspace.Imports)
{
importList.Add(import.Namespace);
}
}
}
// now output the imports
foreach (string import in importList)
{
Output.Write("using ");
OutputIdentifier(import);
Output.WriteLine(';');
}
if (importList.Count > 0)
{
Output.WriteLine();
}
// in C# the best place to put these is at the top level.
if (e.AssemblyCustomAttributes.Count > 0)
{
GenerateAttributes(e.AssemblyCustomAttributes, "assembly: ");
Output.WriteLine();
}
}