-
Notifications
You must be signed in to change notification settings - Fork 522
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
[iOS] [.NET 8] Binding library source generator does not use interface for protocols #19612
Labels
bug
If an issue is a bug or a pull request a bug fix
generator
Issues affecting the generator
regression
The issue or pull request is a regression
Milestone
Comments
rolfbjarne
added a commit
to rolfbjarne/xamarin-macios
that referenced
this issue
Dec 11, 2023
This fixes a regression in .NET 8, where we changed the temporary assembly name when building using a project file / MSBuild - we started compiling the temporary binding code in MSBuild instead of in the generator, and in the process we changed the name of the temporary assembly. This broke logic in bgen that compared the assembly name to check if a given type is from the temporary assembly or not. Fix this by checking the actual temporary assembly instead of the name of the assembly instead. Fixes dotnet#19612.
I can reproduce, and a fix is in progress. I'll try to come up with a workaround. |
Adding this to the binding project seems to fix it: <Target Name="FixTemporaryAssemblyName" AfterTargets="_ComputeCompileApiDefinitionsInputs">
<PropertyGroup>
<_CompiledApiDefinitionAssembly>$(DeviceSpecificIntermediateOutputPath)temp.dll</_CompiledApiDefinitionAssembly>
</PropertyGroup>
</Target> |
@rolfbjarne It does, thanks for the workaround! |
rolfbjarne
added a commit
that referenced
this issue
Dec 14, 2023
This fixes a regression in .NET 8, where we changed the temporary assembly name when building using a project file / MSBuild - we started compiling the temporary binding code in MSBuild instead of in the generator, and in the process we changed the name of the temporary assembly. This broke logic in bgen that compared the assembly name to check if a given type is from the temporary assembly or not. Fix this by checking the actual temporary assembly instead of the name of the assembly instead. Fixes #19612.
rolfbjarne
added a commit
to rolfbjarne/xamarin-macios
that referenced
this issue
Dec 14, 2023
This fixes a regression in .NET 8, where we changed the temporary assembly name when building using a project file / MSBuild - we started compiling the temporary binding code in MSBuild instead of in the generator, and in the process we changed the name of the temporary assembly. This broke logic in bgen that compared the assembly name to check if a given type is from the temporary assembly or not. Fix this by checking the actual temporary assembly instead of the name of the assembly instead. Fixes dotnet#19612. Backport of dotnet#19619.
rolfbjarne
added a commit
that referenced
this issue
Dec 15, 2023
This fixes a regression in .NET 8, where we changed the temporary assembly name when building using a project file / MSBuild - we started compiling the temporary binding code in MSBuild instead of in the generator, and in the process we changed the name of the temporary assembly. This broke logic in bgen that compared the assembly name to check if a given type is from the temporary assembly or not. Fix this by checking the actual temporary assembly instead of the name of the assembly instead. Fixes #19612. Backport of #19619.
I am sorry but adding that to the .csproj file is still generating abstract classes instead of interfaces, Am I missing something? |
@15mgm15 please file a new issue with a test case and we'll have a look at what's happening. |
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
regression
The issue or pull request is a regression
Hello,
I'm trying to update my iOS binding library from .NET 7.0 to 8.0, but I believe the code behind source generator is not generating the correct code. When I define a protocol, it's not using the generated interface causing the object to try to inherit from both the NSObject and the protocol class. This results in compiler error CS1721 (cannot have multiple base classes).
This was working correctly in .NET 7.0, could I be missing a breaking change?
Steps to Reproduce
Create a new binding library and add the following code to the ApiDefinition.cs in a namespace of your choosing.
Expected Behavior
The generated Reader.g.cs file should have a
Reader
class with the following signature (net7.0-ios behavior):Actual Behavior
The generated Reader.g.cs file contains a
Reader
class with the following signature (net8.0-ios behavior):This causes the compiler to throw error CS1721 "Class 'Reader' cannot have multiple base classes: 'NSObject' and 'ReaderProtocol'.
Environment
Version information
Build Logs
Example Project (If Possible)
The text was updated successfully, but these errors were encountered: