This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
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

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