You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the version from `SdkVersions.cs` (e.g., `26.2`) for all availability attributes. If the user specifies a different version (e.g., binding a beta branch at `26.4`), use that instead. **Ask the user if you're unsure which version to use.**
83
+
84
+
#### File Locations
85
+
71
86
Bindings go in these locations:
72
87
-**`src/frameworkname.cs`** — API definitions (interfaces with `[Export]` attributes)
> ❌ **NEVER** forget platform availability attributes. Every new API must have `[iOS]`, `[Mac]`, `[TV]`, `[MacCatalyst]`, and/or `[No*]` attributes matching the `.todo` file platforms where the API appears.
108
+
> ❌ **NEVER** forget platform availability attributes. Every new API must have `[iOS]`, `[Mac]`, `[TV]`, `[MacCatalyst]`, and/or `[No*]` attributes matching the `.todo` file platforms where the API appears. This includes **all** binding types:
109
+
> - API definition interfaces and members in `src/frameworkname.cs` — use `[iOS (X, Y)]`, `[Mac (X, Y)]`, etc.
110
+
> - P/Invoke wrappers and manual properties in `src/FrameworkName/*.cs` — use `[SupportedOSPlatform ("iosX.Y")]`, `[SupportedOSPlatform ("macos")]`, etc.
111
+
> - Fields, constants, and enum values
94
112
95
113
> ❌ **NEVER** use `string.Empty` — use `""`. Never use `Array.Empty<T>()` — use `[]`.
96
114
115
+
> ❌ **NEVER** forget `#nullable enable` at the top of every new C# file you create.
116
+
97
117
> ❌ **NEVER** use non-blittable types (`bool`, `char`) as backing fields in structs. Use `byte` (for `bool`) and `ushort`/`short` (for `char`) with property accessors. See [references/binding-patterns.md](references/binding-patterns.md) for the correct pattern.
98
118
99
119
> ❌ **NEVER** use `XAMCORE_5_0` for new code. `XAMCORE_5_0` is only for fixing breaking API changes on existing types that shipped in prior releases.
> ⚠️ For in depth binding patterns and conventions See [references/binding-patterns.md](references/binding-patterns.md)
108
128
129
+
> ⚠️ **Struct array parameters**: When an API takes a C struct pointer + count (e.g., `MyStruct*` + `NSUInteger`), bind the raw pointer as `[Internal]` with `IntPtr`, then create a manual public wrapper using the **factory pattern** with `fixed`. See [references/binding-patterns.md](references/binding-patterns.md) § "Struct Array Parameter Binding".
130
+
109
131
### Step 4b: Platform Exclusion Patterns for Manual Types
110
132
111
133
When a manually coded type (struct, extension, etc.) is not available on a specific platform (e.g., tvOS), you must handle compilation on that platform:
@@ -130,6 +152,46 @@ make -C src build
130
152
131
153
Fix any compilation errors before proceeding. Builds can take up to 60 minutes — do not timeout early.
132
154
155
+
### Step 5b: Write Monotouch Tests for Manual Bindings
156
+
157
+
For any manually bound APIs (P/Invokes, manual properties on partial classes, struct accessors), add tests in `tests/monotouch-test/{FrameworkName}/`.
158
+
159
+
> ⚠️ **Only run monotouch-tests (Step 6d) if you added or modified test files in this step.** If no manual bindings were added (i.e., all APIs were bound via `[Export]` in the API definition file), skip both this step and Step 6d.
-**Version guards**: Use `TestRuntime.AssertXcodeVersion (major, minor)` matching the API's availability version. This skips the test on older runtimes instead of failing.
188
+
-**Resource cleanup**: Always use `using` statements for handle-based types
189
+
-**Test focus**: Exercise the manual binding — call the P/Invoke wrapper, verify the property returns sensible values, test round-trip behavior for setters
190
+
191
+
> ⚠️ If adding a new test file, make sure the `.csproj` at `tests/monotouch-test/` picks it up (it typically uses wildcard includes, but verify).
192
+
193
+
See [references/binding-patterns.md](references/binding-patterns.md) for more monotouch-test patterns.
194
+
133
195
> ⚠️ **Stale build artifacts**: If you encounter unexpected test failures (false "pre-existing" failures, segfaults in unrelated types), run a full `make all && make install` to clear stale `_build/` artifacts before re-testing.
134
196
135
197
### Step 6: Validate with Tests
@@ -147,6 +209,8 @@ make -C tests/xtro-sharpie run-maccatalyst
147
209
148
210
Verify all `.todo` entries for the bound framework are resolved. If any remain, they need binding or explicit `.ignore` entries with justification.
149
211
212
+
> ⚠️ **Delete empty `.todo` files** after resolving all entries: `git rm tests/xtro-sharpie/api-annotations-dotnet/{platform}-{Framework}.todo`. Do not leave empty `.todo` files in the repository.
213
+
150
214
#### 6b. Cecil Tests
151
215
152
216
```bash
@@ -207,6 +271,14 @@ Look for this pattern in test output to confirm results:
207
271
Tests run: X Passed: X Inconclusive: X Failed: X Ignored: X
208
272
```
209
273
274
+
#### 6d. Monotouch Tests (only if you added tests in Step 5b)
275
+
276
+
Skip this step if no monotouch-test files were added or modified.
277
+
278
+
```bash
279
+
make -C tests/monotouch-test run
280
+
```
281
+
210
282
### Step 7: Handle Test Failures
211
283
212
284
If introspection tests fail for newly bound types:
@@ -234,7 +306,7 @@ When reporting results, use this structure:
234
306
235
307
1.**APIs bound** — table of types/members added with their platforms
236
308
2.**Files changed** — list of modified files
237
-
3.**Test results** — per-platform pass/fail for xtro, cecil, and introspection
309
+
3.**Test results** — per-platform pass/fail for xtro, cecil, introspection, and monotouch-tests
238
310
4.**Remaining items** — any `.todo` entries intentionally left unbound, with reasons
0 commit comments