Output: Write preamble comment at top of code output

This commit is contained in:
Katy Coe
2019-11-12 21:05:37 +01:00
parent 3b6dee36ba
commit 144380c6d3

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2019 Katy Coe - https://www.djkaty.com - https://github.com/djkaty // Copyright (c) 2017-2019 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
// All rights reserved // All rights reserved
using System; using System;
@@ -34,8 +34,6 @@ namespace Il2CppInspector
private void writeFile(string outFile, IEnumerable<TypeInfo> types) { private void writeFile(string outFile, IEnumerable<TypeInfo> types) {
using StreamWriter writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8);
var nsRefs = new HashSet<string>(); var nsRefs = new HashSet<string>();
var code = new StringBuilder(); var code = new StringBuilder();
@@ -75,6 +73,16 @@ namespace Il2CppInspector
// Determine using directives (put System namespaces first) // Determine using directives (put System namespaces first)
var usings = nsRefs.OrderBy(n => (n.StartsWith("System.") || n == "System") ? "0" + n : "1" + n); var usings = nsRefs.OrderBy(n => (n.StartsWith("System.") || n == "System") ? "0" + n : "1" + n);
// Create output file
using StreamWriter writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8);
// Write preamble
writer.Write(@"/*
* Generated code file by Il2CppInspector - http://www.djkaty.com - https://github.com/djkaty
*/
");
// Output using directives // Output using directives
writer.Write(string.Concat(usings.Select(n => $"using {n};\n"))); writer.Write(string.Concat(usings.Select(n => $"using {n};\n")));
if (nsRefs.Any()) if (nsRefs.Any())