[src] Convert manual binding factories to [FactoryMethod] - #26376
[src] Convert manual binding factories to [FactoryMethod]#26376rolfbjarne wants to merge 5 commits into
Conversation
…FactoryMethod] Replace the hand-written SCVideoStreamAnalyzer.Create factory (a manual `new (NSObjectFlag.Empty)` + InitializeHandle wrapper around the failable `initWithParticipantUUID:streamDirection:error:` initializer) with the bgen [FactoryMethod] attribute on the binding constructor. The generated `public static SCVideoStreamAnalyzer? Create (string participantUuid, SCVideoStreamAnalyzerStreamDirection streamDirection, out NSError? error)` is identical to the previous manual factory (same name, signature, nullable return, nil-check/dispose behavior), verified against the generated source and compiled into Microsoft.iOS.dll. The manual partial-class file is deleted and its frameworks.sources entry removed. This binding has monotouch-test coverage (SCVideoStreamAnalyzerTest). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ad44b4bd-764c-4d93-811a-fd5a1f6237e6
Replace the hand-written AVCaptureEventSound.Create factory (a manual `new (NSObjectFlag.Empty)` + InitializeHandle wrapper around the failable `initWithURL:error:` initializer) with the bgen [FactoryMethod] attribute on the binding constructor. The generated `public static AVCaptureEventSound? Create (NSUrl url, out NSError? error)` is identical to the previous manual factory (same name, signature, nullable return, nil-check/dispose behavior), verified against the generated source and compiled into Microsoft.iOS.dll. The manual partial-class file is deleted and its frameworks.sources entry removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ad44b4bd-764c-4d93-811a-fd5a1f6237e6
…[FactoryMethod] Replace the hand-written AVSpeechSynthesisProviderAudioUnit.Create factory (a manual `new (NSObjectFlag.Empty)` + InitializeHandle wrapper around the failable `initWithComponentDescription:options:error:` initializer) with the bgen [FactoryMethod] attribute on the binding constructor. The generated `public static AVSpeechSynthesisProviderAudioUnit? Create (AudioComponentDescription componentDescription, AudioComponentInstantiationOptions options, out NSError? error)` is identical to the previous manual factory (same name, signature, nullable return, nil-check/dispose behavior). The binding init parameter was renamed outError -> error to preserve the public parameter name. Verified against the generated source and compiled into Microsoft.iOS.dll. The manual partial-class file is deleted and its frameworks.sources entry removed. This binding has monotouch-test coverage (AVSpeechSynthesisProviderAudioUnitTest). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ad44b4bd-764c-4d93-811a-fd5a1f6237e6
…ethod] Replace the two hand-written BAAssetPackManifest.Create factories (manual `new (NSObjectFlag.Empty)` + InitializeHandle wrappers around the failable `initWithContentsOfURL:applicationGroupIdentifier:error:` and `initFromData:applicationGroupIdentifier:error:` initializers) with the bgen [FactoryMethod] attribute on two binding constructors. The generated `public static BAAssetPackManifest? Create (NSUrl url, string applicationGroupIdentifier, out NSError? error)` and `Create (NSData data, string applicationGroupIdentifier, out NSError? error)` overloads are identical to the previous manual factories (same names, signatures, nullable return, nil-check/dispose behavior), verified against the generated source and compiled into Microsoft.iOS.dll. The manual partial-class file is deleted and its frameworks.sources entry removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ad44b4bd-764c-4d93-811a-fd5a1f6237e6
Replace the two hand-written WKWebExtensionMatchPattern.Create factories (manual `new (NSObjectFlag.Empty)` + InitializeHandle wrappers around the failable `initWithString:error:` and `initWithScheme:host:path:error:` initializers) with the bgen [FactoryMethod] attribute on two binding constructors. The generated `public static WKWebExtensionMatchPattern? Create (string @string, out NSError? error)` and `Create (string scheme, string host, string path, out NSError? error)` overloads are identical to the previous manual factories (same names, signatures, nullable return, nil-check/dispose behavior), and coexist with the existing `[Static]` `Create` overloads (matchPatternWithString: / matchPatternWithScheme:host:path:) that take no error argument. Verified against the generated source and compiled into Microsoft.iOS.dll. The manual partial-class file is deleted and its frameworks.sources entry removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ad44b4bd-764c-4d93-811a-fd5a1f6237e6
There was a problem hiding this comment.
Pull request overview
This PR migrates five hand-written “failable initializer” factory implementations to bgen’s new [FactoryMethod] support, so the generator emits nullable Create(...) factories automatically and the redundant manual partial-class helpers can be removed.
Changes:
- Replaced
[Internal] NativeHandle _InitWith...init helpers with[FactoryMethod]failable constructor bindings ([return: NullAllowed] NativeHandle Constructor (...)) for five types. - Deleted the corresponding hand-written partial-class
Create(...)implementations. - Removed the deleted source files from
src/frameworks.sources.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/WebKit/WKWebExtensionMatchPattern.cs | Deletes the manual Create(...) factory helpers for failable initializers. |
| src/webkit.cs | Adds [FactoryMethod] constructor bindings for WKWebExtensionMatchPattern failable initializers. |
| src/SensitiveContentAnalysis/SCVideoStreamAnalyzer.cs | Deletes the manual Create(...) factory helper. |
| src/sensitivecontentanalysis.cs | Adds a [FactoryMethod] constructor binding for the failable initializer. |
| src/BackgroundAssets/BAAssetPackManifest.cs | Deletes the manual Create(...) factory helpers. |
| src/backgroundassets.cs | Adds [FactoryMethod] constructor bindings for the two failable initializers. |
| src/AVKit/AVCaptureEventSound.cs | Deletes the manual Create(...) factory helper. |
| src/avkit.cs | Adds a [FactoryMethod] constructor binding for the failable initializer. |
| src/AVFoundation/AVSpeechSynthesisProviderAudioUnit.cs | Deletes the manual Create(...) factory helper. |
| src/avfoundation.cs | Adds a [FactoryMethod] constructor binding for the failable initializer. |
| src/frameworks.sources | Removes the deleted partial-class source files from the build inputs. |
| [FactoryMethod] | ||
| [Export ("initWithContentsOfURL:applicationGroupIdentifier:error:")] | ||
| NativeHandle _InitWithContentsOfUrl (NSUrl url, string applicationGroupIdentifier, [NullAllowed] out NSError error); | ||
|
|
||
| [Internal] | ||
| [return: NullAllowed] | ||
| NativeHandle Constructor (NSUrl url, string applicationGroupIdentifier, [NullAllowed] out NSError error); |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🔥 [CI Build #4f9a408] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 46 tests failed, 157 tests passed. Failures❌ cecil tests1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (iOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (macOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (iOS)19 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)19 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ msbuild tests1 tests failed, 1 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ xtro tests1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|
Convert five hand-written failable-initializer factory helpers to use the new bgen
[FactoryMethod]attribute (added in #26196). Each conversion replaces an[Internal] NativeHandle _InitWith...helper plus a manual partial-class factory method with a[FactoryMethod] [return: NullAllowed] NativeHandle Constructor (...)in the binding definition, letting the generator emit thepublic static T? Create (...)factory. The manual partial-class files are deleted and their entries removed fromframeworks.sources.🤖 Pull request created by Copilot