Skip to content

Use a code-first approach to app-level debugging options #15428

@rolfbjarne

Description

@rolfbjarne

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.
  2. Update templates to set these values to true for debug builds:
#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: #13747

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeIf an issue or a pull request represents a breaking changeenhancementThe issue or pull request is an enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions