dotnet / dotnet/dotnet-api-docs
Should docs state that Decoder and Encoder corrupt internal state during exceptional code paths?
- Lingua principale
- C#
- Stelle
- 949
- Fork
- 1.7k
- Merge medio
- 2g 19h
- PR unite (30g)
- 52
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia esaminando la documentazione API collegata di System.Text.Decoder e System.Text.Encoder e la discussione dell’issue sul comportamento delle eccezioni. Confronta le indicazioni attuali con l’avviso proposto; il lavoro sarà completato quando un maintainer avrà deciso se questo comportamento debba essere documentato e, se approvato, la documentazione API sarà stata aggiornata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100