#768·Harmony

Add nullable reference annotations to the public API

Author: pardeikeCreated Sep 8, 2026Updated Sep 8, 2026
Labelsenhancement

Enhancement for the Harmony 3 backlog.

Reflection helpers such as AccessTools.Method document returning null when a member cannot be found, but Harmony's public signatures do not communicate that to nullable-aware callers.

Audit and annotate the public API on v3, starting with reflection and patch metadata. Match existing behavior rather than changing which inputs are accepted or which failures throw.

Completion criteria:

  • Audit null inputs, optional parameters, return values and generic contracts before adding annotations. Document any deliberately unannotated areas.
  • Compile representative nullable-enabled consumer examples and verify both useful warnings and valid calls without spurious warnings.
  • Preserve binary signatures and runtime behavior, including builds for all currently supported target frameworks. Supply annotation attributes for older targets only where required.
  • Update the generated API documentation to explain relevant null contracts.

This concerns nullable reference metadata, not support for nullable value types such as int?.

Follow-up to #586. Current API.