MCPcopy Index your code
hub / github.com/github/copilot-sdk / failUnmappable

Function failUnmappable

scripts/codegen/csharp.ts:297–305  ·  view source on GitHub ↗

* Schemas marked `.asOpaqueJson()` on the runtime side carry * `x-opaque-json: true`. These are the only shapes that legitimately surface * as opaque JSON in the SDK (mapped to `JsonElement` in C#). Anything else * that lacks an idiomatic mapping (untyped fields, non-discriminated unions, * etc.

(context: string, schema: JSONSchema7)

Source from the content-addressed store, hash-verified

295 * The predicate itself lives in {@link "./utils".isOpaqueJson} for reuse.
296 */
297function failUnmappable(context: string, schema: JSONSchema7): never {
298 const summary = JSON.stringify(schema, (key, value) => (key === "description" ? undefined : value)).slice(0, 200);
299 throw new Error(
300 `C# codegen: cannot map schema to an idiomatic C# type (${context}). ` +
301 `On the runtime side, either tighten the Zod schema to a typed shape, or — if it is genuinely free-form JSON — ` +
302 `mark it \`.asOpaqueJson()\` so the schema emits \`x-opaque-json: true\` and the codegen maps it to JsonElement. ` +
303 `Offending schema (truncated): ${summary}`,
304 );
305}
306
307function requiresArgumentNullCheck(typeName: string, isRequired: boolean): boolean {
308 return isRequired && !typeName.endsWith("?") && !isNonNullableCSharpValueType(typeName);

Callers 2

schemaTypeToCSharpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…