Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BI1055 error is thrown for iOS Binding project after migrating to .NET6 #11497

Closed
APopatanasov opened this issue May 11, 2021 · 1 comment · Fixed by #11522
Closed

BI1055 error is thrown for iOS Binding project after migrating to .NET6 #11497

APopatanasov opened this issue May 11, 2021 · 1 comment · Fixed by #11522
Assignees
Labels
bug If an issue is a bug or a pull request a bug fix dotnet-pri0 .NET 6: required for stable release
Milestone

Comments

@APopatanasov
Copy link

APopatanasov commented May 11, 2021

Steps to Reproduce

I am currently migrating our iOS Binding project to .NET6. One of the APIs I am binding is a protocol that inherits from the native UIScrollViewDelegate protocol. When I try to build the project the an error is thrown.

  1. Open the attached project.
  2. Try to build it: dotnet build Net6Binding.csproj

Expected Behavior

The binding should be built.

Actual Behavior

An error is thrown.

BTOUCH : error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.SupportedOSPlatformAttribute, System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.

Environment

MacOS Big Sur 11.3.1
dotner version - 6.0.100-preview.4.21255.9

Build Logs

log.txt

Example Project (If Possible)

Net6Binding.zip

@spouliot spouliot added bug If an issue is a bug or a pull request a bug fix dotnet-pri0 .NET 6: required for stable release labels May 11, 2021
@spouliot spouliot added this to the .NET 6 milestone May 11, 2021
@spouliot
Copy link
Contributor

Complete stack trace

        BTOUCH error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.SupportedOSPlatformAttribute, System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case. [/Users/poupou/Downloads/Net6Binding/Net6Binding/Net6Binding.csproj]
       at AttributeManager.ConvertType(Type type, ICustomAttributeProvider provider) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator-attribute-manager.cs:line 206
       at AttributeManager.CreateAttributeInstance[T](CustomAttributeData attribute, ICustomAttributeProvider provider) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator-attribute-manager.cs:line 299
       at AttributeManager.FilterAttributes[T](IList`1 attributes, ICustomAttributeProvider provider) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator-attribute-manager.cs:line 390
       at AttributeManager.GetCustomAttributes[T](ICustomAttributeProvider provider) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator-attribute-manager.cs:line 405
       at Generator.SelectProtocolMethods(Type type, Nullable`1 static, Nullable`1 required)+MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 5641
       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
       at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
       at Generator.GenerateProtocolTypes(Type type, String class_visibility, String TypeName, String protocol_name, ProtocolAttribute protocolAttribute) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 5991
       at Generator.Generate(Type type) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 6411
       at Generator.Go() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 2502
       at BindingTouch.Main3(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 599
       at BindingTouch.Main2(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 223
       at BindingTouch.Main(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 89

@spouliot spouliot self-assigned this May 11, 2021
spouliot added a commit to spouliot/xamarin-macios that referenced this issue May 12, 2021
Internally the generator uses `AvailabilityBaseAttribute` to make its
decisions. For `dotnet` we generated the newer `[SupportedOSPlatform]`
and `[UnsupportedOSPlatform]`.

A 3rd-party (dotnet) binding might refer to members decorated with the
newer attributes and fail the build with an error [1]. Avoiding the error
is easy (first block of the diff) but it does not make the _right_
decisions (e.g. if a member is unavailable for the platform) when
generating the code.

To fix this we need to be able to convert the new attributes into the
well know `AvailabilityBaseAttribute` subclasses. We have not spotted
such cases yet because

* the bindings pass our tests (good but extra code would not fail)
* API diff across legacy and dotnet is not yet done [2]

[1] dotnet#11497
[2] dotnet#10210
@spouliot spouliot linked a pull request May 12, 2021 that will close this issue
spouliot added a commit that referenced this issue May 12, 2021
Internally the generator uses `AvailabilityBaseAttribute` to make its
decisions. For `dotnet` we generated the newer `[SupportedOSPlatform]`
and `[UnsupportedOSPlatform]`.

A 3rd-party (dotnet) binding might refer to members decorated with the
newer attributes and fail the build with an error [1]. Avoiding the error
is easy (first block of the diff) but it does not make the _right_
decisions (e.g. if a member is unavailable for the platform) when
generating the code.

To fix this we need to be able to convert the new attributes into the
well know `AvailabilityBaseAttribute` subclasses. We have not spotted
such cases yet because

* the bindings pass our tests (good but extra code would not fail)
* API diff across legacy and dotnet is not yet done [2]

[1] #11497
[2] #10210
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix dotnet-pri0 .NET 6: required for stable release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants