Description
Type of issue
Missing information
Description
simulate clearing the internal state of the encoder after the calculation
After? What possible value could there be to simulating clearing the internal state after the calculation? Once calculation is complete, the method is done. Simulating a cleared buffer at that point makes no sense. And if we are indeed just 'simulating,' nothing about the decoder's state is actually changing so it's not like any subsequent calls are going to be impacted.
Surely you must mean BEFORE the calculation. If there's leftover data from a previous call to GetChars, whether you include any leftover bytes or not can certainly make a difference in the GetCharCount results. This is also consistent with what I see when I experiment with setting the flag.
Having said that, I just took a look at the source. And despite the fact that we're 'simulating,' there ARE changes to the state of the decoder from the GetCharCount call. Both a variable named _mustFlush and _throwOnOverflow get modified. And while neither variable is read in that source file (I'm looking at DecoderNLS.cs), the values are exposed to callers, so who knows what's up with that.
Simulating clearing the internal state of the encoder 'before' makes sense, but this whole page repeatedly asserts the opposite. And if you really do mean after, then some discussion of what happens after that would be affected by this simulation would be in order.
Page URL
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Text/Decoder.xml
Document Version Independent Id
f6d0f7c6-74c8-db97-da0e-d17770e3360e
Platform Id
d84fef13-e343-6d3c-0650-7ead5aaf0401