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

Function emitClientSessionApiRegistration

scripts/codegen/csharp.ts:2183–2300  ·  view source on GitHub ↗
(clientSchema: Record<string, unknown>, classes: string[])

Source from the content-addressed store, hash-verified

2181}
2182
2183function emitClientSessionApiRegistration(clientSchema: Record<string, unknown>, classes: string[]): string[] {
2184 const lines: string[] = [];
2185 const groups = collectClientGroups(clientSchema);
2186
2187 for (const { methods } of groups) {
2188 for (const method of methods) {
2189 const resultSchema = getMethodResultSchema(method);
2190 if (!isVoidSchema(resultSchema) && !isOpaqueJson(resultSchema)) {
2191 emitRpcResultType(resultTypeName(method), resultSchema!, "public", classes);
2192 }
2193
2194 const effectiveParams = resolveMethodParamsSchema(method);
2195 if (effectiveParams?.properties && Object.keys(effectiveParams.properties).length > 0) {
2196 const paramsClass = emitRpcClass(paramsTypeName(method), effectiveParams, "public", classes);
2197 if (paramsClass) classes.push(paramsClass);
2198 }
2199 }
2200 }
2201
2202 for (const { groupName, groupNode, methods } of groups) {
2203 const interfaceName = clientHandlerInterfaceName(groupName);
2204 const groupExperimental = isNodeFullyExperimental(groupNode);
2205 const groupDeprecated = isNodeFullyDeprecated(groupNode);
2206 lines.push(`/// <summary>Handles \`${groupName}\` client session API methods.</summary>`);
2207 if (groupExperimental) {
2208 pushExperimentalAttribute(lines);
2209 }
2210 if (groupDeprecated) {
2211 pushObsoleteAttributes(lines);
2212 }
2213 lines.push(`public interface ${interfaceName}`);
2214 lines.push(`{`);
2215 for (const method of methods) {
2216 const effectiveParams = resolveMethodParamsSchema(method);
2217 const hasParams = !!effectiveParams?.properties && Object.keys(effectiveParams.properties).length > 0;
2218 const resultSchema = getMethodResultSchema(method);
2219 const taskType = resultTaskType(method);
2220 pushRpcMethodXmlDocs(
2221 lines,
2222 method,
2223 " ",
2224 [
2225 ...(hasParams ? [{ name: "request", description: rpcParamsDescription(method, effectiveParams) }] : []),
2226 { name: "cancellationToken", description: CANCELLATION_TOKEN_DESCRIPTION, escapeDescription: false },
2227 ],
2228 resultSchema,
2229 `Handles "${method.rpcMethod}".`
2230 );
2231 if (method.stability === "experimental" && !groupExperimental) {
2232 pushExperimentalAttribute(lines, " ");
2233 }
2234 if (method.deprecated && !groupDeprecated) {
2235 pushObsoleteAttributes(lines, " ");
2236 }
2237 if (hasParams) {
2238 lines.push(` ${taskType} ${clientHandlerMethodName(method.rpcMethod)}(${paramsTypeName(method)} request, CancellationToken cancellationToken = default);`);
2239 } else {
2240 lines.push(` ${taskType} ${clientHandlerMethodName(method.rpcMethod)}(CancellationToken cancellationToken = default);`);

Callers 1

generateRpcCodeFunction · 0.70

Calls 15

isVoidSchemaFunction · 0.85
isOpaqueJsonFunction · 0.85
emitRpcResultTypeFunction · 0.85
emitRpcClassFunction · 0.85
isNodeFullyExperimentalFunction · 0.85
isNodeFullyDeprecatedFunction · 0.85
pushObsoleteAttributesFunction · 0.85
resultTaskTypeFunction · 0.85
pushRpcMethodXmlDocsFunction · 0.85
handlerTaskTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…