dotnet / dotnet/dotnet-api-docs
Should docs state that Decoder and Encoder corrupt internal state during exceptional code paths?
- Vorherrschende Sprache
- C#
- Sterne
- 949
- Forks
- 1.7k
- Ø Merge
- 2 T. 19 Std.
- Gemergte PRs (30 T.)
- 52
Beschreibung
For [`System.Text.Decoder`](https://docs.microsoft.com/en-us/dotnet/api/system.text.decoder) and [`System.Text.Encoder`](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoder), the general pattern is that callers should ensure the destination buffers are large enough to hold the converted output.
It is _not_ appropriate for the caller to catch exceptions from these APIs, double the destination buffer, and try the operation again. The `Decoder` and `Encoder` instances mutate their internal state during instance method calls, and exceptions occurring during these method calls can leave the internal instance state undefined. This could result in data corruption when attempting to use these instances for subsequent operations.
Does this behavior need to be documented? It was suggested on another thread that we state this explicitly. I wanted to gauge the feedback here because I was under the impression that `Encoder` and `Decoder` aren't unique here; that it's generally assumed framework-wide that exceptions might leave the target object in an indeterminate state. Similar to how we assume that instance methods are not thread-safe unless explicitly documented as being thread-safe.
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit der Durchsicht der verlinkten API-Dokumentation zu System.Text.Decoder und System.Text.Encoder sowie der Diskussion im Issue über das Ausnahmeverhalten. Vergleichen Sie die aktuelle Anleitung mit der vorgeschlagenen Warnung; abgeschlossen ist die Aufgabe, wenn ein Maintainer entschieden hat, ob dieses Verhalten dokumentiert werden sollte, und, falls genehmigt, die API-Dokumentation aktualisiert wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100