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.
The message attributesAtIndex:effectiveRange: is not bound in NSAttributed string. The "longestEffectiveRange" variant is bound.
This method is needed to subclass NSTextStorage
> public NSDictionary GetAttributes (nint location, out NSRange effectiveRange)
is the bound version of "attributesAtIndex:effectiveRange:" in NSAttributedString
However the way it was done you need to override
> public virtual IntPtr LowLevelGetAttributes (nint location, out NSRange effectiveRange)
as the former is not virtual.
Git history brings me back to the original monotouch commit (2010-04-19) but I believe that the binding generator was not, at the time, able to handle this case.
The problem is that there is no way to test effectiveRange against null with that signature. The docs explicitly allow that case and the function does get called that way.
For now, I'm doing my own override:
member this.GetAttributes (location : nint, effectiveRange : nativeint) : nativeint =
if effectiveRange <> 0n then
let range = NSRange (nint 0, data.Length)
System.Runtime.InteropServices.Marshal.StructureToPtr (range, effectiveRange, false)
So this won't be fixed?
Not in the short term. It's how .NET works (non-nullable struct), which is not always the best in a ref/out case. Fixing this would be an API breaking change (without workarounds).
Your workaround, using a different signature, is the best way to test for null (even if it makes using the NSRange instance harder later).