Bug 50407 - NSFormatter.IsPartialStringValid bindings totally wrong
Summary: NSFormatter.IsPartialStringValid bindings totally wrong
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) (show other bugs)
Version: Master
Hardware: PC Mac OS
: Normal normal
Target Milestone: (C10)
Assignee: Timothy Risi
URL:
Depends on:
Blocks:
 
Reported: 2016-12-19 20:44 UTC by Chris Hamons
Modified: 2017-01-11 23:35 UTC (History)
3 users (show)

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


Attachments

Description Chris Hamons 2016-12-19 20:44:03 UTC
Currently:

[Export ("isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:")]
unsafe bool IsPartialStringValid (out string partialString, out NSRange proposedSelRange, string origString, NSRange origSelRange, out NSString error);

should be 

[Export ("isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:")]
unsafe bool IsPartialStringValid (ref NSString partialString, out NSRange proposedSelRange, string origString, NSRange origSelRange, out NSString error);

Since they pass in the new string (which is NSString * _Nonnull * _Nonnull) in partialString that you either accept to return null and modify.

Example - https://gist.github.com/chamons/2195b5072ecb50aecac7e44bc91ffd1f

Doing this in a clean somewhat backwards compat manor is the hard part.

Current idea is:

stub out the old on in !XAMCORE_4_0 (make sure to get sig right)
make it a no-op that you can override
define the new one, with the export
mark the old one as Obsolete
Comment 1 Chris Hamons 2016-12-19 20:44:38 UTC
Work around is to export manually:

[Export ("isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:")]
public bool IsPartialStringValid (ref NSString partialString, out NSRange proposedSelRange, string origString, NSRange origSelRange, out NSString error)
{
}
Comment 2 Chris Hamons 2016-12-19 21:22:04 UTC
Maybe the last out should be ref too (needs testing).
Comment 3 Timothy Risi 2017-01-11 23:35:52 UTC
Fixed https://github.com/xamarin/xamarin-macios/pull/1456

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.