Added AutoGenerated header, switched to CodeCompileUnit, added global usings
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Kaitai;
|
||||
|
||||
// ReSharper disable BitwiseOperatorOnEnumWithoutFlags
|
||||
using Kaitai;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.CodeDom;
|
||||
@@ -11,8 +13,6 @@ using System.Text;
|
||||
using Microsoft.CSharp;
|
||||
using BlendFile = Kaitai.BlenderBlend;
|
||||
|
||||
// ReSharper disable BitwiseOperatorOnEnumWithoutFlags
|
||||
|
||||
namespace CodeGenerator {
|
||||
public class Program {
|
||||
public static BlendFile blendfile;
|
||||
@@ -222,14 +222,22 @@ namespace CodeGenerator {
|
||||
};
|
||||
var provider = new CSharpCodeProvider();
|
||||
var date = DateTime.Now.ToString();
|
||||
CodeComment comment = new CodeComment("Automatically generated by BlenderSharp at " + date, false);
|
||||
|
||||
tempNs.Comments.Add(new(comment));
|
||||
CodeNamespace globalNs = new CodeNamespace();
|
||||
CodeComment comment = new CodeComment("Automatically generated by BlenderSharp at " + date, false);
|
||||
globalNs.Comments.Add(new(comment));
|
||||
|
||||
globalNs.Imports.Add(new("System"));
|
||||
globalNs.Imports.Add(new("BlendFile.CompatTypes"));
|
||||
|
||||
CodeCompileUnit ccu = new CodeCompileUnit();
|
||||
ccu.Namespaces.Add(globalNs);
|
||||
ccu.Namespaces.Add(tempNs);
|
||||
foreach (var type in ns.Types.OfType<CodeTypeDeclaration>()) {
|
||||
tempNs.Types.Add(type);
|
||||
Log($"Writing out {(type.IsStruct ? "struct" : "class")} {type.Name}");
|
||||
using var sw = new StreamWriter($"{OutPath}\\{type.Name}.cs");
|
||||
provider.GenerateCodeFromNamespace(tempNs, sw, codeGeneratorOptions);
|
||||
provider.GenerateCodeFromCompileUnit(ccu, sw, codeGeneratorOptions);
|
||||
tempNs.Types.Remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user