@descryy/adapter-csharp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.d.ts +31 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +263 -0
- package/dist/adapter.js.map +1 -0
- package/dist/aspnetcore.d.ts +207 -0
- package/dist/aspnetcore.d.ts.map +1 -0
- package/dist/aspnetcore.js +410 -0
- package/dist/aspnetcore.js.map +1 -0
- package/dist/client-base.d.ts +123 -0
- package/dist/client-base.d.ts.map +1 -0
- package/dist/client-base.js +123 -0
- package/dist/client-base.js.map +1 -0
- package/dist/client.d.ts +168 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +387 -0
- package/dist/client.js.map +1 -0
- package/dist/efcore.d.ts +198 -0
- package/dist/efcore.d.ts.map +1 -0
- package/dist/efcore.js +611 -0
- package/dist/efcore.js.map +1 -0
- package/dist/extract.d.ts +83 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +1120 -0
- package/dist/extract.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/nullability.d.ts +117 -0
- package/dist/nullability.d.ts.map +1 -0
- package/dist/nullability.js +152 -0
- package/dist/nullability.js.map +1 -0
- package/dist/parse.d.ts +240 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +861 -0
- package/dist/parse.js.map +1 -0
- package/dist/projects.d.ts +87 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +226 -0
- package/dist/projects.js.map +1 -0
- package/dist/tree-sitter-c_sharp.wasm +0 -0
- package/package.json +35 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# files to Canonical IR.
|
|
3
|
+
*
|
|
4
|
+
* ## Identity is the project plus the declared namespace
|
|
5
|
+
*
|
|
6
|
+
* Not the namespace alone. C# namespaces do not follow directories and the same
|
|
7
|
+
* namespace legitimately spans projects, so two `.csproj` files in one
|
|
8
|
+
* repository may both declare `Shop.Orders.OrderService`. That is DEC-077's
|
|
9
|
+
* collision — the Java case where one fully-qualified name existed under two
|
|
10
|
+
* source sets and stopped identifying anything — and the project is C#'s
|
|
11
|
+
* equivalent separator.
|
|
12
|
+
*
|
|
13
|
+
* ## Two decisions land here, both taken before this file was written
|
|
14
|
+
*
|
|
15
|
+
* **DEC-083, a declaration that spans files.** `partial class` is the first
|
|
16
|
+
* construct in this project whose declaration is legitimately multi-file. The
|
|
17
|
+
* merge is free — a node id never contains a file path — so the parts collapse
|
|
18
|
+
* to one node with no new machinery. `file` is the lexicographically first
|
|
19
|
+
* declaring path and every part is listed in `attrs.declaredIn`, which is what
|
|
20
|
+
* a precision adjudicator has to search instead of `file`.
|
|
21
|
+
*
|
|
22
|
+
* **DEC-084, the base list.** `class A : B, IC` does not say which entry is the
|
|
23
|
+
* class, but the language does: at most one base class, and it must be first.
|
|
24
|
+
* So entries after the first are `IMPLEMENTS` unconditionally, a struct's and an
|
|
25
|
+
* interface's entries are all `IMPLEMENTS`, and exactly one entry per class ever
|
|
26
|
+
* needs resolving. The `IFoo` prefix is never read — it is a convention,
|
|
27
|
+
* `System.Exception` disproves it in the other direction, and inferring an edge
|
|
28
|
+
* from a naming habit is what golden pattern 12 exists to punish.
|
|
29
|
+
*
|
|
30
|
+
* ## Ambiguity is disclosed, never broken
|
|
31
|
+
*
|
|
32
|
+
* A `using` imports a whole namespace, so a bare name can be found under two of
|
|
33
|
+
* them at once. Real C# resolves that with the full type environment; this
|
|
34
|
+
* adapter has names only, so two candidates produce a ledger entry and no edge.
|
|
35
|
+
* Extension methods are the same answer for the same reason: `x.Foo()` where
|
|
36
|
+
* `Foo` is a static method on an unrelated class, selected by the receiver's
|
|
37
|
+
* type, is not decidable from names.
|
|
38
|
+
*/
|
|
39
|
+
import { type IdentityScope, type IREdge, type IRNode, type ResolutionLevel, type UnresolvedRef } from "@descryy/ir";
|
|
40
|
+
import type { CsFile } from "./parse.ts";
|
|
41
|
+
import { type NullableContext } from "./nullability.ts";
|
|
42
|
+
export declare const LANGUAGE = "csharp";
|
|
43
|
+
export interface ExtractInput {
|
|
44
|
+
readonly repo: string;
|
|
45
|
+
readonly scope: IdentityScope;
|
|
46
|
+
readonly producedBy: string;
|
|
47
|
+
readonly reached: ResolutionLevel;
|
|
48
|
+
readonly files: readonly CsFile[];
|
|
49
|
+
/**
|
|
50
|
+
* Repo-relative path -> source text, for the framework extractors.
|
|
51
|
+
*
|
|
52
|
+
* The Fluent API and minimal-API registrations are call chains rather than
|
|
53
|
+
* declarations, and reading them faithfully from the tree would mean modelling
|
|
54
|
+
* the whole builder. `efcore.ts` and `aspnetcore.ts` read them textually and
|
|
55
|
+
* refuse everything they cannot evaluate, which is a smaller claim honestly
|
|
56
|
+
* made — see their file comments. They need the text to do it.
|
|
57
|
+
*
|
|
58
|
+
* Empty when the caller has none: both extractors then see no files, emit
|
|
59
|
+
* nothing, and the language half is unaffected.
|
|
60
|
+
*/
|
|
61
|
+
readonly sources?: ReadonlyMap<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* The NRT context governing a file, resolved by the caller.
|
|
64
|
+
*
|
|
65
|
+
* Supplied by the adapter, which is the only layer holding the `.csproj` and
|
|
66
|
+
* the `Directory.Build.props` — DEC-180 §1's second and third sources. Without
|
|
67
|
+
* it this falls back to `#nullable` directives alone, which answers `absent`
|
|
68
|
+
* for a repository whose declaration is in its project files, and every
|
|
69
|
+
* reference-typed column comes out `unresolved`.
|
|
70
|
+
*
|
|
71
|
+
* That fallback is honest degradation rather than a guess, and it is the wrong
|
|
72
|
+
* answer for a fixture: the conformance corpus declares `<Nullable>enable</Nullable>`
|
|
73
|
+
* in `Shop.csproj` and golden 06's `discount_code` is a nullable `string?`.
|
|
74
|
+
*/
|
|
75
|
+
readonly nullableContextOf?: (file: string) => NullableContext;
|
|
76
|
+
}
|
|
77
|
+
export interface Extraction {
|
|
78
|
+
readonly nodes: readonly IRNode[];
|
|
79
|
+
readonly edges: readonly IREdge[];
|
|
80
|
+
readonly unresolved: readonly UnresolvedRef[];
|
|
81
|
+
}
|
|
82
|
+
export declare function extract(input: ExtractInput): Extraction;
|
|
83
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,MAAM,EAAwD,MAAM,YAAY,CAAC;AAG/F,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI7F,eAAO,MAAM,QAAQ,WAAW,CAAC;AAgDjC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC;CAChE;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAgCD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,UAAU,CAwlCvD"}
|