Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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
Developer Community or GitHub 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.
Property Android.Graphics.BitmapFactory.Options.InTempStorage cannot be assigned to. In java it can be set (it's public field - http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inTempStorage). Also, type of this property is IList<byte> - why not byte?
Indeed, we should fix that property to have a setter.
As for why it's an IList<byte> and not a byte, it's for performance!
The problem is this: if the property were a byte, then whenever you get (or set) the property, the _entire_ array needs to be copied from/to Java. For small arrays, this would probably be fine, but for large arrays, that could be a lot of memory you're copying. Further add in the fact that it's a _property_ (and not a method), implicitly copying (possibly large) arrays would be Bad™. See also the "Properties That Return Arrays" section at: http://msdn.microsoft.com/en-us/library/k2604h5s.aspx
Instead, what we do is the property getter allocates and returns an Android.Runtime.JavaArray<byte> instance (which implements IList<byte>), which provides an indexer which is implemented as JNIEnv.GetArrayItem().
The result is that if you do:
byte value = instance.InTempStorage ;
There will only be a JNI invocation to read index 0 of the Java-side byte array, and not a byte copy operation.
(Whether this is actually a performance win or not obviously depends upon what exactly you're doing, but it's certainly semantically more correct than always copying the array on every property access, which would have terrible performance & memory implications.)
Fixed in master/6cfb9f60.