Added an analyzer which keeps line breaks LF on every system (#1193)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-11 19:30:00 +01:00
1 parent b1c1f13993
commit 65d50de033
96 files changed
+741 -393

No files matched your search

+21 -21
View File
@@ -658,7 +658,7 @@ public record ChatTemplate(
return true;
var builder = new StringBuilder();
builder.AppendLine("{");
builder.AppendLineLF("{");
for (var i = 0; i < this.ExampleConversation.Count; i++)
{
var block = this.ExampleConversation[i];
@@ -680,10 +680,10 @@ public record ChatTemplate(
return false;
}
builder.AppendLine(" {");
builder.AppendLine($" [\"Role\"] = \"{block.Role}\",");
builder.AppendLine($" [\"Content\"] = {LuaTools.ToLuaStringLiteral(textContent.Text)},");
builder.AppendLine(" },");
builder.AppendLineLF(" {");
builder.AppendLineLF($" [\"Role\"] = \"{block.Role}\",");
builder.AppendLineLF($" [\"Content\"] = {LuaTools.ToLuaStringLiteral(textContent.Text)},");
builder.AppendLineLF(" },");
}
builder.Append(" }");
@@ -693,7 +693,7 @@ public record ChatTemplate(
private static string BuildOptionalStringLua(string fieldName, string? value) => value is null
? string.Empty
: $"{Environment.NewLine} [\"{fieldName}\"] = {LuaTools.ToLuaStringLiteral(value)},";
: $"\n [\"{fieldName}\"] = {LuaTools.ToLuaStringLiteral(value)},";
/// <remarks>
/// An empty set is written out as an empty table rather than being left out: the two say
@@ -706,21 +706,21 @@ public record ChatTemplate(
return string.Empty;
var builder = new StringBuilder();
builder.AppendLine();
builder.AppendLineLF();
if (this.ToolIds.Count == 0)
{
builder.Append(""" ["ToolIds"] = {},""");
return builder.ToString();
}
builder.AppendLine(""" ["ToolIds"] = {""");
builder.AppendLineLF(""" ["ToolIds"] = {""");
//
// A set has no order of its own, so exporting the same template twice would otherwise
// produce two different files. Sorting keeps the plugin diffs readable:
//
foreach (var toolId in this.ToolIds.Order(StringComparer.Ordinal))
builder.AppendLine($" {LuaTools.ToLuaStringLiteral(toolId)},");
builder.AppendLineLF($" {LuaTools.ToLuaStringLiteral(toolId)},");
builder.Append(" },");
return builder.ToString();
@@ -732,22 +732,22 @@ public record ChatTemplate(
return string.Empty;
var builder = new StringBuilder();
builder.AppendLine();
builder.AppendLine(""" ["DataSourceOptions"] = {""");
builder.AppendLine($""" ["DisableDataSources"] = {options.DisableDataSources.ToString().ToLowerInvariant()},""");
builder.AppendLine($""" ["AutomaticDataSourceSelection"] = {options.AutomaticDataSourceSelection.ToString().ToLowerInvariant()},""");
builder.AppendLine($""" ["AutomaticValidation"] = {options.AutomaticValidation.ToString().ToLowerInvariant()},""");
builder.AppendLine($""" ["RetrievalMode"] = "{options.RetrievalMode}",""");
builder.AppendLineLF();
builder.AppendLineLF(""" ["DataSourceOptions"] = {""");
builder.AppendLineLF($""" ["DisableDataSources"] = {options.DisableDataSources.ToString().ToLowerInvariant()},""");
builder.AppendLineLF($""" ["AutomaticDataSourceSelection"] = {options.AutomaticDataSourceSelection.ToString().ToLowerInvariant()},""");
builder.AppendLineLF($""" ["AutomaticValidation"] = {options.AutomaticValidation.ToString().ToLowerInvariant()},""");
builder.AppendLineLF($""" ["RetrievalMode"] = "{options.RetrievalMode}",""");
if (options.PreselectedDataSourceIds.Count == 0)
builder.AppendLine(""" ["PreselectedDataSourceIds"] = {},""");
builder.AppendLineLF(""" ["PreselectedDataSourceIds"] = {},""");
else
{
builder.AppendLine(""" ["PreselectedDataSourceIds"] = {""");
builder.AppendLineLF(""" ["PreselectedDataSourceIds"] = {""");
foreach (var dataSourceId in options.PreselectedDataSourceIds)
builder.AppendLine($" {LuaTools.ToLuaStringLiteral(dataSourceId)},");
builder.AppendLineLF($" {LuaTools.ToLuaStringLiteral(dataSourceId)},");
builder.AppendLine(" },");
builder.AppendLineLF(" },");
}
builder.Append(" },");
@@ -801,9 +801,9 @@ public record ChatTemplate(
return "{}";
var builder = new StringBuilder();
builder.AppendLine("{");
builder.AppendLineLF("{");
foreach (var path in paths)
builder.AppendLine($" \"{LuaTools.EscapeLuaString(path)}\",");
builder.AppendLineLF($" \"{LuaTools.EscapeLuaString(path)}\",");
builder.Append(" }");
return builder.ToString();
@@ -93,6 +93,6 @@ public static class ExportedTokenizerPath
field,
];
return string.Join($"{Environment.NewLine}{indentation}", lines);
return string.Join($"\n{indentation}", lines);
}
}
@@ -346,14 +346,14 @@ public sealed record ProviderCapabilityOverrides
return string.Empty;
var builder = new StringBuilder();
builder.AppendLine($@"{indentation}[""CapabilityOverrides""] = {{");
builder.AppendLineLF($@"{indentation}[""CapabilityOverrides""] = {{");
foreach (var capability in SUPPORTED_CAPABILITIES)
{
var overrideValue = this.GetOverride(capability);
if (overrideValue is null)
continue;
builder.AppendLine($@"{indentation} [""{capability}""] = {overrideValue.Value.ToString().ToLowerInvariant()},");
builder.AppendLineLF($@"{indentation} [""{capability}""] = {overrideValue.Value.ToString().ToLowerInvariant()},");
}
foreach (var key in NUMERIC_KEYS)
@@ -361,7 +361,7 @@ public sealed record ProviderCapabilityOverrides
if (this.GetNumber(key) is not { } number)
continue;
builder.AppendLine($@"{indentation} [""{key}""] = {number.ToString(CultureInfo.InvariantCulture)},");
builder.AppendLineLF($@"{indentation} [""{key}""] = {number.ToString(CultureInfo.InvariantCulture)},");
}
builder.Append($@"{indentation}}},");