@groma/scanner-csharp 0.2.0 → 0.2.2

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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/dist/index.js +15 -15
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -5,7 +5,7 @@ platform. Install the scanner and scan source without a project SDK, NuGet resto
5
5
  or application build. `global.json` does not select the scanner's runtime.
6
6
 
7
7
  ```sh
8
- groma scanner add @groma/scanner-csharp
8
+ groma plugin add @groma/scanner-csharp
9
9
  groma scan
10
10
  ```
11
11
 
@@ -110,6 +110,14 @@ expression tree. Implicit calls, initializers, generated operations,
110
110
  receiver/delegate value flow, dependency injection and network protocols are
111
111
  not resolved.
112
112
 
113
+ A file that several projects compile is analyzed once, and another of those
114
+ projects can parse it differently, for example under other `DefineConstants`.
115
+ A call from such a project to a method it declares with a body in that file
116
+ names its target when the analyzed file declares a member written with the same
117
+ name at the same position, however each project binds the member's types. When
118
+ the analyzed file declares another member there, or none, that call alone is
119
+ reported as unresolved, without a target.
120
+
113
121
  Solutions and projects supply source roots and file membership. They are not
114
122
  C4 components or proof of business collaborations. Core owns curated membership
115
123
  and relationship selection; ordinary Markdown readers see the existing OKF
package/dist/index.js CHANGED
@@ -120,13 +120,13 @@ function compare(...values) {
120
120
  }
121
121
  function uniqueBy(values, key, label) {
122
122
  const seen = new Set;
123
- for (const value of values) {
124
- const id = key(value);
123
+ const keyed = values.map((value) => ({ id: key(value), value }));
124
+ for (const { id } of keyed) {
125
125
  if (seen.has(id))
126
126
  throw new Error(`duplicate ${label}: ${id}`);
127
127
  seen.add(id);
128
128
  }
129
- return [...values].sort((left, right) => key(left).localeCompare(key(right)));
129
+ return keyed.sort((left, right) => left.id.localeCompare(right.id)).map((entry) => entry.value);
130
130
  }
131
131
  function createScanObservation(input) {
132
132
  const roots = validateRoots(input.roots);
@@ -137,9 +137,7 @@ function createScanObservation(input) {
137
137
  symbols: [...new Map(file.symbols.map((symbol) => [
138
138
  compare(symbol.id, symbol.kind),
139
139
  symbol
140
- ])).values()].sort((left, right) => {
141
- return compare(left.id, left.kind).localeCompare(compare(right.id, right.kind));
142
- })
140
+ ]))].sort(([left], [right]) => left.localeCompare(right)).map(([, symbol]) => symbol)
143
141
  })), (file) => file.file, "file path");
144
142
  const filePaths = new Set(files.map((file) => file.file));
145
143
  for (const file of files) {
@@ -150,8 +148,6 @@ function createScanObservation(input) {
150
148
  throw new Error(`file references unknown root: ${root}`);
151
149
  }
152
150
  }
153
- for (const diagnostic of input.diagnostics)
154
- diagnosticLocation(diagnostic);
155
151
  return {
156
152
  schemaVersion: 1,
157
153
  scanner: input.scanner,
@@ -161,14 +157,14 @@ function createScanObservation(input) {
161
157
  ...entryPoints(input.entryPoints, filePaths),
162
158
  ...operationEvidence(input, filePaths),
163
159
  ...httpEvidence(input.httpEndpoints, input.httpRequests, input.operations && new Set(input.operations.map((operation) => operation.id))),
164
- diagnostics: [...new Map(input.diagnostics.map((diagnostic) => [
165
- diagnosticKey(diagnostic),
166
- diagnostic
167
- ])).values()].sort((left, right) => {
168
- return diagnosticKey(left).localeCompare(diagnosticKey(right));
169
- })
160
+ diagnostics: normalizeScanDiagnostics(input.diagnostics)
170
161
  };
171
162
  }
163
+ function normalizeScanDiagnostics(diagnostics) {
164
+ for (const diagnostic of diagnostics)
165
+ diagnosticLocation(diagnostic);
166
+ return [...new Map(diagnostics.map((diagnostic) => [diagnosticKey(diagnostic), diagnostic]))].sort(([left], [right]) => left.localeCompare(right)).map(([, diagnostic]) => diagnostic);
167
+ }
172
168
  function entryPoints(input, paths) {
173
169
  if (input === undefined)
174
170
  return {};
@@ -367,10 +363,14 @@ function operationTokens(operation) {
367
363
  const endLine = Number(operation.endLine);
368
364
  if (endLine < startLine)
369
365
  throw new Error("operation.endLine must be at or after startLine");
366
+ const tokens = array(operation.tokens, "operation.tokens");
367
+ tokens.forEach((token) => {
368
+ string(token, "operation.token");
369
+ });
370
370
  return {
371
371
  startLine,
372
372
  endLine,
373
- tokens: array(operation.tokens, "operation.tokens").map((token) => string(token, "operation.token"))
373
+ tokens
374
374
  };
375
375
  }
376
376
  function validateOperationTokens(operation) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@groma/scanner-csharp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/MrLesk/Groma.md.git"
9
+ "url": "https://github.com/MrLesk/groma.md.git"
10
10
  },
11
11
  "description": "C# project evidence through Roslyn.",
12
12
  "publishConfig": {
@@ -28,11 +28,11 @@
28
28
  "x64"
29
29
  ],
30
30
  "optionalDependencies": {
31
- "@groma/scanner-csharp-darwin-arm64": "0.2.0",
32
- "@groma/scanner-csharp-linux-arm64": "0.2.0",
33
- "@groma/scanner-csharp-linux-x64": "0.2.0",
34
- "@groma/scanner-csharp-win32-arm64": "0.2.0",
35
- "@groma/scanner-csharp-win32-x64": "0.2.0"
31
+ "@groma/scanner-csharp-darwin-arm64": "0.2.2",
32
+ "@groma/scanner-csharp-linux-arm64": "0.2.2",
33
+ "@groma/scanner-csharp-linux-x64": "0.2.2",
34
+ "@groma/scanner-csharp-win32-arm64": "0.2.2",
35
+ "@groma/scanner-csharp-win32-x64": "0.2.2"
36
36
  },
37
37
  "groma": {
38
38
  "scanner": {