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 form .NET6 to .NET7 #18966

Closed
awattar opened this issue Sep 7, 2023 · 8 comments · Fixed by #18972
Closed

BI1055 error is thrown for iOS Binding project after migrating form .NET6 to .NET7 #18966

awattar opened this issue Sep 7, 2023 · 8 comments · Fixed by #18972
Labels
bug If an issue is a bug or a pull request a bug fix generator Issues affecting the generator
Milestone

Comments

@awattar
Copy link

awattar commented Sep 7, 2023

Steps to Reproduce

  1. Build binding iOS library project over framework containing Obsolete attributes.

Expected Behavior

Build without issues.

Actual Behavior

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

Environment

Version information
Visual Studio Enterprise 2022 for Mac
Version 17.6.3 (build 421)
Installation UUID: 8300f224-7062-4a1c-a6f2-c2947d875e92

Runtime
.NET 7.0.3 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2

Roslyn (Language Service)
4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa

NuGet
Version: 6.4.0.117

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/7.0.307/Sdks
SDK Versions:
	7.0.307
	7.0.306
	7.0.304
	7.0.302
	7.0.203
	7.0.202
	7.0.201
	7.0.200
	7.0.103
	7.0.102
	6.0.413
	6.0.412
	6.0.410
	6.0.408
	6.0.407
	6.0.406
	6.0.405
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Versions:
	7.0.307
	7.0.306
	7.0.304
	7.0.302
	7.0.203
	7.0.202

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	7.0.10
	7.0.9
	7.0.7
	7.0.5
	7.0.4
	7.0.3
	7.0.2
	6.0.21
	6.0.20
	6.0.18
	6.0.16
	6.0.15
	6.0.14
	6.0.13

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
	7.0.10
	7.0.9
	7.0.7
	7.0.5
	7.0.4

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2023-08-02 19:06:42 UTC

Apple Developer Tools
Xcode: 14.3.1 21815
Build: 14E300c

Xamarin.Mac
Version: 9.3.0.6 Visual Studio Enterprise
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:35-0400

Xamarin.iOS
Version: 16.4.0.6 Visual Studio Enterprise
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:36-0400

Xamarin.Android
Version: 13.2.1.2 (Visual Studio Enterprise)
Commit: xamarin-android/d17-5/a8a26c7
Android SDK: /Users/mwesolowski/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		9.0  (API level 28)
		13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 34.0.4
SDK Build Tools Version: 33.0.2

Build Information: 
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2023-08-02 19:06:47 UTC

Android Device Manager
Version: 0.0.0.1309
Hash: 06e3e77
Branch: HEAD
Build date: 2023-08-02 19:06:47 UTC

Build Information
Release ID: 1706030421
Git revision: c90350679f1b9295edc584519320b13d06489853
Build date: 2023-08-02 19:05:00+00
Build branch: release-17.6
Build lane: release-17.6

Operating System
Mac OS X 13.5.1
Darwin 22.6.0 Darwin Kernel Version 22.6.0
    Wed Jul  5 22:22:05 PDT 2023
    root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

Build Logs

Using "BTouch" task from assembly "/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7098/tools/msbuild/iOS/../iOS/Xamarin.iOS.Tasks.dll".
  Task "BTouch"
    /usr/local/share/dotnet/dotnet /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7098/tools/lib/bgen/bgen.dll @/Users/USER/PROJECT/obj/Release/net7.0-ios16.0/response-file.rsp 
    Microsoft (R) Visual C# Compiler version 4.6.0-3.23329.3 (5db00029)
    Copyright (C) Microsoft Corporation. All rights reserved.
    BTOUCH : error BI1055: bgen: Internal error: failed to convert type 'System.Runtime.Versioning.ObsoletedOSPlatformAttribute, System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.
    The command exited with code 1.
  Done executing task "BTouch" -- FAILED.

Description

See identical issue but for different attribute - #11497

See discord conversation - https://discord.com/channels/732297728826277939/732297808148824115/1149440289480646686

Code reference:

  • #if NET
    case "System.Runtime.Versioning.SupportedOSPlatformAttribute":
    return typeof (System.Runtime.Versioning.SupportedOSPlatformAttribute);
    case "System.Runtime.Versioning.UnsupportedOSPlatformAttribute":
    return typeof (System.Runtime.Versioning.UnsupportedOSPlatformAttribute);
    #endif
  • #if NET
    case "System.Runtime.Versioning.SupportedOSPlatformAttribute":
    return typeof (System.Runtime.Versioning.SupportedOSPlatformAttribute);
    case "System.Runtime.Versioning.UnsupportedOSPlatformAttribute":
    return typeof (System.Runtime.Versioning.UnsupportedOSPlatformAttribute);
    #endif
@rolfbjarne
Copy link
Member

Could you show the api definition that triggers this?

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Sep 8, 2023
@rolfbjarne rolfbjarne added this to the Future milestone Sep 8, 2023
@microsoft-github-policy-service
Copy link
Contributor

Hi @awattar. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@awattar
Copy link
Author

awattar commented Sep 8, 2023

@rolfbjarne sure - as simple as this:

...
[Protocol, Model]
[BaseType(typeof(UIApplicationDelegate))]
public interface TestDelegate
{
    [Export("handleEvent:")]
    void HandleEvent(MyAppEvent anEvent);
}

[BaseType(typeof(NSObject))]
public interface MyAppEvent
{
    [Export("message")]
    string Message { get; set; }
}
...

Generates unfinished file and breaks:

namespace TestBinding4 {
	[Protocol (Name = "TestDelegate", WrapperType = typeof (TestDelegateWrapper))]
	[ProtocolMember (IsRequired = false, IsProperty = false, IsStatic = false, Name = "HandleEvent", Selector = "handleEvent:", ParameterType = new Type [] { typeof (TestBinding4.MyAppEvent) }, ParameterByRef = new bool [] { false })]
	public partial interface ITestDelegate : INativeObject, IDisposable, 
		UIKit.IUIApplicationDelegate
	{
	}
	public static partial class TestDelegate_Extensions {
		[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
		public static void HandleEvent (this ITestDelegate This, MyAppEvent anEvent)
		{
			var anEvent__handle__ = anEvent!.GetNonNullHandle (nameof (anEvent));
			global::ApiDefinition.Messaging.void_objc_msgSend_NativeHandle (This.Handle, Selector.GetHandle ("handleEvent:"), anEvent__handle__);
		}
	}

Removing [Protocol] or changing [BaseType(typeof(UIApplicationDelegate))] to [BaseType(typeof(NSObject))] moves further but obviously generates API that is not expected.

The same definition code works for .NET6.

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Sep 8, 2023
@rolfbjarne rolfbjarne added generator Issues affecting the generator bug If an issue is a bug or a pull request a bug fix and removed need-attention An issue requires our attention/response labels Sep 8, 2023
@rolfbjarne
Copy link
Member

OK, I can reproduce it now, thanks.

@awattar
Copy link
Author

awattar commented Sep 9, 2023

@rolfbjarne thanks for the quick fix. Any chances it will land soon on .NET7 stable channel? If not what will be version/manifest version for this change?

@rolfbjarne
Copy link
Member

@rolfbjarne thanks for the quick fix. Any chances it will land soon on .NET7 stable channel? If not what will be version/manifest version for this change?

I'll backport this to .NET 7, but it will take a few weeks until it gets released (it's too late for the next service release, it will have to wait until the one after that).

@awattar
Copy link
Author

awattar commented Sep 11, 2023

@rolfbjarne thanks for the quick fix. Any chances it will land soon on .NET7 stable channel? If not what will be version/manifest version for this change?

I'll backport this to .NET 7, but it will take a few weeks until it gets released (it's too late for the next service release, it will have to wait until the one after that).

We can take the sideload build. Would you be so kind as to tell me the location and build number once it will be merged?

dalexsoto pushed a commit that referenced this issue Sep 13, 2023
…rm attributes. Fixes #18966. (#18990)

Fixes #18966.


Backport of #18972

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
@rolfbjarne
Copy link
Member

@rolfbjarne thanks for the quick fix. Any chances it will land soon on .NET7 stable channel? If not what will be version/manifest version for this change?

I'll backport this to .NET 7, but it will take a few weeks until it gets released (it's too late for the next service release, it will have to wait until the one after that).

We can take the sideload build. Would you be so kind as to tell me the location and build number once it will be merged?

Microsoft.iOS 16.4.7105 contains the fix: https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.iOS.Sdk/overview/16.4.7105%20sha.a08b9f39d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix generator Issues affecting the generator
Projects
None yet
2 participants