The current code generator is using the following to transform generated code to Unix Line Endings:
str.Replace(Environment.NewLine, "\n");
However, on Win systems that have been configured to use Unix style line endings there still seems to be a handful of CRLF codes in the generated files and the above method does not catch them. A better solution would be to simply match against the actual unwanted characters:
str.Replace("\r\n", "\n").Replace("\r", "\n");
This removes any dependency on having the correct system configuration to function as intended. Note: Order or operations matters with the above code.
Wow, never heard
Win systems that have been configured to use Unix style line endings
:)
Thanks for letting me know, I'll update!
I was still getting inconsistent line endings for Generated/ComponentIds.cs on Windows machine. The fix works fine. Since it has been proposed 2 months ago it should have already made into the source by now. Don't you think?
Thanks! Sorry, took a while. Will be in the next release
In windows 10 64 i still had this problem but only the header it was causing.
I resolved thus on file CodeGenerator.cs method "writeFiles" change this:
var header = string.Format(AUTO_GENERATED_HEADER_FORMAT, file.generatorName);
to this:
var header = string.Format(AUTO_GENERATED_HEADER_FORMAT.Replace("\n",Environment.NewLine), file.generatorName);
Sorry my bad english.
@AllanSamurai Thanks!
I don't have a windows 10 machine right now, but you could help me verify if this fixes it:
Can you replace CodeGenerator.writeFiles() method with this code and see if it the issue is fixed?
CodeGenerator.cs
static void writeFiles(string directory, CodeGenFile[] files) {
if(!Directory.Exists(directory)) {
Directory.CreateDirectory(directory);
}
foreach(var file in files) {
var fileName = directory + file.fileName + ".cs";
var header = string.Format(AUTO_GENERATED_HEADER_FORMAT, file.generatorName);
var fileContent = (header + file.fileContent).Replace("\n", Environment.NewLine);
File.WriteAllText(fileName, fileContent);
}
}
Tested on my own project and on Entitas-Shmup project too
it fixes
:D
Thank you!
Awesome, will be in the next release
bb83d990c59266d6605da94a95389195a892a4ec