Skip to content

ObservableEventsGenerator (contributors)

Languages

简体中文

This page describes generator repository layout for ObservableEventsGenerator. It does not change the consumer API documented in Observable events.

No consumer impact

The generator was refactored into partial files and unused pre–0.6.0 flat wrapper codegen was removed. Generated output and public extension methods are unchanged from 0.6.1.

Where the code lives

Shared sources: MvvmAIO.R3.SourceGenerators/MvvmAIO.R3.SourceGenerators/ (listed in MvvmAIO.R3.SourceGenerators.projitems; all Roslyn* projects import it).

ObservableEventsGenerator is a public sealed partial class with [Generator] on the root file only.

File map

FileRole
ObservableEventsGenerator.csInitialize, post-init bootstrap, RegisterSourceOutput orchestration
ObservableEvents/ObservableEventsConstants.csEntry method names, GeneratedNamespace, QualifiedType()
ObservableEvents/ObservableEventsEntryKind.csFromEvents, routed, attached kinds
ObservableEvents/ObservableEventsModels.csObservableEventTargetSets, EventInterfaceDescriptor, constraint targets
ObservableEventsGenerator.Discovery.csSyntax filtering, CollectObservableEventTargets
ObservableEventsGenerator.InterfacePipeline.csEmitInterfaceBasedSources, hierarchy, name collisions
ObservableEventsGenerator.InterfaceEmission.csInterface / *Impl / extension emission
ObservableEventsGenerator.GenericConstraints.cswhere T : A, B combined interfaces
ObservableEventsGenerator.RoutedDetection.csWPF / Avalonia routed CLR detection
ObservableEventsGenerator.AttachedRouted.csAvalonia attached routed extensions
ObservableEventsGenerator.EventProperties.csEvent Observable properties, delegate checks
ObservableEventsGenerator.Helpers.csIdentifiers, constraint clauses, diagnostics helpers
ObservableEventsSyntaxFactory.csRoslyn syntax only (no orchestration)

When you add a .cs file, register it in alphabetical order in MvvmAIO.R3.SourceGenerators.projitems.

Runtime pipeline

mermaid
flowchart TD
  init[Initialize]
  discover[Discovery: CollectObservableEventTargets]
  iface[InterfacePipeline: EmitInterfaceBasedSources]
  emit[InterfaceEmission + GenericConstraints]
  attached[AttachedRouted per target]
  init --> discover
  discover --> iface
  iface --> emit
  discover --> attached
  1. Post-init — bootstrap extensions + NullEvents (GeneratorBootstrapSyntaxFactory).
  2. Discovery — record types from FromEvents(), routed entries, generic constraints, attached routed.
  3. Interface pipeline — build EventInterfaceDescriptor tree → EventInterfaces.{kind}.g.cs + {Type}.{kind}.g.cs.
  4. Attached routed — separate path; returns Observable<T> (not the interface model).

Static ObservableEventsStatics / OBS_* discovery exists but generation is disabled (StaticObservableEventsGenerationEnabled = false).

Removed internal paths

Do not reintroduce without a design discussion:

  • v0.4.x flat wrapper classes (GenerateObservableSourceForType, CreateWrapperClass, old CreateExtensionsClass chain).

The only instance and routed paths are the interface pipeline above.

Further reading (generator repo)

DocumentContents
AGENTS.mdConventions, CI, diagnostics, full source map
docs/README.mdIn-repo developer doc index
design-interface-based-event-generation.mdInterface hierarchy algorithm (中文), §11 source layout

Released under the MIT License.

Released under the MIT License.