Bug 28134 - System.Text.EncoderFallbackException inconsistent initial state compared to .Net
Summary: System.Text.EncoderFallbackException inconsistent initial state compared to .Net
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-03-17 16:46 UTC by nader
Modified: 2015-03-30 09:27 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description nader 2015-03-17 16:46:47 UTC
System.Text.EncoderFallbackException has an incorrect/inconsistent initial state compared to its implementation in .Net 4.5. The first inconsistency is that the index property is set to -1, which is  initialized to 0 in .Net.
This property is explicitly set to -1 in the mono source code which can be found in here:


Another inconsistency is the exception's message which is different between .Net and mono.

To reproduce this issue, run the following code snippet:

System.Text.EncoderFallbackException v0 =  new System.Text.EncoderFallbackException();
System.Int32 index = v0.Index ;
System.String message = v0.Message;

mono output:
"Exception of type 'System.Text.EncoderFallbackException' was thrown."

.Net output:
"Value does not fall within the expected range."

The code snippet above was ran using .Net 4.5 and mono 3.3.0. The same issue happens when running the code in Xamarin android and comparing the result with a Windows Phone 8.1 project.

Additional Build Environment info:
Xamarin.Android Version: 4.16.0 (Business Edition)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
Comment 1 nader 2015-03-17 16:50:45 UTC
The same issue appears for System.Text.DecoderFallbackException which appears here:

Comment 2 Marek Safar 2015-03-30 09:27:45 UTC
Fixed in mono 4.0