Skip to content

Conversation

@mandel-macaque
Copy link
Contributor

This change allows to inline the factory methods found in protocols as constructors.

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.
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Base automatically changed from dev/mandel/method-to-constructor to main September 15, 2025 14:58
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Comment on lines +15 to +29
[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.
}
Copy link
Member

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.

Copy link
Contributor Author

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.

mandel-macaque and others added 3 commits September 16, 2025 10:02
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.
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #88b25b0] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #88b25b0] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #88b25b0] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #88b25b0] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build #88b25b0] Tests on macOS arm64 - Mac Sequoia (15) failed ❌

Failed tests are:

  • monotouch-test

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #88b25b0] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #88b25b0] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [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
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 88b25b0243c58f858646e6cc7b23bf03d3339c72 [PR build]

@mandel-macaque mandel-macaque merged commit 7eb6a1e into main Sep 16, 2025
38 of 40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/inline-factory-method-constructor branch September 16, 2025 19:04
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