fix: translate PascalCase procedure names to .NET getter/setter convention

The kRPC server (a C# application) exposes C# properties using
.NET accessor naming: a property `UT` on the SpaceCenter service
becomes two procedures named `get_UT` and `set_UT`. A class
property `CelestialBody.Name` becomes `CelestialBody.get_Name`
and `CelestialBody.set_Name`.

We had been calling `SpaceCenter.GetUT()` (PascalCase, no
underscore) and looking up the literal key. That key never
matched, so the cache always returned 'procedure not found' —
even though `get_UT` was sitting right there.

The Python client side-steps this by using snake_case for
everything (`SpaceCenter.ut` -> `SpaceCenter.get_UT`), and
the C# client just uses .NET convention directly. Our
TypeScript/extract code uses the more familiar PascalCase
form, so the cache lookup now does the translation.

The translation is purely a fallback path:
- exact match tried first
- if not found and the name starts with Get/Set, the
  .NET-style `get_X`/`set_X` variant is tried
- works for both top-level ("GetUT") and class-prefixed
  ("CelestialBody.GetName") procedure names

This unblocks the real bridge: `SpaceCenter.GetUT`,
`SpaceCenter.GetActiveVessel`, `SpaceCenter.GetBodies`,
`SpaceCenter.GetVessels`, and all the class methods like
`CelestialBody.GetName`, `Vessel.GetType`, `Orbit.GetApoapsis`
should now resolve to actual kRPC procedures.
This commit is contained in:
Mavis
2026-06-03 00:11:39 +00:00
parent ee75d0b6c9
commit e9ebbf17d2
2 changed files with 88 additions and 28 deletions
@@ -225,4 +225,39 @@ describe('ServiceCache', () => {
// Missing return type becomes NONE (code 0).
expect(r.info.returnType.code).toBe(0);
});
it('falls back to .NET-style getter/setter naming for C# properties', () => {
// The kRPC server exposes C# properties using .NET accessor
// conventions: a property `UT` on SpaceCenter becomes two
// procedures named `get_UT` and `set_UT`. User code typically
// writes `SpaceCenter.GetUT()` (PascalCase). The cache must
// transparently translate to the wire-format name.
const raw = {
services: [
{
name: 'SpaceCenter',
procedures: [
{ name: 'get_UT', parameters: [], returnType: null, returnIsNullable: false },
{ name: 'set_UT', parameters: [], returnType: null, returnIsNullable: false },
{ name: 'get_ActiveVessel', parameters: [], returnType: null, returnIsNullable: true },
{ name: 'CelestialBody.get_Name', parameters: [], returnType: null, returnIsNullable: false },
],
classes: [],
enumerations: [],
},
],
};
const cache = new ServiceCache(raw as unknown as Parameters<typeof ServiceCache>[0]);
// Top-level PascalCase -> .NET getter
expect(cache.lookup('SpaceCenter', 'GetUT').found).toBe(true);
// Top-level PascalCase -> .NET setter
expect(cache.lookup('SpaceCenter', 'SetUT').found).toBe(true);
expect(cache.lookup('SpaceCenter', 'GetActiveVessel').found).toBe(true);
// Class-prefixed: "CelestialBody.GetName" -> "CelestialBody.get_Name"
expect(cache.lookup('SpaceCenter', 'CelestialBody.GetName').found).toBe(true);
// Exact match still works
expect(cache.lookup('SpaceCenter', 'get_UT').found).toBe(true);
// And unknown names still return not-found
expect(cache.lookup('SpaceCenter', 'NoSuchProcedure').found).toBe(false);
});
});