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

Function emitServerInstanceMethod

scripts/codegen/csharp.ts:1815–1945  ·  view source on GitHub ↗
(
    name: string,
    method: RpcMethod,
    lines: string[],
    classes: string[],
    indent: string,
    groupExperimental: boolean,
    groupDeprecated: boolean
)

Source from the content-addressed store, hash-verified

1813}
1814
1815function emitServerInstanceMethod(
1816 name: string,
1817 method: RpcMethod,
1818 lines: string[],
1819 classes: string[],
1820 indent: string,
1821 groupExperimental: boolean,
1822 groupDeprecated: boolean
1823): void {
1824 const methodName = toPascalCase(name);
1825 const isInternal = method.visibility === "internal";
1826 const methodVisibility = isInternal ? "internal" : "public";
1827 const resultSchema = getMethodResultSchema(method);
1828 let resultClassName = !isVoidSchema(resultSchema) ? resultTypeName(method) : "";
1829 if (!isVoidSchema(resultSchema) && method.stability === "experimental" && !nonExperimentalRpcTypes.has(resultClassName)) {
1830 experimentalRpcTypes.add(resultClassName);
1831 }
1832 if (!isVoidSchema(resultSchema)) {
1833 resultClassName = emitRpcResultType(resultClassName, resultSchema!, methodVisibility, classes);
1834 }
1835
1836 const effectiveParams = resolveMethodParamsSchema(method);
1837 const paramEntries = effectiveParams?.properties ? Object.entries(effectiveParams.properties) : [];
1838 const requiredSet = new Set(effectiveParams?.required || []);
1839
1840 // Sort so required params come before optional (C# requires defaults at end)
1841 paramEntries.sort((a, b) => {
1842 const aReq = requiredSet.has(a[0]) ? 0 : 1;
1843 const bReq = requiredSet.has(b[0]) ? 0 : 1;
1844 return aReq - bReq;
1845 });
1846
1847 let requestClassName: string | null = null;
1848 if (paramEntries.length > 0) {
1849 requestClassName = paramsTypeName(method);
1850 if (method.stability === "experimental" && !nonExperimentalRpcTypes.has(requestClassName)) {
1851 experimentalRpcTypes.add(requestClassName);
1852 }
1853 const reqClass = emitRpcClass(requestClassName, effectiveParams!, "internal", classes);
1854 if (reqClass) classes.push(reqClass);
1855 }
1856
1857 const sigParams: string[] = [];
1858 const bodyAssignments: string[] = [];
1859 const argumentNullChecks: string[] = [];
1860 const parameterDescriptions: Array<{ name: string; description?: string; escapeDescription?: boolean }> = [];
1861
1862 for (const [pName, pSchema] of paramEntries) {
1863 if (typeof pSchema !== "object") continue;
1864 const isReq = requiredSet.has(pName);
1865 const jsonSchema = pSchema as JSONSchema7;
1866 const csharpName = requestClassName
1867 ? toCSharpPropertyName(pName, jsonSchema)
1868 : toPascalCase(pName);
1869 const naturalType = requestClassName
1870 ? resolveRpcType(jsonSchema, isReq, requestClassName, csharpName, classes)
1871 : schemaTypeToCSharp(jsonSchema, isReq, rpcKnownTypes, csharpName);
1872 // Boundary special-case: if the natural type is JsonElement/JsonElement?

Callers 2

emitServerRpcClassesFunction · 0.85
emitServerApiClassFunction · 0.85

Calls 15

isVoidSchemaFunction · 0.85
emitRpcResultTypeFunction · 0.85
emitRpcClassFunction · 0.85
toCSharpPropertyNameFunction · 0.85
resolveRpcTypeFunction · 0.85
schemaTypeToCSharpFunction · 0.85
localRequestVariableNameFunction · 0.85
pushRpcMethodXmlDocsFunction · 0.85
pushObsoleteAttributesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…