MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / extractCSharpRelations

Function extractCSharpRelations

src/ast/extract-csharp.ts:211–229  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

209
210// Extract navigation properties / relationships
211function extractCSharpRelations(body: string): string[] {
212 const relations: string[] = [];
213 // public virtual ICollection<Post> Posts { get; set; }
214 // public virtual User User { get; set; }
215 const navPattern =
216 /public\s+virtual\s+(I?(?:Collection|List)<\s*(\w+)\s*>|(\w+))\s+(\w+)\s*\{/g;
217 let m: RegExpExecArray | null;
218 while ((m = navPattern.exec(body)) !== null) {
219 const collectionType = m[2];
220 const singleType = m[3];
221 const propName = m[4];
222 if (collectionType) {
223 relations.push(`${propName}: ${collectionType}[]`);
224 } else if (singleType && singleType !== "string" && singleType !== "int" && singleType !== "bool") {
225 relations.push(`${propName}: ${singleType}`);
226 }
227 }
228 return relations;
229}
230
231// ─── C# lib exports ────────────────────────────────────────────────────────
232

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected