-
Notifications
You must be signed in to change notification settings - Fork 554
[RGen] Add support to inline protocol factory methods as constructors. #23812
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
[RGen] Add support to inline protocol factory methods as constructors. #23812
Conversation
This allows to convert the method marked as factories in a protocol into constructors, later we can use this conversion to inline the factory methods as constructors in the classes that implement a protocol with factories.
This change allows to inline the factory methods found in protocols as constructors.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| [BindingType<ObjCBindings.Protocol>] | ||
| public partial interface IMyNSCoding { | ||
|
|
||
| [Export<Method> ("initWithCoder:", Flags = Method.Factory)] | ||
| public virtual partial IMyNSCoding CreateWithCoder (NSObject coder); | ||
| } | ||
|
|
||
| [SupportedOSPlatform ("macos")] | ||
| [SupportedOSPlatform ("ios")] | ||
| [SupportedOSPlatform ("tvos")] | ||
| [SupportedOSPlatform ("maccatalyst13.1")] | ||
| [BindingType<Class>] | ||
| public partial class InlineProtocolConstructors : IMyNSCoding { | ||
| // we are testing that the protocol constructor is added. | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in this case (the class already has a constructor with the same selector or even just overload)?
[BindingType<ObjCBindings.Protocol>]
public partial interface IMyNSCoding {
[Export<Method> ("initWithCoder:", Flags = Method.Factory)]
public virtual partial IMyNSCoding CreateWithCoder (NSObject coder);
}
[BindingType<Class>]
public partial class InlineProtocolConstructors1 : IMyNSCoding {
// we are testing that the protocol constructor is added.
[Export<Method> ("initWithCoder:")]
public partial InlineProtocolConstructors1 (NSObject coder);
}
[BindingType<Class>]
public partial class InlineProtocolConstructors2 : IMyNSCoding {
// we are testing that the protocol constructor is added.
[Export<Method> ("initWithWhatever:")]
public partial InlineProtocolConstructors2 (NSObject whatever);
}In either case, I think you'll have to just not inline the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already do that, if you check there is a dict that will merge constructors and will ignore those coming from the protocol that have the same selector.
Nevertheless the review is valid, I will add those test cases to show we already do that.
If a protocola and a class have constructors that are overloaded, detect that and use the one in the class instead of inlining the protocol one.
✅ [PR Build #88b25b0] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commit.NET ( No breaking changes )✅ API diff vs stable.NET ( No breaking changes )ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #88b25b0] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #88b25b0] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #88b25b0] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
❌ [CI Build #88b25b0] Tests on macOS arm64 - Mac Sequoia (15) failed ❌Failed tests are:
Pipeline on Agent |
💻 [CI Build #88b25b0] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #88b25b0] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #88b25b0] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 115 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This change allows to inline the factory methods found in protocols as constructors.