Skip to content

Generate the core register interface - #135

Merged
glopesdev merged 1 commit into
harp-tech:mainfrom
glopesdev:core-schema-emission
Sep 4, 2026
Merged

Generate the core register interface#135
glopesdev merged 1 commit into
harp-tech:mainfrom
glopesdev:core-schema-emission

Conversation

@glopesdev

@glopesdev glopesdev commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Metadata without a device name now generates an interface to the core register set rather than failing to compile. The register classes, their payload types, the Timestamped variants, the per-register payload operators and the address map are all generated as before; the operators that describe a device are not.

What is omitted

Seven types: GetDeviceMetadata, GroupByRegister, DeviceDataWriter, FilterRegister, Parse, Format and CreateMessage.

Five of them collide by name with hand-written general-purpose operators in Bonsai.Harp, at CreateMessage.cs, FilterRegister.cs, Format.cs, GroupByRegister.cs and Parse.cs. Generating them for the core register schema would be duplicate type definitions in the same namespace. The remaining two are device-scoped by nature, one writing a device-named storage folder and the other returning a device metadata file.

The Device class is reshaped into its common form as a plain partial class Device holding just a standalone RegisterMap, without the Bonsai.Harp.Device base, the WhoAmI constant, INamedElement or the attributes that make it a source operator. No asynchronous interface is generated.

How the two cases are told apart

DeviceMetadata.IsApplicationDevice reports whether the metadata names a device, mirroring the schema layering directly: a document carrying device is a device.json document, one without is a registers.json document. Both targets now read it, where the Python target previously computed its own equivalent from register addresses.

A device declaring no registers stays on the device path and generates exactly what it did before, which the register-count guards around the four operators that index the first register continue to protect.

Evidence

The generated common interface now matches the hand-maintained Bonsai.Harp reference exactly on types, 66 against 66, having previously carried seven extras. It contains no nameof at all, which is what allowed the core register metadata to drop its device name; doing so changed no generated output, confirming the name was already unreferenced.

Closes #134

Metadata that names no device now generates an interface to the core
register set: the register classes, their payload types and an address
map, without the device operators. The seven device-scoped types are
omitted, and five of them would otherwise collide with the hand-written
operators of the same name in Bonsai.Harp. No asynchronous interface is
generated, and the implementation no longer enumerates a file for it, so
a consumer writing the generated files produces only one.

DeviceMetadata gains IsApplicationDevice, which both targets now share
rather than the Python target computing its own. The core register
metadata can now drop its device name.
@glopesdev glopesdev added the feature New planned feature label Sep 4, 2026
@glopesdev
glopesdev merged commit 7e6128c into harp-tech:main Sep 4, 2026
9 checks passed
@glopesdev
glopesdev deleted the core-schema-emission branch September 4, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New planned feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing device name generates uncompilable C# and misreports the cause

1 participant