Skip to content

Complete support for [BindAs] - #2220

Merged
dalexsoto merged 5 commits into
dotnet:masterfrom
dalexsoto:bindasregistrar
Jun 26, 2017
Merged

Complete support for [BindAs]#2220
dalexsoto merged 5 commits into
dotnet:masterfrom
dalexsoto:bindasregistrar

Conversation

@dalexsoto

@dalexsoto dalexsoto commented Jun 14, 2017

Copy link
Copy Markdown
Member

Introspection tests have an issue when verifying native signatures, since we are using Nullable<T> and not NSValue or NSNumber it reports a false positive.

Once we land this fix we can use it for Xcode 9 bindings and actually add to monotouch-tests some API using this attribute. like in PR #2193

… as NSObjects

BindAsAttribute allows to bind NSValue and NSNumber into more
accurate C# types lyke bool?, int? etc. so we must teach registrar
about this.
Introspection will currently fail if BindAs is used, introspection
will report that the incorrect type is registered so we need to skip
this check if Nullable type is found in the signature
@dalexsoto

dalexsoto commented Jun 14, 2017

Copy link
Copy Markdown
Member Author

@spouliot / @rolfbjarne Please review so I can unblock @mandel-macaque on #2193 also feedback is super appreciated since this is my first time touching the registrar 😄 so pardon in advance is something is not right :p

@monojenkins

Copy link
Copy Markdown
Contributor

Build failure

Comment thread src/ObjCRuntime/Registrar.cs Outdated
}

// We use BindAsAttribute to wrap NSNumber/NSValue into more accurate Nullable<T> types
if (typeFullName != null && typeFullName.Contains ("Nullable"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contains is not safe enough
Startwith would be better
But it might be possible to check for generic earlier

Comment thread tests/introspection/ApiSignatureTest.cs Outdated
{
if (method is MethodInfo mf) {
if (IsNullableType (mf.ReturnType))
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not skip
Else the other check won't be done and we'll miss errors
Instead we could detect nullable and see the the return or parameters are something bindas support

…the type when Nullable type is encountered

Introspection will currently fail if BindAs is used. Introspection
will report that the incorrect type is registered so we need verify
if a Nullable type is found in the signature and check against of
a withelist of BindAs supported types
@dalexsoto

Copy link
Copy Markdown
Member Author

Sadly I can't use C# 7 heh anyways

@spouliot I think I've addressed the introspection tests side, I think I'll need to wait for @rolfbjarne input since it seems I am missing something from the whole picture with the current fix according to registrar tests.

@monojenkins

Copy link
Copy Markdown
Contributor

Build failure

@rolfbjarne

Copy link
Copy Markdown
Member

So this is a lot more complex for the registrar. I'll have a look and get back to you.

return false;
}

protected HashSet<string> BindAsSupportedTypes = new HashSet<string> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Worth having a bidi comment with the generator source to keep this in sync

@rolfbjarne

Copy link
Copy Markdown
Member

@dalexsoto can you remove the registrar changes, so that we can get the introspection changes in?

Then we can do the registrar changes (which are extensive) in a separate PR.

@dalexsoto

Copy link
Copy Markdown
Member Author

@rolfbjarne / @spouliot done

@monojenkins

Copy link
Copy Markdown
Contributor

Build success

@dalexsoto
dalexsoto merged commit 8c55dd8 into dotnet:master Jun 26, 2017
@dalexsoto
dalexsoto deleted the bindasregistrar branch June 26, 2017 15:56
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jun 30, 2017
* [registrar] BindAs uses Nullable types so allow them to be registered as NSObjects

BindAsAttribute allows to bind NSValue and NSNumber into more
accurate C# types lyke bool?, int? etc. so we must teach registrar
about this.

* [tests][introspection] Teach intro about BindAs and Nullable types

Introspection will currently fail if BindAs is used, introspection
will report that the incorrect type is registered so we need to skip
this check if Nullable type is found in the signature

* [introspection] Add better type checking instead of totally skipping the type when Nullable type is encountered

Introspection will currently fail if BindAs is used. Introspection
will report that the incorrect type is registered so we need verify
if a Nullable type is found in the signature and check against of
a withelist of BindAs supported types

* Revert "[registrar] BindAs uses Nullable types so allow them to be registered as NSObjects"

This reverts commit 911eab9.

* [tests] Add comment about where to find BindAs types
dalexsoto added a commit that referenced this pull request Jun 30, 2017
* [registrar] BindAs uses Nullable types so allow them to be registered as NSObjects

BindAsAttribute allows to bind NSValue and NSNumber into more
accurate C# types lyke bool?, int? etc. so we must teach registrar
about this.

* [tests][introspection] Teach intro about BindAs and Nullable types

Introspection will currently fail if BindAs is used, introspection
will report that the incorrect type is registered so we need to skip
this check if Nullable type is found in the signature

* [introspection] Add better type checking instead of totally skipping the type when Nullable type is encountered

Introspection will currently fail if BindAs is used. Introspection
will report that the incorrect type is registered so we need verify
if a Nullable type is found in the signature and check against of
a withelist of BindAs supported types

* Revert "[registrar] BindAs uses Nullable types so allow them to be registered as NSObjects"

This reverts commit 911eab9.

* [tests] Add comment about where to find BindAs types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants