Use a code-first approach to app-level debugging options
- Dominant language
- C#
- Stars
- 2.9k
- Forks
- 576
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
The `CheckForIllegalCrossThreadCalls` and `CheckForEventAndDelegateMismatches` fields are hard to discover and tweak (the developer has to modify build settings to get them linked away (or not, depending on the configuration)).
The proposal is to:
1. Change these static fields to be static properties instead. This will:
1. Avoid the need for any logic in the static constructor (to set these values to true).
2. Make it easier for the trimmer to trim them away.
3. Update templates to set these values to `true` for debug builds:
```cs
#if DEBUG
// Enable runtime checks to ensure some types are only used from the main (UI) thread
UIApplication.CheckForIllegalCrossThreadCalls = true;
// Enable runtime checks to ensure ObjC delegates and events (using their own delegates) are not mixed
UIApplication.CheckForEventAndDelegateMismatches = true;
#endif
```
Ref: https://github.com/xamarin/xamarin-macios/pull/13747
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.