@siyavuyachagi/typesharp 0.1.1 → 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 +47 -10
- package/dist/cli/index.js +6 -4
- 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.d.ts.map +1 -1
- package/dist/generator/index.js +5 -4
- 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 -190
- 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 -2
- 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 +18 -25
- package/dist/types/typesharp-config.d.ts.map +1 -1
- package/package.json +13 -6
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,WAAW,EACX,iBAAiB,EAClB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTypeScriptFiles = exports.parseCSharpFiles = exports.
|
|
3
|
+
exports.generateTypeScriptFiles = exports.parseCSharpFiles = exports.loadConfig = exports.generate = void 0;
|
|
4
4
|
// Main exports for programmatic usage
|
|
5
5
|
var core_1 = require("./core");
|
|
6
6
|
Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return core_1.generate; } });
|
|
7
7
|
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return core_1.loadConfig; } });
|
|
8
|
-
Object.defineProperty(exports, "createSampleConfig", { enumerable: true, get: function () { return core_1.createSampleConfig; } });
|
|
9
8
|
var parser_1 = require("./parser");
|
|
10
9
|
Object.defineProperty(exports, "parseCSharpFiles", { enumerable: true, get: function () { return parser_1.parseCSharpFiles; } });
|
|
11
10
|
var generator_1 = require("./generator");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,+BAA8C;AAArC,gGAAA,QAAQ,OAAA;AAAE,kGAAA,UAAU,OAAA;AAC7B,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA;AACzB,yCAAsD;AAA7C,oHAAA,uBAAuB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAQ5D;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA+BtF"}
|
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,23 +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}(Attribute)?\\]`,
|
|
79
|
-
'g');
|
|
78
|
+
const annotationRegex = new RegExp(`\\[${targetAnnotation}(?:Attribute)?(?:\\(\\s*"([^"]*)"\\s*\\))?\\]`, 'g');
|
|
80
79
|
const matches = [...cleanContent.matchAll(annotationRegex)];
|
|
81
80
|
for (const match of matches) {
|
|
82
81
|
const startIndex = match.index;
|
|
83
82
|
const afterAnnotation = cleanContent.substring(startIndex);
|
|
84
83
|
// Check if it's an enum
|
|
85
|
-
const enumMatch = afterAnnotation.match(
|
|
84
|
+
const enumMatch = afterAnnotation.match(/(?:\[[\w]+(?:\([^)]*\))?\]\s*)*public\s+enum\s+(\w+)/);
|
|
86
85
|
if (enumMatch) {
|
|
87
|
-
const
|
|
86
|
+
const typeNameOverride = match[1] ?? undefined;
|
|
87
|
+
const enumClass = parseEnum(afterAnnotation, typeNameOverride ?? enumMatch[1]);
|
|
88
88
|
if (enumClass)
|
|
89
89
|
classes.push(enumClass);
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
92
|
// Parse as class with full generic support
|
|
93
93
|
// Matches: public class ClassName<T, U> : BaseClass<T>
|
|
94
|
-
|
|
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+)(?:<([^>]+)>)?)?/);
|
|
95
96
|
if (classMatch) {
|
|
96
97
|
const className = classMatch[1];
|
|
97
98
|
const genericParams = classMatch[2]; // e.g., "T" or "T, U"
|
|
@@ -99,7 +100,7 @@ function parseClassesFromFile(content, targetAnnotation) {
|
|
|
99
100
|
const baseGenerics = classMatch[4]; // e.g., "T" or "T, U"
|
|
100
101
|
const classBody = extractClassBody(afterAnnotation);
|
|
101
102
|
if (classBody) {
|
|
102
|
-
const properties = parseProperties(classBody);
|
|
103
|
+
const properties = (0, parse_properties_1.parseProperties)(classBody);
|
|
103
104
|
// Parse generic parameters
|
|
104
105
|
const genericParameters = genericParams
|
|
105
106
|
? genericParams.split(',').map(p => p.trim())
|
|
@@ -107,8 +108,9 @@ function parseClassesFromFile(content, targetAnnotation) {
|
|
|
107
108
|
const baseClassGenerics = baseGenerics
|
|
108
109
|
? baseGenerics.split(',').map(p => p.trim())
|
|
109
110
|
: undefined;
|
|
111
|
+
const typeNameOverride = match[1] ?? undefined;
|
|
110
112
|
classes.push({
|
|
111
|
-
name: className,
|
|
113
|
+
name: typeNameOverride ?? className,
|
|
112
114
|
properties,
|
|
113
115
|
inheritsFrom,
|
|
114
116
|
isEnum: false,
|
|
@@ -161,186 +163,6 @@ function extractClassBody(content) {
|
|
|
161
163
|
}
|
|
162
164
|
return null;
|
|
163
165
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Parse properties from class body
|
|
166
|
-
*/
|
|
167
|
-
function parseProperties(classBody) {
|
|
168
|
-
const properties = [];
|
|
169
|
-
let match;
|
|
170
|
-
// Match property declarations with get/set
|
|
171
|
-
const propertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get;\s*set;\s*\}/g;
|
|
172
|
-
while ((match = propertyRegex.exec(classBody)) !== null) {
|
|
173
|
-
const type = match[1];
|
|
174
|
-
const name = match[2];
|
|
175
|
-
properties.push(parsePropertyType(name, type));
|
|
176
|
-
}
|
|
177
|
-
// Also match computed/expression-bodied properties (with =>)
|
|
178
|
-
const computedPropertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*=>/g;
|
|
179
|
-
while ((match = computedPropertyRegex.exec(classBody)) !== null) {
|
|
180
|
-
const type = match[1];
|
|
181
|
-
const name = match[2];
|
|
182
|
-
properties.push(parsePropertyType(name, type));
|
|
183
|
-
}
|
|
184
|
-
// { get { return ...; } }
|
|
185
|
-
const getBlockRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get\s*\{[^}]*\}\s*\}/g;
|
|
186
|
-
while ((match = getBlockRegex.exec(classBody)) !== null) {
|
|
187
|
-
properties.push(parsePropertyType(match[2], match[1]));
|
|
188
|
-
}
|
|
189
|
-
// { get; set; } and { get; init; }
|
|
190
|
-
// const autoPropertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get;\s*(?:set|init);\s*\}/g;
|
|
191
|
-
// while ((match = autoPropertyRegex.exec(classBody)) !== null) {
|
|
192
|
-
// properties.push(parsePropertyType(match[2]!, match[1]!));
|
|
193
|
-
// }
|
|
194
|
-
return properties;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Find the index of the matching '>' for the first '<' at startIdx.
|
|
198
|
-
* Returns -1 if not found.
|
|
199
|
-
*/
|
|
200
|
-
function findMatchingAngleBracket(s, startIdx) {
|
|
201
|
-
let depth = 0;
|
|
202
|
-
for (let i = startIdx; i < s.length; i++) {
|
|
203
|
-
if (s[i] === '<')
|
|
204
|
-
depth++;
|
|
205
|
-
else if (s[i] === '>') {
|
|
206
|
-
depth--;
|
|
207
|
-
if (depth === 0)
|
|
208
|
-
return i;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return -1;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Split a comma-separated generic-argument string into top-level args,
|
|
215
|
-
* i.e. respects nested <...> and does NOT split commas inside nested generics.
|
|
216
|
-
* Example: "string, List<Dictionary<string, Foo>>, int" -> ["string", "List<Dictionary<string, Foo>>", "int"]
|
|
217
|
-
*/
|
|
218
|
-
function splitTopLevelGenericArgs(s) {
|
|
219
|
-
const parts = [];
|
|
220
|
-
let depth = 0;
|
|
221
|
-
let buf = '';
|
|
222
|
-
for (let i = 0; i < s.length; i++) {
|
|
223
|
-
const ch = s[i];
|
|
224
|
-
if (ch === '<') {
|
|
225
|
-
depth++;
|
|
226
|
-
buf += ch;
|
|
227
|
-
}
|
|
228
|
-
else if (ch === '>') {
|
|
229
|
-
depth--;
|
|
230
|
-
buf += ch;
|
|
231
|
-
}
|
|
232
|
-
else if (ch === ',' && depth === 0) {
|
|
233
|
-
parts.push(buf.trim());
|
|
234
|
-
buf = '';
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
buf += ch;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (buf.trim().length > 0)
|
|
241
|
-
parts.push(buf.trim());
|
|
242
|
-
return parts;
|
|
243
|
-
}
|
|
244
|
-
function parsePropertyType(name, csType) {
|
|
245
|
-
let raw = csType.trim();
|
|
246
|
-
let isNullable = false;
|
|
247
|
-
// Extract nullable marker (T?)
|
|
248
|
-
if (raw.endsWith('?')) {
|
|
249
|
-
isNullable = true;
|
|
250
|
-
raw = raw.slice(0, -1).trim();
|
|
251
|
-
}
|
|
252
|
-
// Recursive resolver: returns { tsType, isArray }
|
|
253
|
-
function resolveType(typeText) {
|
|
254
|
-
const t = typeText.trim();
|
|
255
|
-
// 1) Array syntax: T[]
|
|
256
|
-
if (t.endsWith('[]')) {
|
|
257
|
-
const inner = t.slice(0, -2).trim();
|
|
258
|
-
const resolved = resolveType(inner);
|
|
259
|
-
// If inner is already an array, keep it as array-of-array semantics;
|
|
260
|
-
// mark as array so generator will append [] (or use resolved.tsType which may include [] already)
|
|
261
|
-
return { tsType: resolved.tsType, isArray: true };
|
|
262
|
-
}
|
|
263
|
-
// 2) Dictionary-like types (handle Dictionary, IDictionary, IReadOnlyDictionary)
|
|
264
|
-
if (/^(?:[\w\.]+\.)?(?:Dictionary|IDictionary|IReadOnlyDictionary)\s*</.test(t)) {
|
|
265
|
-
// locate first '<' and its matching '>'
|
|
266
|
-
const firstAngle = t.indexOf('<');
|
|
267
|
-
const lastAngle = findMatchingAngleBracket(t, firstAngle);
|
|
268
|
-
if (firstAngle !== -1 && lastAngle !== -1) {
|
|
269
|
-
const inner = t.slice(firstAngle + 1, lastAngle).trim();
|
|
270
|
-
const args = splitTopLevelGenericArgs(inner);
|
|
271
|
-
if (args.length === 2) {
|
|
272
|
-
const keyCs = args[0];
|
|
273
|
-
const valueCs = args[1];
|
|
274
|
-
// Guard against undefined/null/empty parts before resolving
|
|
275
|
-
if (typeof keyCs !== 'string' || typeof valueCs !== 'string' || keyCs.trim() === '' || valueCs.trim() === '') {
|
|
276
|
-
// Fallback: avoid throwing — emit a generic record
|
|
277
|
-
return { tsType: 'Record<string, any>', isArray: false };
|
|
278
|
-
}
|
|
279
|
-
const resolvedKey = resolveType(keyCs);
|
|
280
|
-
const resolvedValue = resolveType(valueCs);
|
|
281
|
-
// Normalize key to a safe TS key type: Record<K extends keyof any, V>
|
|
282
|
-
// If key is not primitive 'string' or 'number' or 'symbol', coerce to 'string'
|
|
283
|
-
const keyTsRaw = resolvedKey.tsType;
|
|
284
|
-
const safeKey = keyTsRaw === 'string' || keyTsRaw === 'number' || keyTsRaw === 'symbol'
|
|
285
|
-
? keyTsRaw
|
|
286
|
-
: 'string';
|
|
287
|
-
// Build value type (respect nested arrays)
|
|
288
|
-
const valueType = resolvedValue.isArray ? `${resolvedValue.tsType}[]` : resolvedValue.tsType;
|
|
289
|
-
return { tsType: `Record<${safeKey}, ${valueType}>`, isArray: false };
|
|
290
|
-
}
|
|
291
|
-
// else: fallthrough to other checks (malformed or >2 args) — do not falsely match
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
// 3) Collections: List<T>, IEnumerable<T>, ICollection<T>, IList<T>
|
|
295
|
-
const collectionMatch = t.match(/^(?:List|IEnumerable|ICollection|IList)\s*<\s*(.+)\s*>$/);
|
|
296
|
-
if (collectionMatch) {
|
|
297
|
-
const inner = collectionMatch[1].trim();
|
|
298
|
-
const resolvedInner = resolveType(inner);
|
|
299
|
-
// Collections become inner[] in TS; mark isArray true and tsType = resolvedInner.tsType
|
|
300
|
-
// The generator will append [].
|
|
301
|
-
return { tsType: resolvedInner.tsType, isArray: true };
|
|
302
|
-
}
|
|
303
|
-
// 4) Fallback: map primitive / known types, else return as-is (class name)
|
|
304
|
-
return { tsType: mapCSharpTypeToTypeScript(t), isArray: false };
|
|
305
|
-
}
|
|
306
|
-
const resolved = resolveType(raw);
|
|
307
|
-
return {
|
|
308
|
-
name,
|
|
309
|
-
type: resolved.tsType,
|
|
310
|
-
isNullable,
|
|
311
|
-
isArray: resolved.isArray,
|
|
312
|
-
isGeneric: false,
|
|
313
|
-
genericType: undefined
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Map C# primitive types to TypeScript types
|
|
318
|
-
*/
|
|
319
|
-
function mapCSharpTypeToTypeScript(csType) {
|
|
320
|
-
const typeMap = {
|
|
321
|
-
'bool': 'boolean',
|
|
322
|
-
'byte': 'number',
|
|
323
|
-
'byte[]': 'Blob',
|
|
324
|
-
'decimal': 'number',
|
|
325
|
-
'double': 'number',
|
|
326
|
-
'DateOnly': 'string',
|
|
327
|
-
'DateTime': 'string',
|
|
328
|
-
'float': 'number',
|
|
329
|
-
'FileStream': 'Blob',
|
|
330
|
-
'FormFile': 'File',
|
|
331
|
-
'Guid': 'string',
|
|
332
|
-
'int': 'number',
|
|
333
|
-
'IFormFile': 'File',
|
|
334
|
-
'IFormFileCollection': 'File[]',
|
|
335
|
-
'long': 'number',
|
|
336
|
-
'MemoryStream': 'Blob',
|
|
337
|
-
'object': 'any',
|
|
338
|
-
'string': 'string',
|
|
339
|
-
'Stream': 'Blob',
|
|
340
|
-
'TimeOnly': 'string',
|
|
341
|
-
};
|
|
342
|
-
return typeMap[csType] || csType;
|
|
343
|
-
}
|
|
344
166
|
/**
|
|
345
167
|
* Remove single-line and multi-line comments
|
|
346
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,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UAAU,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAKD;;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,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B,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,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"}
|