Skip to content

Commit 90c1206

Browse files
chore: Added context re bindable options for agents (#5035)
1 parent fd57a21 commit 90c1206

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ gh pr view --json number -q '.number'
139139
- Maintain **backwards compatibility** — avoid breaking public API without strong justification
140140
- Platform-specific code lives in `src/Sentry/Platforms/` and is conditionally compiled
141141

142+
## Adding New Options (AOT Compatibility)
143+
144+
`SentryOptions` is **not** bound directly from configuration. Instead, a parallel `BindableSentryOptions` class (`src/Sentry/BindableSentryOptions.cs`) exists for AOT-safe configuration binding.
145+
146+
When adding a configurable property to any of the classes descending from `SentryOptions`:
147+
148+
1. Add the property to `SentryOptions` as normal.
149+
2. Add a matching **nullable** property to `BindableSentryOptions`. Use only simple/primitive types the source generator can handle. For complex types (e.g., `IReadOnlyList<StringOrRegex>`), use a simpler surrogate (e.g., `List<string>?`) and convert in `ApplyTo`.
150+
3. Add a line in `BindableSentryOptions.ApplyTo`: `options.MyProp = MyProp ?? options.MyProp;`
151+
4. Run the relevant bindable options test (e.g., `BindableSentryOptionsTests`) — the `BindableProperties_MatchOptionsProperties` test will fail if any bindable property is missing from the bindable class.
152+
153+
The same pattern applies to `BindableSentryAspNetCoreOptions`, `BindableSentryMauiOptions`, `BindableSentryLoggingOptions`, and the platform-specific partial classes under `src/Sentry/Platforms/`.
154+
142155
## Commit Attribution
143156

144157
AI commits MUST include:

0 commit comments

Comments
 (0)