Stufe 4c (#764): Bezeichner auf Englisch - Typen, Methoden, Felder, Parameter, Locals, Testnamen
Mit Roslyn umbenannt (Verweise folgen, Zeichenketten bleiben unberuehrt). Nicht umbenannt, weil gespeichert oder ueber die API gebunden (Stufe 4e): Properties, Record-Parameter, Enum-Member sowie die Parameter der Endpunkt-Handler (Routen-/Query-Bindung ueber den Namen). Die JSON-Felder anonymer Objekte bleiben ausdruecklich benannt (JsonFilter: pfad). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
837a634a22
commit
77062facc9
@@ -36,7 +36,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
|
||||
[Fact]
|
||||
public void Inhalt_wird_geschrieben()
|
||||
public void Content_is_written()
|
||||
{
|
||||
var path = Path_("datei.json");
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Eine_bestehende_Datei_wird_ersetzt()
|
||||
public void An_existing_file_is_replaced()
|
||||
{
|
||||
var path = Path_("datei.json");
|
||||
File.WriteAllText(path, "alter Inhalt der deutlich laenger ist");
|
||||
@@ -57,7 +57,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fehlende_Verzeichnisse_werden_angelegt()
|
||||
public void Missing_directories_are_created()
|
||||
{
|
||||
var path = Path_(Path.Combine("a", "b", "c", "datei.json"));
|
||||
|
||||
@@ -67,7 +67,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Es_bleiben_keine_Nebendateien_zurueck()
|
||||
public void No_side_files_are_left_behind()
|
||||
{
|
||||
var path = Path_("datei.json");
|
||||
|
||||
@@ -78,7 +78,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Umlaute_und_Emoji_werden_als_UTF8_ohne_BOM_geschrieben()
|
||||
public void Umlauts_and_emoji_are_written_as_UTF8_without_BOM()
|
||||
{
|
||||
var path = Path_("datei.txt");
|
||||
const string content = "Grüße aus München 🦀";
|
||||
@@ -91,7 +91,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Die_asynchrone_Fassung_verhaelt_sich_gleich()
|
||||
public async Task The_async_version_behaves_the_same()
|
||||
{
|
||||
var path = Path_("datei.json");
|
||||
|
||||
@@ -111,29 +111,29 @@ public sealed class AtomicFileTests : IDisposable
|
||||
/// only see a complete document.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task Waehrend_des_Schreibens_wird_nie_ein_halber_Inhalt_sichtbar()
|
||||
public async Task While_writing_half_content_is_never_visible()
|
||||
{
|
||||
var path = Path_("gross.json");
|
||||
var klein = JsonSerializer.Serialize(Enumerable.Range(0, 50).Select(i => $"eintrag-{i}"));
|
||||
var gross = JsonSerializer.Serialize(Enumerable.Range(0, 20_000).Select(i => $"eintrag-{i}"));
|
||||
var small = JsonSerializer.Serialize(Enumerable.Range(0, 50).Select(i => $"eintrag-{i}"));
|
||||
var large = JsonSerializer.Serialize(Enumerable.Range(0, 20_000).Select(i => $"eintrag-{i}"));
|
||||
|
||||
AtomicFile.WriteAllText(path, klein);
|
||||
AtomicFile.WriteAllText(path, small);
|
||||
|
||||
var fehler = 0;
|
||||
var gelesen = 0;
|
||||
var error = 0;
|
||||
var readBack = 0;
|
||||
|
||||
// Hard time limit, so an error in the writer does not leave the test hanging.
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));
|
||||
|
||||
var schreiber = Task.Run(async () =>
|
||||
var writer = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// #722: Writing continues until the reader has seen enough — not a fixed
|
||||
// number of times. Under parallel load the reader otherwise only got five looks.
|
||||
for (var i = 0; (i < 40 || Volatile.Read(ref gelesen) < 20) && !cts.IsCancellationRequested; i++)
|
||||
for (var i = 0; (i < 40 || Volatile.Read(ref readBack) < 20) && !cts.IsCancellationRequested; i++)
|
||||
{
|
||||
AtomicFile.WriteAllText(path, i % 2 == 0 ? gross : klein);
|
||||
AtomicFile.WriteAllText(path, i % 2 == 0 ? large : small);
|
||||
await Task.Delay(1);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
});
|
||||
|
||||
var leser = Task.Run(async () =>
|
||||
var reader = Task.Run(async () =>
|
||||
{
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
@@ -151,15 +151,15 @@ public sealed class AtomicFileTests : IDisposable
|
||||
{
|
||||
// AtomicFile.ReadAllText, so the reader does not block the
|
||||
// writer — that is exactly what the helper exists for.
|
||||
var inhalt = AtomicFile.ReadAllText(path);
|
||||
Interlocked.Increment(ref gelesen);
|
||||
var content = AtomicFile.ReadAllText(path);
|
||||
Interlocked.Increment(ref readBack);
|
||||
|
||||
// Must always be a complete JSON array.
|
||||
JsonSerializer.Deserialize<string[]>(inhalt);
|
||||
JsonSerializer.Deserialize<string[]>(content);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
Interlocked.Increment(ref fehler);
|
||||
Interlocked.Increment(ref error);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
@@ -169,10 +169,10 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
});
|
||||
|
||||
await Task.WhenAll(schreiber, leser);
|
||||
await Task.WhenAll(writer, reader);
|
||||
|
||||
gelesen.ShouldBeGreaterThan(5, "der Test muss tatsächlich gelesen haben");
|
||||
fehler.ShouldBe(0, "es darf nie ein unvollständiges Dokument sichtbar sein");
|
||||
readBack.ShouldBeGreaterThan(5, "der Test muss tatsächlich gelesen haben");
|
||||
error.ShouldBe(0, "es darf nie ein unvollständiges Dokument sichtbar sein");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -184,7 +184,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
/// File.Replace copes with a sharing reader. Hence Replace.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Ein_offener_Leser_blockiert_das_Schreiben_nicht()
|
||||
public void An_open_reader_does_not_block_writing()
|
||||
{
|
||||
var path = Path_("gehalten.json");
|
||||
AtomicFile.WriteAllText(path, """{"stand":"alt"}""");
|
||||
@@ -198,7 +198,7 @@ public sealed class AtomicFileTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parallele_Schreibvorgaenge_hinterlassen_eine_gueltige_Datei()
|
||||
public void Parallel_writes_leave_a_valid_file()
|
||||
{
|
||||
var path = Path_("parallel.json");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user