Fix mixed newline characters in generated bindings

This commit is contained in:
2025-12-05 15:59:06 +02:00
parent 2d038e4508
commit 0faca0675d

View File

@@ -1487,7 +1487,7 @@ namespace Flax.Build.Bindings
}
contents.AppendLine();
contents.AppendLine(string.Join("\n" + indent, (indent + $$"""
contents.AppendLine(string.Join(Environment.NewLine + indent, (indent + $$"""
/// <summary>
/// Marshaller for type <see cref="{{classInfo.Name}}"/>.
/// </summary>
@@ -1546,7 +1546,7 @@ namespace Flax.Build.Bindings
#pragma warning restore 618
#pragma warning restore 1591
}
""").Split(new char[] { '\n' })));
""").Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)));
}
#endif
// Namespace end
@@ -1824,7 +1824,7 @@ namespace Flax.Build.Bindings
toManagedContent.Append("return managed;");
}
contents.AppendLine(string.Join("\n" + indent, (indent + $$"""
contents.AppendLine(string.Join(Environment.NewLine + indent, (indent + $$"""
/// <summary>
/// Marshaller for type <see cref="{{structureInfo.Name}}"/>.
/// </summary>
@@ -1842,7 +1842,7 @@ namespace Flax.Build.Bindings
{
#pragma warning disable 1591
#pragma warning disable 618
{{structContents.Replace("\n", "\n" + " ").ToString().TrimEnd()}}
{{structContents.Replace("\n", Environment.NewLine + " ").ToString().TrimEnd()}}
{{InsertHideInEditorSection()}}
public static class NativeToManaged
@@ -1851,7 +1851,7 @@ namespace Flax.Build.Bindings
public static {{structureInfo.Name}}Internal ConvertToUnmanaged({{structureInfo.Name}} managed) => {{marshallerFullName}}.ToNative(managed);
public static void Free({{structureInfo.Name}}Internal unmanaged)
{
{{freeContents2.Replace("\n", "\n" + " ").ToString().TrimEnd()}}
{{freeContents2.Replace("\n", Environment.NewLine + " ").ToString().TrimEnd()}}
}
}
{{InsertHideInEditorSection()}}
@@ -1876,21 +1876,21 @@ namespace Flax.Build.Bindings
internal static {{structureInfo.Name}}Internal ConvertToUnmanaged({{structureInfo.Name}} managed) => ToNative(managed);
internal static void Free({{structureInfo.Name}}Internal unmanaged)
{
{{freeContents.Replace("\n", "\n" + " ").ToString().TrimEnd()}}
{{freeContents.Replace("\n", Environment.NewLine + " ").ToString().TrimEnd()}}
}
internal static {{structureInfo.Name}} ToManaged({{structureInfo.Name}}Internal unmanaged)
{
{{toManagedContent.Replace("\n", "\n" + " ").ToString().TrimEnd()}}
{{toManagedContent.Replace("\n", Environment.NewLine + " ").ToString().TrimEnd()}}
}
internal static {{structureInfo.Name}}Internal ToNative({{structureInfo.Name}} managed)
{
{{toNativeContent.Replace("\n", "\n" + " ").ToString().TrimEnd()}}
{{toNativeContent.Replace("\n", Environment.NewLine + " ").ToString().TrimEnd()}}
}
#pragma warning restore 618
#pragma warning restore 1591
}
""").Split(new char[] { '\n' })));
""").Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)));
string InsertHideInEditorSection()
{
@@ -2158,7 +2158,7 @@ namespace Flax.Build.Bindings
{
value = entryInfo.Value;
}
contents.Append(" = ").Append(value);
contents.Append(" = ").Append(value.Trim());
}
// Handle case of next value after Max value being zero if a value is not defined.
else if (string.IsNullOrEmpty(entryInfo.Value) && usedMax)