@siyavuyachagi/typesharp 0.1.0 → 0.1.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.
- package/LICENSE +1 -1
- package/README.md +196 -49
- package/dist/cli/index.js +7 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/core/create-sample-config.d.ts +5 -0
- package/dist/core/create-sample-config.d.ts.map +1 -0
- package/dist/core/create-sample-config.js +110 -0
- package/dist/core/create-sample-config.js.map +1 -0
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +36 -66
- package/dist/core/index.js.map +1 -1
- package/dist/generator/index.js +77 -53
- package/dist/generator/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +12 -176
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/parse-properties.d.ts +6 -0
- package/dist/parser/parse-properties.d.ts.map +1 -0
- package/dist/parser/parse-properties.js +250 -0
- package/dist/parser/parse-properties.js.map +1 -0
- package/dist/parser/resolve-project-files-from-source.d.ts +29 -0
- package/dist/parser/resolve-project-files-from-source.d.ts.map +1 -0
- package/dist/parser/resolve-project-files-from-source.js +98 -0
- package/dist/parser/resolve-project-files-from-source.js.map +1 -0
- package/dist/types/index.d.ts +7 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/naming-convention-config.d.ts +9 -0
- package/dist/types/naming-convention-config.d.ts.map +1 -0
- package/dist/types/naming-convention-config.js +3 -0
- package/dist/types/naming-convention-config.js.map +1 -0
- package/dist/types/naming-convention.d.ts +5 -0
- package/dist/types/naming-convention.d.ts.map +1 -0
- package/dist/types/naming-convention.js +3 -0
- package/dist/types/naming-convention.js.map +1 -0
- package/dist/types/typesharp-config.d.ts +29 -25
- package/dist/types/typesharp-config.d.ts.map +1 -1
- package/package.json +14 -6
package/dist/parser/index.js
CHANGED
|
@@ -37,15 +37,15 @@ exports.parseCSharpFiles = parseCSharpFiles;
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const glob_1 = require("glob");
|
|
40
|
+
const resolve_project_files_from_source_1 = require("./resolve-project-files-from-source");
|
|
41
|
+
const parse_properties_1 = require("./parse-properties");
|
|
40
42
|
/**
|
|
41
43
|
* Parse C# files in the target project(s)
|
|
42
44
|
*/
|
|
43
45
|
async function parseCSharpFiles(config) {
|
|
44
46
|
const targetAnnotation = config.targetAnnotation ?? 'TypeSharp';
|
|
45
47
|
// Convert single project to array for unified handling
|
|
46
|
-
const projectFiles =
|
|
47
|
-
? config.projectFiles
|
|
48
|
-
: [config.projectFiles];
|
|
48
|
+
const projectFiles = (0, resolve_project_files_from_source_1.resolveProjectFilesFromSource)(config.source);
|
|
49
49
|
const allResults = [];
|
|
50
50
|
// Process each project
|
|
51
51
|
for (const projectFile of projectFiles) {
|
|
@@ -75,22 +75,24 @@ function parseClassesFromFile(content, targetAnnotation) {
|
|
|
75
75
|
// Remove comments
|
|
76
76
|
const cleanContent = removeComments(content);
|
|
77
77
|
// Find all classes/enums with the target annotation
|
|
78
|
-
const annotationRegex = new RegExp(`\\[${targetAnnotation}\\]`, 'g');
|
|
78
|
+
const annotationRegex = new RegExp(`\\[${targetAnnotation}(?:Attribute)?(?:\\(\\s*"([^"]*)"\\s*\\))?\\]`, 'g');
|
|
79
79
|
const matches = [...cleanContent.matchAll(annotationRegex)];
|
|
80
80
|
for (const match of matches) {
|
|
81
81
|
const startIndex = match.index;
|
|
82
82
|
const afterAnnotation = cleanContent.substring(startIndex);
|
|
83
83
|
// Check if it's an enum
|
|
84
|
-
const enumMatch = afterAnnotation.match(
|
|
84
|
+
const enumMatch = afterAnnotation.match(/(?:\[[\w]+(?:\([^)]*\))?\]\s*)*public\s+enum\s+(\w+)/);
|
|
85
85
|
if (enumMatch) {
|
|
86
|
-
const
|
|
86
|
+
const typeNameOverride = match[1] ?? undefined;
|
|
87
|
+
const enumClass = parseEnum(afterAnnotation, typeNameOverride ?? enumMatch[1]);
|
|
87
88
|
if (enumClass)
|
|
88
89
|
classes.push(enumClass);
|
|
89
90
|
continue;
|
|
90
91
|
}
|
|
91
92
|
// Parse as class with full generic support
|
|
92
93
|
// Matches: public class ClassName<T, U> : BaseClass<T>
|
|
93
|
-
|
|
94
|
+
// Now supports multiple stacked attributes before the class declaration
|
|
95
|
+
const classMatch = afterAnnotation.match(/(?:\[[\w]+(?:\([^)]*\))?\]\s*)*public\s+class\s+(\w+)(?:<([^>]+)>)?(?:\s*:\s*(\w+)(?:<([^>]+)>)?)?/);
|
|
94
96
|
if (classMatch) {
|
|
95
97
|
const className = classMatch[1];
|
|
96
98
|
const genericParams = classMatch[2]; // e.g., "T" or "T, U"
|
|
@@ -98,7 +100,7 @@ function parseClassesFromFile(content, targetAnnotation) {
|
|
|
98
100
|
const baseGenerics = classMatch[4]; // e.g., "T" or "T, U"
|
|
99
101
|
const classBody = extractClassBody(afterAnnotation);
|
|
100
102
|
if (classBody) {
|
|
101
|
-
const properties = parseProperties(classBody);
|
|
103
|
+
const properties = (0, parse_properties_1.parseProperties)(classBody);
|
|
102
104
|
// Parse generic parameters
|
|
103
105
|
const genericParameters = genericParams
|
|
104
106
|
? genericParams.split(',').map(p => p.trim())
|
|
@@ -106,8 +108,9 @@ function parseClassesFromFile(content, targetAnnotation) {
|
|
|
106
108
|
const baseClassGenerics = baseGenerics
|
|
107
109
|
? baseGenerics.split(',').map(p => p.trim())
|
|
108
110
|
: undefined;
|
|
111
|
+
const typeNameOverride = match[1] ?? undefined;
|
|
109
112
|
classes.push({
|
|
110
|
-
name: className,
|
|
113
|
+
name: typeNameOverride ?? className,
|
|
111
114
|
properties,
|
|
112
115
|
inheritsFrom,
|
|
113
116
|
isEnum: false,
|
|
@@ -160,173 +163,6 @@ function extractClassBody(content) {
|
|
|
160
163
|
}
|
|
161
164
|
return null;
|
|
162
165
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Parse properties from class body
|
|
165
|
-
*/
|
|
166
|
-
function parseProperties(classBody) {
|
|
167
|
-
const properties = [];
|
|
168
|
-
// Match property declarations with get/set
|
|
169
|
-
const propertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get;\s*set;\s*\}/g;
|
|
170
|
-
let match;
|
|
171
|
-
while ((match = propertyRegex.exec(classBody)) !== null) {
|
|
172
|
-
const type = match[1];
|
|
173
|
-
const name = match[2];
|
|
174
|
-
properties.push(parsePropertyType(name, type));
|
|
175
|
-
}
|
|
176
|
-
// Also match computed/expression-bodied properties (with =>)
|
|
177
|
-
// These are read-only, so we'll skip them for now since they don't have set;
|
|
178
|
-
// If you want to include them, uncomment below:
|
|
179
|
-
/*
|
|
180
|
-
const computedPropertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*=>/g;
|
|
181
|
-
while ((match = computedPropertyRegex.exec(classBody)) !== null) {
|
|
182
|
-
const type = match[1]!;
|
|
183
|
-
const name = match[2]!;
|
|
184
|
-
|
|
185
|
-
properties.push(parsePropertyType(name, type));
|
|
186
|
-
}
|
|
187
|
-
*/
|
|
188
|
-
return properties;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Find the index of the matching '>' for the first '<' at startIdx.
|
|
192
|
-
* Returns -1 if not found.
|
|
193
|
-
*/
|
|
194
|
-
function findMatchingAngleBracket(s, startIdx) {
|
|
195
|
-
let depth = 0;
|
|
196
|
-
for (let i = startIdx; i < s.length; i++) {
|
|
197
|
-
if (s[i] === '<')
|
|
198
|
-
depth++;
|
|
199
|
-
else if (s[i] === '>') {
|
|
200
|
-
depth--;
|
|
201
|
-
if (depth === 0)
|
|
202
|
-
return i;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return -1;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Split a comma-separated generic-argument string into top-level args,
|
|
209
|
-
* i.e. respects nested <...> and does NOT split commas inside nested generics.
|
|
210
|
-
* Example: "string, List<Dictionary<string, Foo>>, int" -> ["string", "List<Dictionary<string, Foo>>", "int"]
|
|
211
|
-
*/
|
|
212
|
-
function splitTopLevelGenericArgs(s) {
|
|
213
|
-
const parts = [];
|
|
214
|
-
let depth = 0;
|
|
215
|
-
let buf = '';
|
|
216
|
-
for (let i = 0; i < s.length; i++) {
|
|
217
|
-
const ch = s[i];
|
|
218
|
-
if (ch === '<') {
|
|
219
|
-
depth++;
|
|
220
|
-
buf += ch;
|
|
221
|
-
}
|
|
222
|
-
else if (ch === '>') {
|
|
223
|
-
depth--;
|
|
224
|
-
buf += ch;
|
|
225
|
-
}
|
|
226
|
-
else if (ch === ',' && depth === 0) {
|
|
227
|
-
parts.push(buf.trim());
|
|
228
|
-
buf = '';
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
buf += ch;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (buf.trim().length > 0)
|
|
235
|
-
parts.push(buf.trim());
|
|
236
|
-
return parts;
|
|
237
|
-
}
|
|
238
|
-
function parsePropertyType(name, csType) {
|
|
239
|
-
let raw = csType.trim();
|
|
240
|
-
let isNullable = false;
|
|
241
|
-
// Extract nullable marker (T?)
|
|
242
|
-
if (raw.endsWith('?')) {
|
|
243
|
-
isNullable = true;
|
|
244
|
-
raw = raw.slice(0, -1).trim();
|
|
245
|
-
}
|
|
246
|
-
// Recursive resolver: returns { tsType, isArray }
|
|
247
|
-
function resolveType(typeText) {
|
|
248
|
-
const t = typeText.trim();
|
|
249
|
-
// 1) Array syntax: T[]
|
|
250
|
-
if (t.endsWith('[]')) {
|
|
251
|
-
const inner = t.slice(0, -2).trim();
|
|
252
|
-
const resolved = resolveType(inner);
|
|
253
|
-
// If inner is already an array, keep it as array-of-array semantics;
|
|
254
|
-
// mark as array so generator will append [] (or use resolved.tsType which may include [] already)
|
|
255
|
-
return { tsType: resolved.tsType, isArray: true };
|
|
256
|
-
}
|
|
257
|
-
// 2) Dictionary-like types (handle Dictionary, IDictionary, IReadOnlyDictionary)
|
|
258
|
-
if (/^(?:[\w\.]+\.)?(?:Dictionary|IDictionary|IReadOnlyDictionary)\s*</.test(t)) {
|
|
259
|
-
// locate first '<' and its matching '>'
|
|
260
|
-
const firstAngle = t.indexOf('<');
|
|
261
|
-
const lastAngle = findMatchingAngleBracket(t, firstAngle);
|
|
262
|
-
if (firstAngle !== -1 && lastAngle !== -1) {
|
|
263
|
-
const inner = t.slice(firstAngle + 1, lastAngle).trim();
|
|
264
|
-
const args = splitTopLevelGenericArgs(inner);
|
|
265
|
-
if (args.length === 2) {
|
|
266
|
-
const keyCs = args[0];
|
|
267
|
-
const valueCs = args[1];
|
|
268
|
-
// Guard against undefined/null/empty parts before resolving
|
|
269
|
-
if (typeof keyCs !== 'string' || typeof valueCs !== 'string' || keyCs.trim() === '' || valueCs.trim() === '') {
|
|
270
|
-
// Fallback: avoid throwing — emit a generic record
|
|
271
|
-
return { tsType: 'Record<string, any>', isArray: false };
|
|
272
|
-
}
|
|
273
|
-
const resolvedKey = resolveType(keyCs);
|
|
274
|
-
const resolvedValue = resolveType(valueCs);
|
|
275
|
-
// Normalize key to a safe TS key type: Record<K extends keyof any, V>
|
|
276
|
-
// If key is not primitive 'string' or 'number' or 'symbol', coerce to 'string'
|
|
277
|
-
const keyTsRaw = resolvedKey.tsType;
|
|
278
|
-
const safeKey = keyTsRaw === 'string' || keyTsRaw === 'number' || keyTsRaw === 'symbol'
|
|
279
|
-
? keyTsRaw
|
|
280
|
-
: 'string';
|
|
281
|
-
// Build value type (respect nested arrays)
|
|
282
|
-
const valueType = resolvedValue.isArray ? `${resolvedValue.tsType}[]` : resolvedValue.tsType;
|
|
283
|
-
return { tsType: `Record<${safeKey}, ${valueType}>`, isArray: false };
|
|
284
|
-
}
|
|
285
|
-
// else: fallthrough to other checks (malformed or >2 args) — do not falsely match
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// 3) Collections: List<T>, IEnumerable<T>, ICollection<T>, IList<T>
|
|
289
|
-
const collectionMatch = t.match(/^(?:List|IEnumerable|ICollection|IList)\s*<\s*(.+)\s*>$/);
|
|
290
|
-
if (collectionMatch) {
|
|
291
|
-
const inner = collectionMatch[1].trim();
|
|
292
|
-
const resolvedInner = resolveType(inner);
|
|
293
|
-
// Collections become inner[] in TS; mark isArray true and tsType = resolvedInner.tsType
|
|
294
|
-
// The generator will append [].
|
|
295
|
-
return { tsType: resolvedInner.tsType, isArray: true };
|
|
296
|
-
}
|
|
297
|
-
// 4) Fallback: map primitive / known types, else return as-is (class name)
|
|
298
|
-
return { tsType: mapCSharpTypeToTypeScript(t), isArray: false };
|
|
299
|
-
}
|
|
300
|
-
const resolved = resolveType(raw);
|
|
301
|
-
return {
|
|
302
|
-
name,
|
|
303
|
-
type: resolved.tsType,
|
|
304
|
-
isNullable,
|
|
305
|
-
isArray: resolved.isArray,
|
|
306
|
-
isGeneric: false,
|
|
307
|
-
genericType: undefined
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Map C# primitive types to TypeScript types
|
|
312
|
-
*/
|
|
313
|
-
function mapCSharpTypeToTypeScript(csType) {
|
|
314
|
-
const typeMap = {
|
|
315
|
-
'string': 'string',
|
|
316
|
-
'int': 'number',
|
|
317
|
-
'long': 'number',
|
|
318
|
-
'double': 'number',
|
|
319
|
-
'float': 'number',
|
|
320
|
-
'decimal': 'number',
|
|
321
|
-
'bool': 'boolean',
|
|
322
|
-
'DateTime': 'string',
|
|
323
|
-
'DateOnly': 'string',
|
|
324
|
-
'TimeOnly': 'string',
|
|
325
|
-
'Guid': 'string',
|
|
326
|
-
'object': 'any'
|
|
327
|
-
};
|
|
328
|
-
return typeMap[csType] || csType;
|
|
329
|
-
}
|
|
330
166
|
/**
|
|
331
167
|
* Remove single-line and multi-line comments
|
|
332
168
|
*/
|
package/dist/parser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,4CA+BC;AA9CD,uCAAyB;AACzB,2CAA6B;AAC7B,+BAA4B;AAG5B,2FAAoF;AACpF,yDAAqD;AAMrD;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,MAAuB;IAC5D,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,WAAW,CAAC;IAEhE,uDAAuD;IACvD,MAAM,YAAY,GAAG,IAAA,iEAA6B,EAAC,MAAM,CAAC,MAAO,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAkB,EAAE,CAAC;IAErC,uBAAuB;IACvB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,IAAA,WAAI,EAAC,SAAS,EAAE;YACpC,GAAG,EAAE,UAAU;YACf,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,oBAAoB,CAAC;SACzD,CAAC,CAAC;QAEH,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;YAEhE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,4DAA4D;gBAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CA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KD;;GAEG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,6BAA6B;IAC7B,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAEtD,8BAA8B;IAC9B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-properties.d.ts","sourceRoot":"","sources":["../../src/parser/parse-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,EAAE,CAsDnE"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseProperties = parseProperties;
|
|
4
|
+
/**
|
|
5
|
+
* Parse properties from class body
|
|
6
|
+
*/
|
|
7
|
+
function parseProperties(classBody) {
|
|
8
|
+
const properties = [];
|
|
9
|
+
let match;
|
|
10
|
+
// Match property declarations with get/set
|
|
11
|
+
const propertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get;\s*set;\s*\}/g;
|
|
12
|
+
while ((match = propertyRegex.exec(classBody)) !== null) {
|
|
13
|
+
const type = match[1];
|
|
14
|
+
const name = match[2];
|
|
15
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
16
|
+
if (tsAttrs.ignore)
|
|
17
|
+
continue;
|
|
18
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
19
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
20
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
21
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
22
|
+
}
|
|
23
|
+
// Also match computed/expression-bodied properties (with =>)
|
|
24
|
+
const computedPropertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*=>/g;
|
|
25
|
+
while ((match = computedPropertyRegex.exec(classBody)) !== null) {
|
|
26
|
+
const type = match[1];
|
|
27
|
+
const name = match[2];
|
|
28
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
29
|
+
if (tsAttrs.ignore)
|
|
30
|
+
continue;
|
|
31
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
32
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
33
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
34
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
35
|
+
}
|
|
36
|
+
// { get { return ...; } }
|
|
37
|
+
const getBlockRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get\s*\{[^}]*\}\s*\}/g;
|
|
38
|
+
while ((match = getBlockRegex.exec(classBody)) !== null) {
|
|
39
|
+
const type = match[1];
|
|
40
|
+
const name = match[2];
|
|
41
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
42
|
+
if (tsAttrs.ignore)
|
|
43
|
+
continue;
|
|
44
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
45
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
46
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
47
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
48
|
+
}
|
|
49
|
+
return properties;
|
|
50
|
+
}
|
|
51
|
+
function extractObsoleteInfo(classBody, matchIndex) {
|
|
52
|
+
const before = classBody.substring(0, matchIndex);
|
|
53
|
+
const lines = before.split('\n');
|
|
54
|
+
// Walk backwards, only through attribute lines and whitespace
|
|
55
|
+
// Stop as soon as we hit a line that isn't an attribute or blank
|
|
56
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
57
|
+
const line = lines[i].trim();
|
|
58
|
+
if (line === '')
|
|
59
|
+
continue;
|
|
60
|
+
// If it's an attribute line, check for Obsolete
|
|
61
|
+
if (line.startsWith('[')) {
|
|
62
|
+
const obsoleteMatch = line.match(/\[Obsolete(?:Attribute)?\s*(?:\(\s*"([^"]*)"\s*(?:,\s*(?:true|false))?\s*\))?\]/i);
|
|
63
|
+
if (obsoleteMatch) {
|
|
64
|
+
return {
|
|
65
|
+
isDeprecated: true,
|
|
66
|
+
deprecationMessage: obsoleteMatch[1] ?? undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// It's a different attribute — keep walking back (stacked attributes)
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// Hit a non-attribute, non-blank line — stop looking
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return { isDeprecated: false };
|
|
76
|
+
}
|
|
77
|
+
function extractTypeSharpAttributeInfo(classBody, matchIndex) {
|
|
78
|
+
const before = classBody.substring(0, matchIndex);
|
|
79
|
+
const lines = before.split('\n');
|
|
80
|
+
let ignore = false;
|
|
81
|
+
let overrideName;
|
|
82
|
+
let overrideType;
|
|
83
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
84
|
+
const line = lines[i].trim();
|
|
85
|
+
if (line === '')
|
|
86
|
+
continue;
|
|
87
|
+
if (!line.startsWith('['))
|
|
88
|
+
break;
|
|
89
|
+
if (/\[TypeIgnore\]/.test(line))
|
|
90
|
+
ignore = true;
|
|
91
|
+
const nameMatch = line.match(/\[TypeName\s*\(\s*"([^"]+)"\s*\)\]/);
|
|
92
|
+
if (nameMatch)
|
|
93
|
+
overrideName = nameMatch[1];
|
|
94
|
+
const asMatch = line.match(/\[TypeAs\s*\(\s*"([^"]+)"\s*\)\]/);
|
|
95
|
+
if (asMatch)
|
|
96
|
+
overrideType = asMatch[1];
|
|
97
|
+
}
|
|
98
|
+
return { ignore, overrideName, overrideType };
|
|
99
|
+
}
|
|
100
|
+
function parsePropertyType(name, csType) {
|
|
101
|
+
let raw = csType.trim();
|
|
102
|
+
let isNullable = false;
|
|
103
|
+
// Extract nullable marker (T?)
|
|
104
|
+
if (raw.endsWith('?')) {
|
|
105
|
+
isNullable = true;
|
|
106
|
+
raw = raw.slice(0, -1).trim();
|
|
107
|
+
}
|
|
108
|
+
// Recursive resolver: returns { tsType, isArray }
|
|
109
|
+
function resolveType(typeText) {
|
|
110
|
+
const t = typeText.trim();
|
|
111
|
+
// 1) Array syntax: T[]
|
|
112
|
+
if (t.endsWith('[]')) {
|
|
113
|
+
const inner = t.slice(0, -2).trim();
|
|
114
|
+
const resolved = resolveType(inner);
|
|
115
|
+
// If inner is already an array, keep it as array-of-array semantics;
|
|
116
|
+
// mark as array so generator will append [] (or use resolved.tsType which may include [] already)
|
|
117
|
+
return { tsType: resolved.tsType, isArray: true };
|
|
118
|
+
}
|
|
119
|
+
// 2) Dictionary-like types (handle Dictionary, IDictionary, IReadOnlyDictionary)
|
|
120
|
+
if (/^(?:[\w\.]+\.)?(?:Dictionary|IDictionary|IReadOnlyDictionary)\s*</.test(t)) {
|
|
121
|
+
// locate first '<' and its matching '>'
|
|
122
|
+
const firstAngle = t.indexOf('<');
|
|
123
|
+
const lastAngle = findMatchingAngleBracket(t, firstAngle);
|
|
124
|
+
if (firstAngle !== -1 && lastAngle !== -1) {
|
|
125
|
+
const inner = t.slice(firstAngle + 1, lastAngle).trim();
|
|
126
|
+
const args = splitTopLevelGenericArgs(inner);
|
|
127
|
+
if (args.length === 2) {
|
|
128
|
+
const keyCs = args[0];
|
|
129
|
+
const valueCs = args[1];
|
|
130
|
+
// Guard against undefined/null/empty parts before resolving
|
|
131
|
+
if (typeof keyCs !== 'string' || typeof valueCs !== 'string' || keyCs.trim() === '' || valueCs.trim() === '') {
|
|
132
|
+
// Fallback: avoid throwing — emit a generic record
|
|
133
|
+
return { tsType: 'Record<string, any>', isArray: false };
|
|
134
|
+
}
|
|
135
|
+
const resolvedKey = resolveType(keyCs);
|
|
136
|
+
const resolvedValue = resolveType(valueCs);
|
|
137
|
+
// Normalize key to a safe TS key type: Record<K extends keyof any, V>
|
|
138
|
+
// If key is not primitive 'string' or 'number' or 'symbol', coerce to 'string'
|
|
139
|
+
const keyTsRaw = resolvedKey.tsType;
|
|
140
|
+
const safeKey = keyTsRaw === 'string' || keyTsRaw === 'number' || keyTsRaw === 'symbol'
|
|
141
|
+
? keyTsRaw
|
|
142
|
+
: 'string';
|
|
143
|
+
// Build value type (respect nested arrays)
|
|
144
|
+
const valueType = resolvedValue.isArray ? `${resolvedValue.tsType}[]` : resolvedValue.tsType;
|
|
145
|
+
return { tsType: `Record<${safeKey}, ${valueType}>`, isArray: false };
|
|
146
|
+
}
|
|
147
|
+
// else: fallthrough to other checks (malformed or >2 args) — do not falsely match
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// 3) Collections: List<T>, IEnumerable<T>, ICollection<T>, IList<T>
|
|
151
|
+
const collectionMatch = t.match(/^(?:List|IEnumerable|ICollection|IList)\s*<\s*(.+)\s*>$/);
|
|
152
|
+
if (collectionMatch) {
|
|
153
|
+
const inner = collectionMatch[1].trim();
|
|
154
|
+
const resolvedInner = resolveType(inner);
|
|
155
|
+
// Collections become inner[] in TS; mark isArray true and tsType = resolvedInner.tsType
|
|
156
|
+
// The generator will append [].
|
|
157
|
+
return { tsType: resolvedInner.tsType, isArray: true };
|
|
158
|
+
}
|
|
159
|
+
// 4) Fallback: map primitive / known types, else return as-is (class name)
|
|
160
|
+
return { tsType: mapCSharpTypeToTypeScript(t), isArray: false };
|
|
161
|
+
}
|
|
162
|
+
const resolved = resolveType(raw);
|
|
163
|
+
return {
|
|
164
|
+
name,
|
|
165
|
+
type: resolved.tsType,
|
|
166
|
+
isNullable,
|
|
167
|
+
isArray: resolved.isArray,
|
|
168
|
+
isGeneric: false,
|
|
169
|
+
genericType: undefined,
|
|
170
|
+
isDeprecated: false,
|
|
171
|
+
deprecationMessage: undefined,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Find the index of the matching '>' for the first '<' at startIdx.
|
|
176
|
+
* Returns -1 if not found.
|
|
177
|
+
*/
|
|
178
|
+
function findMatchingAngleBracket(s, startIdx) {
|
|
179
|
+
let depth = 0;
|
|
180
|
+
for (let i = startIdx; i < s.length; i++) {
|
|
181
|
+
if (s[i] === '<')
|
|
182
|
+
depth++;
|
|
183
|
+
else if (s[i] === '>') {
|
|
184
|
+
depth--;
|
|
185
|
+
if (depth === 0)
|
|
186
|
+
return i;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return -1;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Split a comma-separated generic-argument string into top-level args,
|
|
193
|
+
* i.e. respects nested <...> and does NOT split commas inside nested generics.
|
|
194
|
+
* Example: "string, List<Dictionary<string, Foo>>, int" -> ["string", "List<Dictionary<string, Foo>>", "int"]
|
|
195
|
+
*/
|
|
196
|
+
function splitTopLevelGenericArgs(s) {
|
|
197
|
+
const parts = [];
|
|
198
|
+
let depth = 0;
|
|
199
|
+
let buf = '';
|
|
200
|
+
for (let i = 0; i < s.length; i++) {
|
|
201
|
+
const ch = s[i];
|
|
202
|
+
if (ch === '<') {
|
|
203
|
+
depth++;
|
|
204
|
+
buf += ch;
|
|
205
|
+
}
|
|
206
|
+
else if (ch === '>') {
|
|
207
|
+
depth--;
|
|
208
|
+
buf += ch;
|
|
209
|
+
}
|
|
210
|
+
else if (ch === ',' && depth === 0) {
|
|
211
|
+
parts.push(buf.trim());
|
|
212
|
+
buf = '';
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
buf += ch;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (buf.trim().length > 0)
|
|
219
|
+
parts.push(buf.trim());
|
|
220
|
+
return parts;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Map C# primitive types to TypeScript types
|
|
224
|
+
*/
|
|
225
|
+
function mapCSharpTypeToTypeScript(csType) {
|
|
226
|
+
const typeMap = {
|
|
227
|
+
'bool': 'boolean',
|
|
228
|
+
'byte': 'number',
|
|
229
|
+
'byte[]': 'Blob',
|
|
230
|
+
'decimal': 'number',
|
|
231
|
+
'double': 'number',
|
|
232
|
+
'DateOnly': 'string',
|
|
233
|
+
'DateTime': 'string',
|
|
234
|
+
'float': 'number',
|
|
235
|
+
'FileStream': 'Blob',
|
|
236
|
+
'FormFile': 'File',
|
|
237
|
+
'Guid': 'string',
|
|
238
|
+
'int': 'number',
|
|
239
|
+
'IFormFile': 'File',
|
|
240
|
+
'IFormFileCollection': 'File[]',
|
|
241
|
+
'long': 'number',
|
|
242
|
+
'MemoryStream': 'Blob',
|
|
243
|
+
'object': 'any',
|
|
244
|
+
'string': 'string',
|
|
245
|
+
'Stream': 'Blob',
|
|
246
|
+
'TimeOnly': 'string',
|
|
247
|
+
};
|
|
248
|
+
return typeMap[csType] || csType;
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=parse-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-properties.js","sourceRoot":"","sources":["../../src/parser/parse-properties.ts"],"names":[],"mappings":";;AAMA,0CAsDC;AAzDD;;GAEG;AACH,SAAgB,eAAe,CAAC,SAAiB;IAC7C,MAAM,UAAU,GAAqB,EAAE,CAAC;IAExC,IAAI,KAAK,CAAC;IAEV,2CAA2C;IAC3C,MAAM,aAAa,GAAG,yDAAyD,CAAC;IAChF,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QAEvB,MAAM,OAAO,GAAG,6BAA6B,CAAC,SAAS,EAAE,KAAK,CAAC,KAAM,CAAC,CAAC;QACvE,IAAI,OAAO,CAAC,M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QAAQ;QACf,WAAW,EAAE,MAAM;QACnB,qBAAqB,EAAE,QAAQ;QAC/B,MAAM,EAAE,QAAQ;QAChB,cAAc,EAAE,MAAM;QACtB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,QAAQ;KACvB,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a list of `.csproj` file paths from one or more source entries.
|
|
3
|
+
*
|
|
4
|
+
* Supported source types:
|
|
5
|
+
* - `.csproj` — used directly
|
|
6
|
+
* - `.sln` — parsed using regex to extract referenced `.csproj` paths
|
|
7
|
+
* - `.slnx` — parsed as XML to extract `<Project Path="..." />` entries
|
|
8
|
+
*
|
|
9
|
+
* @param source - A single path or array of paths to `.csproj`, `.sln`, or `.slnx` files
|
|
10
|
+
* @returns A flat array of resolved absolute `.csproj` file paths
|
|
11
|
+
* @throws If a source file type is not `.csproj`, `.sln`, or `.slnx`
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Single solution file
|
|
15
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.sln');
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // XML solution file
|
|
19
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.slnx');
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Mixed sources
|
|
23
|
+
* resolveProjectFilesFromSource([
|
|
24
|
+
* 'C:/MyApp/MyApp.slnx',
|
|
25
|
+
* 'C:/Other/Other.csproj'
|
|
26
|
+
* ]);
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveProjectFilesFromSource(source: string | string[]): string[];
|
|
29
|
+
//# sourceMappingURL=resolve-project-files-from-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project-files-from-source.d.ts","sourceRoot":"","sources":["../../src/parser/resolve-project-files-from-source.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CA8BjF"}
|