Unisce origin/main (audio, ere e obsolescenza, scheda dell'industria e schermata di connessione) e corregge i rilievi della revisione del tutorial (ADR 0023 aggiornato). - Chiave dell'avanzamento senza l'impronta del terreno, che il server ricalcola e che cambia giocando (città, industrie): origine della partita, seme, lato, anno d'inizio, regione e compagnia. Un tutorial ripreso dopo un anno di gioco ritrova la sua voce. - «Tutorial» apre una partita locale di prova sempre nuova in user://tutorial-server invece di riprendere l'autosalvataggio del giocatore e rifare il tutorial lì dentro; con salvataggi locali già presenti la casella «Mostra il tutorial» parte spenta. Casella e pulsante passano nella nuova ConnectScreen (MenuScreen non c'è più). - La casella spuntata vale anche su una voce chiusa o completata (stesso seme di una partita vecchia). - Contorno ritagliato dai contenitori a scorrimento, con l'elemento portato in vista; del tutto nascosto si usa il ripiego. - Pulsanti del riquadro senza fuoco: Invio e spazio restano alla partita (Costruisci, pausa) e non saltano il passo. - La base di «increase» è presa al completamento del passo precedente e gli esiti dei comandi si valutano subito: un binario costruito appena dopo conta per il passo nuovo. - Velocità contata solo dalle richieste di questo client. - Copione mancante o non valido segnalato nella partita; validazione dei null ammessi dal JSON. - Test: chiave stabile con impronta diversa, base al completamento, piano con la casella, null nel copione. 228 test (208 senza i lenti). Refs #45. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
347 lines
20 KiB
C#
347 lines
20 KiB
C#
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using RailEnterprise.Client.Tutorial;
|
|
using RailEnterprise.Core.Commands;
|
|
using RailEnterprise.Protocol.Messages;
|
|
using RailEnterprise.Tests.Harness;
|
|
|
|
namespace RailEnterprise.Tests.Client;
|
|
|
|
/// <summary>Tutorial guidato del client (F6, issue #45, ADR 0023): copione, condizioni, macchina a stati, avanzamento salvato.</summary>
|
|
public static class TutorialTests
|
|
{
|
|
private static string ClientDir()
|
|
{
|
|
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (dir is not null)
|
|
{
|
|
string candidate = Path.Combine(dir.FullName, "client", "RailEnterprise.Client");
|
|
if (File.Exists(Path.Combine(candidate, "project.godot"))) return candidate;
|
|
dir = dir.Parent;
|
|
}
|
|
throw new DirectoryNotFoundException("Cartella del client non trovata");
|
|
}
|
|
|
|
private static TutorialScript RealScript() =>
|
|
TutorialScript.Parse(File.ReadAllText(Path.Combine(ClientDir(), "assets", "tutorial", "tutorial.json")));
|
|
|
|
private static TutorialStep Step(string id, TutorialCondition? done = null, string? highlight = null) =>
|
|
new() { Id = id, Title = "Titolo " + id, Text = "Testo " + id, Done = done, Highlight = highlight };
|
|
|
|
private static TutorialFacts Facts(string panel = TutorialFacts.NoPanel, params (string Counter, double Value)[] counters)
|
|
{
|
|
var f = new TutorialFacts { Panel = panel };
|
|
foreach (var (c, v) in counters) f.Set(c, v);
|
|
return f;
|
|
}
|
|
|
|
[Test(Description = "Il copione reale è valido e copre la sequenza minima della prima partita")]
|
|
public static void RealScriptIsValidAndComplete()
|
|
{
|
|
var script = RealScript();
|
|
var errors = script.Validate();
|
|
Assert.True(errors.Count == 0, string.Join("; ", errors));
|
|
string[] required =
|
|
[
|
|
"welcome", "map", "time", "stations", "depot", "track-tool", "track-profile", "track-build", "construction",
|
|
"locomotive", "cars", "compose", "line", "assign", "market", "finance", "climb", "tips",
|
|
];
|
|
int last = -1;
|
|
foreach (string id in required)
|
|
{
|
|
int i = script.IndexOf(id);
|
|
Assert.True(i > last, $"passo «{id}» mancante o fuori ordine");
|
|
last = i;
|
|
}
|
|
Assert.True(script.Steps[0].IsInformative, "si apre con un passo informativo");
|
|
Assert.True(script.Steps[^1].IsInformative, "si chiude con i consigli (informativo)");
|
|
// il profilo si guarda prima di costruire, e i pannelli finali si aprono davvero
|
|
Assert.Equal("track", script.Steps[script.IndexOf("track-tool")].Done!.Panel);
|
|
foreach (string panel in new[] { "market", "finance", "climb" })
|
|
Assert.Equal(panel, script.Steps[script.IndexOf(panel)].Done!.Panel);
|
|
}
|
|
|
|
[Test(Description = "Titoli, testi e scritte del tutorial hanno la riga in strings.csv con l'inglese")]
|
|
public static void TextsAreTranslated()
|
|
{
|
|
var rows = ReadCsv(Path.Combine(ClientDir(), "assets", "i18n", "strings.csv"));
|
|
var keys = new List<string>();
|
|
foreach (var s in RealScript().Steps) keys.AddRange([s.Title, s.Text]);
|
|
keys.AddRange(["Avanti", "Salta passo", "Chiudi tutorial", "Tutorial", "Passo {0} di {1}", "Fine", "Fatto", "Mostra il tutorial",
|
|
"Tutorial non disponibile: {0}", "Nuova partita locale di prova con il tutorial dal primo passo: la tua partita locale resta com'è"]);
|
|
foreach (string key in keys)
|
|
{
|
|
Assert.True(rows.TryGetValue(key, out var row), $"manca in strings.csv: «{key}»");
|
|
Assert.True(row!.Length >= 3 && row[1].Length == 0 && row[2].Trim().Length > 0, $"riga senza inglese o con l'italiano non vuoto: «{key}»");
|
|
}
|
|
}
|
|
|
|
[Test(Description = "I pannelli noti al tutorial sono gli strumenti della barra (enum Tool del client)")]
|
|
public static void PanelsMatchToolbar()
|
|
{
|
|
string toolbar = File.ReadAllText(Path.Combine(ClientDir(), "scripts", "Hud", "Toolbar.cs"));
|
|
var m = Regex.Match(toolbar, @"public enum Tool\s*\{([^}]*)\}");
|
|
Assert.True(m.Success, "enum Tool non trovato");
|
|
var tools = m.Groups[1].Value.Split(',').Select(t => t.Trim().ToLowerInvariant()).Where(t => t.Length > 0).ToList();
|
|
Assert.SequenceEqual(tools, TutorialFacts.KnownPanels);
|
|
// e GameScreen risolve ogni elemento che non sia un pulsante della barra
|
|
string screen = File.ReadAllText(Path.Combine(ClientDir(), "scripts", "Screens", "GameScreen.cs"));
|
|
foreach (string target in TutorialScript.KnownTargets.Where(t => !t.StartsWith("toolbar:", StringComparison.Ordinal)))
|
|
Assert.True(screen.Contains($"\"{target}\" =>"), $"GameScreen.TutorialTarget non risolve «{target}»");
|
|
}
|
|
|
|
[Test(Description = "Contatori assoluti, aumenti dall'inizio del passo, pannello aperto, tutte e almeno una")]
|
|
public static void ConditionsUseFactsAndBaseline()
|
|
{
|
|
var empty = Facts();
|
|
var atLeast = new TutorialCondition { Counter = "stations", AtLeast = 2 };
|
|
Assert.False(atLeast.IsMet(Facts(counters: ("stations", 1)), empty));
|
|
Assert.True(atLeast.IsMet(Facts(counters: ("stations", 2)), empty));
|
|
|
|
var atMost = new TutorialCondition { Counter = "edgesBuilding", AtMost = 0 };
|
|
Assert.True(atMost.IsMet(empty, empty), "un contatore mai visto vale zero");
|
|
Assert.False(atMost.IsMet(Facts(counters: ("edgesBuilding", 1)), empty));
|
|
|
|
var increase = new TutorialCondition { Counter = "cmd:BuildTrack", Increase = 1 };
|
|
var baseline = Facts(counters: ("cmd:BuildTrack", 3));
|
|
Assert.False(increase.IsMet(Facts(counters: ("cmd:BuildTrack", 3)), baseline), "i binari costruiti prima del passo non contano");
|
|
Assert.True(increase.IsMet(Facts(counters: ("cmd:BuildTrack", 4)), baseline));
|
|
|
|
var panel = new TutorialCondition { Panel = "market" };
|
|
Assert.True(panel.IsMet(Facts("market"), empty));
|
|
Assert.False(panel.IsMet(Facts("finance"), empty));
|
|
|
|
var all = new TutorialCondition { All = [atLeast, panel] };
|
|
var any = new TutorialCondition { Any = [atLeast, panel] };
|
|
Assert.False(all.IsMet(Facts("market"), empty));
|
|
Assert.True(any.IsMet(Facts("market"), empty));
|
|
Assert.True(all.IsMet(Facts("market", ("stations", 2)), empty));
|
|
}
|
|
|
|
[Test(Description = "La macchina avanza sulle condizioni, Avanti sui passi informativi, Salta e Chiudi")]
|
|
public static void MachineAdvancesSkipsAndCloses()
|
|
{
|
|
var script = new TutorialScript
|
|
{
|
|
Steps =
|
|
[
|
|
Step("intro"),
|
|
Step("pan", new TutorialCondition { Counter = "mapPan", Increase = 0.5 }),
|
|
Step("stations", new TutorialCondition { Counter = "stations", AtLeast = 2 }),
|
|
Step("end"),
|
|
],
|
|
};
|
|
var m = new TutorialMachine(script);
|
|
Assert.Equal("intro", m.Current!.Id);
|
|
Assert.False(m.Update(Facts()), "un passo informativo non si completa da solo");
|
|
m.Next();
|
|
Assert.Equal("pan", m.Current!.Id);
|
|
|
|
// la base del passo è il primo aggiornamento: lo spostamento già fatto non conta
|
|
Assert.False(m.Update(Facts(counters: ("mapPan", 2))));
|
|
Assert.False(m.Update(Facts(counters: ("mapPan", 2.3))));
|
|
Assert.True(m.Update(Facts(counters: ("mapPan", 2.6))));
|
|
Assert.Equal("stations", m.Current!.Id);
|
|
Assert.Equal(new TutorialProgress("stations", TutorialStatus.Active), m.Progress);
|
|
|
|
m.Skip();
|
|
Assert.Equal("end", m.Current!.Id);
|
|
Assert.True(m.IsLast);
|
|
m.Next();
|
|
Assert.Equal(TutorialStatus.Completed, m.Status);
|
|
Assert.Equal(null, m.Current);
|
|
Assert.False(m.Update(Facts()));
|
|
|
|
m.Restart();
|
|
Assert.Equal("intro", m.Current!.Id);
|
|
m.Close();
|
|
Assert.Equal(TutorialStatus.Closed, m.Status);
|
|
Assert.Equal("closed", m.Progress.Encode());
|
|
m.Next();
|
|
Assert.Equal(TutorialStatus.Closed, m.Status, "chiuso, Avanti non fa nulla");
|
|
}
|
|
|
|
[Test(Description = "Avanzamento salvato: codifica, ripresa, passo sparito, piano di apertura")]
|
|
public static void ProgressRoundTripAndLaunchPlan()
|
|
{
|
|
foreach (var p in new[] { new TutorialProgress("depot", TutorialStatus.Active), new TutorialProgress(null, TutorialStatus.Completed), new TutorialProgress(null, TutorialStatus.Closed) })
|
|
Assert.Equal(p, TutorialProgress.Decode(p.Encode()));
|
|
Assert.Equal(null, TutorialProgress.Decode(""));
|
|
Assert.Equal(null, TutorialProgress.Decode("boh"));
|
|
|
|
var script = RealScript();
|
|
var m = new TutorialMachine(script);
|
|
m.Restore(new TutorialProgress("line", TutorialStatus.Active));
|
|
Assert.Equal("line", m.Current!.Id);
|
|
m.Restore(new TutorialProgress("passo-che-non-esiste-piu", TutorialStatus.Active));
|
|
Assert.Equal(script.Steps[0].Id, m.Current!.Id);
|
|
m.Restore(new TutorialProgress(null, TutorialStatus.Completed));
|
|
Assert.Equal(TutorialStatus.Completed, m.Status);
|
|
|
|
var active = new TutorialProgress("depot", TutorialStatus.Active);
|
|
var closed = new TutorialProgress(null, TutorialStatus.Closed);
|
|
Assert.Equal(TutorialLaunch.StartFresh, TutorialMachine.Plan(requested: true, restart: false, saved: null));
|
|
Assert.Equal(TutorialLaunch.Hidden, TutorialMachine.Plan(requested: false, restart: false, saved: null));
|
|
Assert.Equal(TutorialLaunch.Resume, TutorialMachine.Plan(requested: false, restart: false, saved: active));
|
|
var completed = new TutorialProgress(null, TutorialStatus.Completed);
|
|
Assert.Equal(TutorialLaunch.Hidden, TutorialMachine.Plan(requested: false, restart: false, saved: closed), "chiuso e non richiesto: nascosto");
|
|
Assert.Equal(TutorialLaunch.Hidden, TutorialMachine.Plan(requested: false, restart: false, saved: completed));
|
|
// la casella spuntata è una richiesta esplicita: vale anche su una voce chiusa (partita nuova con lo stesso seme)
|
|
Assert.Equal(TutorialLaunch.StartFresh, TutorialMachine.Plan(requested: true, restart: false, saved: closed));
|
|
Assert.Equal(TutorialLaunch.StartFresh, TutorialMachine.Plan(requested: true, restart: false, saved: completed));
|
|
Assert.Equal(TutorialLaunch.Resume, TutorialMachine.Plan(requested: true, restart: false, saved: active), "in corso: si riprende");
|
|
Assert.Equal(TutorialLaunch.StartFresh, TutorialMachine.Plan(requested: false, restart: true, saved: closed));
|
|
Assert.Equal(TutorialLaunch.StartFresh, TutorialMachine.Plan(requested: false, restart: true, saved: active));
|
|
}
|
|
|
|
[Test(Description = "La chiave della partita non cambia giocando (impronta del terreno, data) e separa le origini")]
|
|
public static void GameKeyIsStableDuringTheGame()
|
|
{
|
|
var start = new WorldSummary { Seed = 1, SizeKm = 128, StartYear = 1850, RegionId = "pianura-padana", CompanyId = 0, TerrainHash = 0x1111, Tick = 0, Date = "1850-01-01" };
|
|
// un anno dopo: le città si sono allargate (impronta del terreno nuova) e la data è avanzata
|
|
var later = new WorldSummary { Seed = 1, SizeKm = 128, StartYear = 1850, RegionId = "pianura-padana", CompanyId = 0, TerrainHash = 0x2222, Tick = 2_000_000, Date = "1851-03-01" };
|
|
string key = TutorialProgress.GameKey("local", start);
|
|
Assert.Equal(key, TutorialProgress.GameKey("local", later), "stessa partita dopo un anno di gioco: stessa voce");
|
|
Assert.True(key.All(c => char.IsAsciiLetterOrDigit(c) || c == '_'), $"chiave adatta a ConfigFile: {key}");
|
|
Assert.Equal(key, key.ToLowerInvariant());
|
|
|
|
Assert.NotEqual(key, TutorialProgress.GameKey("tutorial", start), "la partita di prova del tutorial ha la sua voce");
|
|
Assert.NotEqual(key, TutorialProgress.GameKey("remote_192.168.1.5_7400", start), "un server remoto ha la sua voce");
|
|
Assert.NotEqual(key, TutorialProgress.GameKey("local", new WorldSummary { Seed = 2, SizeKm = 128, StartYear = 1850, RegionId = "pianura-padana" }));
|
|
Assert.NotEqual(key, TutorialProgress.GameKey("local", new WorldSummary { Seed = 1, SizeKm = 128, StartYear = 1850, RegionId = "pianura-padana", CompanyId = 2 }));
|
|
string remote = TutorialProgress.GameKey("remote_192.168.1.5_7400", start);
|
|
Assert.True(remote.All(c => char.IsAsciiLetterOrDigit(c) || c == '_'), $"chiave adatta a ConfigFile: {remote}");
|
|
}
|
|
|
|
[Test(Description = "Un comando riuscito subito dopo il completamento di un passo conta per il passo nuovo")]
|
|
public static void BaselineIsTakenWhenThePreviousStepCompletes()
|
|
{
|
|
var build = new TutorialCondition { Counter = "cmd:BuildTrack", Increase = 1 };
|
|
var script = new TutorialScript
|
|
{
|
|
Steps =
|
|
[
|
|
Step("profile", new TutorialCondition { Counter = "trackPreviews", Increase = 1 }),
|
|
Step("build", build),
|
|
Step("link", build),
|
|
Step("end"),
|
|
],
|
|
};
|
|
var m = new TutorialMachine(script);
|
|
Assert.False(m.Update(Facts(counters: ("trackPreviews", 0))));
|
|
Assert.True(m.Update(Facts(counters: ("trackPreviews", 1))));
|
|
Assert.Equal("build", m.Current!.Id);
|
|
// il binario costruito arriva prima del prossimo aggiornamento: conta per «build»
|
|
Assert.True(m.Update(Facts(counters: [("trackPreviews", 1), ("cmd:BuildTrack", 1)])), "il primo binario completa «build»");
|
|
Assert.Equal("link", m.Current!.Id);
|
|
// gli stessi fatti non completano anche «link»
|
|
Assert.False(m.Update(Facts(counters: [("trackPreviews", 1), ("cmd:BuildTrack", 1)])));
|
|
Assert.True(m.Update(Facts(counters: [("trackPreviews", 1), ("cmd:BuildTrack", 2)])), "il secondo binario completa «link»");
|
|
Assert.Equal("end", m.Current!.Id);
|
|
|
|
// dopo Salta passo la base resta il primo aggiornamento del passo
|
|
m.Restart();
|
|
m.Skip();
|
|
Assert.False(m.Update(Facts(counters: ("cmd:BuildTrack", 5))));
|
|
Assert.True(m.Update(Facts(counters: ("cmd:BuildTrack", 6))));
|
|
}
|
|
|
|
[Test(Description = "La validazione rifiuta copioni sbagliati e il parser i campi sconosciuti")]
|
|
public static void ValidationRejectsBadScripts()
|
|
{
|
|
static List<string> Errors(params TutorialStep[] steps) => new TutorialScript { Steps = [.. steps] }.Validate();
|
|
|
|
Assert.True(Errors(Step("a"), Step("a")).Exists(e => e.Contains("ripetuto")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Counter = "binari", AtLeast = 1 })).Exists(e => e.Contains("contatore sconosciuto")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Counter = "cmd:Teletrasporto", Increase = 1 })).Exists(e => e.Contains("contatore sconosciuto")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Counter = "cmd:5", Increase = 1 })).Exists(e => e.Contains("contatore sconosciuto")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Counter = "stations" })).Exists(e => e.Contains("senza atLeast")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Panel = "cucina" })).Exists(e => e.Contains("pannello sconosciuto")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { Panel = "market", Counter = "stations", AtLeast = 1 })).Exists(e => e.Contains("una sola forma")));
|
|
Assert.True(Errors(Step("a", new TutorialCondition { All = [] })).Exists(e => e.Contains("vuoto")));
|
|
Assert.True(Errors(Step("a", highlight: "toolbar:cucina")).Exists(e => e.Contains("evidenziare sconosciuto")));
|
|
Assert.True(Errors().Exists(e => e.Contains("nessun passo")));
|
|
// valori null ammessi dal JSON: errori chiari, nessuna eccezione
|
|
Assert.True(TutorialScript.Parse("""{ "steps": null }""").Validate().Exists(e => e.Contains("elenco dei passi mancante")));
|
|
Assert.True(TutorialScript.Parse("""{ "steps": [ null ] }""").Validate().Exists(e => e.Contains("passo n. 1 nullo")));
|
|
Assert.True(TutorialScript.Parse("""{ "steps": [ { "id": "a", "title": "t", "text": "x", "done": { "all": [ null ] } } ] }""").Validate().Exists(e => e.Contains("condizione nulla")));
|
|
Assert.True(TutorialScript.Parse("""{ "steps": [ { "id": "a", "title": "t", "text": "x", "done": { "any": [ null ] } } ] }""").Validate().Exists(e => e.Contains("condizione nulla")));
|
|
Assert.Equal(0, Errors(Step("a", new TutorialCondition { Counter = TutorialFacts.CommandCounter(CommandType.BuildStation), Increase = 1 }, "toolbar:station")).Count);
|
|
|
|
Assert.Throws<System.Text.Json.JsonException>(() => TutorialScript.Parse("""{ "steps": [ { "id": "a", "title": "t", "text": "x", "colore": "rosso" } ] }"""));
|
|
Assert.Throws<System.Text.Json.JsonException>(() => TutorialScript.Parse("""{ "steps": [ { "id": "a", "text": "x" } ] }"""));
|
|
}
|
|
|
|
[Test(Description = "Una prima partita simulata con fatti plausibili percorre tutto il copione reale")]
|
|
public static void FirstGameWalksTheWholeScript()
|
|
{
|
|
var script = RealScript();
|
|
var m = new TutorialMachine(script);
|
|
var f = new TutorialFacts();
|
|
int guard = 0;
|
|
void Tick() => m.Update(f);
|
|
|
|
while (m.Status == TutorialStatus.Active && guard++ < 200)
|
|
{
|
|
var step = m.Current!;
|
|
Tick();
|
|
if (step.IsInformative)
|
|
{
|
|
m.Next();
|
|
continue;
|
|
}
|
|
// il giocatore fa ciò che il passo chiede; il client osserva soltanto gli effetti
|
|
switch (step.Id)
|
|
{
|
|
case "map": f.Add("mapPan", 0.8); f.Add("mapZoom", 0.6); break;
|
|
case "time": f.Add("speedChanges", 1); break;
|
|
case "stations": f.Add(TutorialFacts.CommandCounter(CommandType.BuildStation), 2); f.Set("stations", 2); break;
|
|
case "depot": f.Set("depots", 1); break;
|
|
case "track-tool": f.Panel = "track"; break;
|
|
case "track-profile": f.Add("trackPreviews", 12); break;
|
|
case "track-build" or "depot-link": f.Add(TutorialFacts.CommandCounter(CommandType.BuildTrack), 1); f.Add("edges", 1); f.Add("edgesBuilding", 1); break;
|
|
case "construction": f.Set("edgesBuilding", 0); f.Set("edgesActive", f.Get("edges")); break;
|
|
case "locomotive": f.Panel = "trains"; f.Set("locomotives", 1); break;
|
|
case "cars": f.Set("cars", 3); break;
|
|
case "compose": f.Set("trains", 1); break;
|
|
case "line": f.Panel = "lines"; f.Set("lines", 1); break;
|
|
case "assign": f.Panel = "trains"; f.Set("trainsOnLine", 1); break;
|
|
default: f.Panel = step.Done!.Panel ?? f.Panel; break;
|
|
}
|
|
int before = m.Index;
|
|
Tick();
|
|
Assert.True(m.Index == before + 1 || m.Status != TutorialStatus.Active, $"il passo «{step.Id}» non si è completato");
|
|
}
|
|
Assert.Equal(TutorialStatus.Completed, m.Status);
|
|
}
|
|
|
|
/// <summary>CSV minimo (virgolette doppie, virgole tra virgolette), come lo legge Godot.</summary>
|
|
private static Dictionary<string, string[]> ReadCsv(string path)
|
|
{
|
|
var rows = new Dictionary<string, string[]>(StringComparer.Ordinal);
|
|
foreach (string line in File.ReadAllLines(path, Encoding.UTF8).Skip(1))
|
|
{
|
|
if (line.Length == 0) continue;
|
|
var fields = new List<string>();
|
|
var sb = new StringBuilder();
|
|
bool quoted = false;
|
|
for (int i = 0; i < line.Length; i++)
|
|
{
|
|
char c = line[i];
|
|
if (quoted)
|
|
{
|
|
if (c == '"' && i + 1 < line.Length && line[i + 1] == '"') { sb.Append('"'); i++; }
|
|
else if (c == '"') quoted = false;
|
|
else sb.Append(c);
|
|
}
|
|
else if (c == '"') quoted = true;
|
|
else if (c == ',') { fields.Add(sb.ToString()); sb.Clear(); }
|
|
else sb.Append(c);
|
|
}
|
|
fields.Add(sb.ToString());
|
|
rows[fields[0]] = [.. fields];
|
|
}
|
|
return rows;
|
|
}
|
|
}
|