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) ()
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)

Tags:
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 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.

Related Links:
Status:
RESOLVED FIXED

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