@ai-dev-tools/csharp-copilot-core 0.0.30 → 0.0.32

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 (60) hide show
  1. package/out/analyze/generateCodeDependency.js +3 -2
  2. package/out/analyze/generateCodeDependency.js.map +1 -1
  3. package/out/analyze/installAnalyzerTool.js +3 -2
  4. package/out/analyze/installAnalyzerTool.js.map +1 -1
  5. package/out/batch/generateCodeTests.d.ts +2 -2
  6. package/out/batch/generateCodeTests.js +55 -39
  7. package/out/batch/generateCodeTests.js.map +1 -1
  8. package/out/benchmark/generateBenchmarkReport.d.ts +1 -1
  9. package/out/benchmark/generateBenchmarkReport.js +2 -2
  10. package/out/benchmark/generateBenchmarkReport.js.map +1 -1
  11. package/out/codeCoverage/extractCodeCoverageInfo.js +2 -1
  12. package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -1
  13. package/out/codeCoverage/extractCoverageReportPath.js +2 -1
  14. package/out/codeCoverage/extractCoverageReportPath.js.map +1 -1
  15. package/out/codeCoverage/reportTool.js +2 -1
  16. package/out/codeCoverage/reportTool.js.map +1 -1
  17. package/out/command/index.js +3 -7
  18. package/out/command/index.js.map +1 -1
  19. package/out/command/utGenWrapper.d.ts +0 -1
  20. package/out/command/utGenWrapper.js +30 -23
  21. package/out/command/utGenWrapper.js.map +1 -1
  22. package/out/gen/autoFix.js +5 -1
  23. package/out/gen/autoFix.js.map +1 -1
  24. package/out/gen/postGen/addAiAnnotation.d.ts +1 -0
  25. package/out/gen/postGen/addAiAnnotation.js +57 -0
  26. package/out/gen/postGen/addAiAnnotation.js.map +1 -0
  27. package/out/gen/postGen/extractCodeFromResponse.js +2 -1
  28. package/out/gen/postGen/extractCodeFromResponse.js.map +1 -1
  29. package/out/gen/postGen/postGenProcess.js +2 -0
  30. package/out/gen/postGen/postGenProcess.js.map +1 -1
  31. package/out/gen/postGen/removeSingleLines.js +2 -1
  32. package/out/gen/postGen/removeSingleLines.js.map +1 -1
  33. package/out/gen/postGen/repairRequiredNameSpaces.js +2 -1
  34. package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -1
  35. package/out/gen/preGen/excludeSpecificTag.js +2 -1
  36. package/out/gen/preGen/excludeSpecificTag.js.map +1 -1
  37. package/out/gen/preGen/validateCode.js +2 -1
  38. package/out/gen/preGen/validateCode.js.map +1 -1
  39. package/out/types/constants.d.ts +4 -0
  40. package/out/types/constants.js +5 -1
  41. package/out/types/constants.js.map +1 -1
  42. package/out/utils/getTestFile.js +2 -0
  43. package/out/utils/getTestFile.js.map +1 -1
  44. package/out/utils/parseBuildResult.js +2 -1
  45. package/out/utils/parseBuildResult.js.map +1 -1
  46. package/out/utils/parseSyntaxCheckResult.js +2 -1
  47. package/out/utils/parseSyntaxCheckResult.js.map +1 -1
  48. package/out/utils/parseVstestResult.js +2 -1
  49. package/out/utils/parseVstestResult.js.map +1 -1
  50. package/out/utils/removeFailedTestMethods.js +2 -1
  51. package/out/utils/removeFailedTestMethods.js.map +1 -1
  52. package/out/utils/writeFailedVerifyResult.d.ts +1 -0
  53. package/out/utils/writeFailedVerifyResult.js +67 -0
  54. package/out/utils/writeFailedVerifyResult.js.map +1 -0
  55. package/out/utils/writeGenCode.d.ts +1 -1
  56. package/out/utils/writeGenCode.js +17 -4
  57. package/out/utils/writeGenCode.js.map +1 -1
  58. package/out/vsPlugin/stdListener.js +1 -1
  59. package/out/vsPlugin/stdListener.js.map +1 -1
  60. package/package.json +1 -1
@@ -41,6 +41,7 @@ const path = __importStar(require("path"));
41
41
  const generateCodeSha256_1 = require("../utils/generateCodeSha256");
42
42
  const getOrCreateDir_1 = require("../utils/getOrCreateDir");
43
43
  const spawnExec_1 = require("../utils/spawnExec");
44
+ const constants_1 = require("../types/constants");
44
45
  const DepAnalyzerDir = "./deps/";
45
46
  async function generateCodeDependency(sourceCodePath, nugetPackagePath = null) {
46
47
  const startTime = Date.now();
@@ -92,7 +93,7 @@ function codeAnalyzerCloseHandler(code, stdout, stderr) {
92
93
  function getCachedCodeDeps(sourceCodePath, depsFilePath) {
93
94
  try {
94
95
  const fileContent = fs.readFileSync(depsFilePath, 'utf-8');
95
- const lines = fileContent.split(/\r?\n/);
96
+ const lines = fileContent.split(constants_1.LINESEPARATOR);
96
97
  const cachedSha256 = lines[0];
97
98
  const depsContent = lines.slice(1).join('\n').trim();
98
99
  const currentSha256 = (0, generateCodeSha256_1.generateCodeSha256)(sourceCodePath);
@@ -112,7 +113,7 @@ function getCachedCodeDeps(sourceCodePath, depsFilePath) {
112
113
  }
113
114
  function getDependency(depsFilePath) {
114
115
  const fileContent = fs.readFileSync(depsFilePath, 'utf-8').trim();
115
- const lines = fileContent.split(/\r?\n/);
116
+ const lines = fileContent.split(constants_1.LINESEPARATOR);
116
117
  const dependencyStr = lines.slice(1).join('\n');
117
118
  return dependencyStr;
118
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateCodeDependency.js","sourceRoot":"","sources":["../../src/analyze/generateCodeDependency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wDAuBC;AAaD,4DAGC;AAED,4DAaC;AA/DD,uCAAyB;AACzB,2CAA6B;AAE7B,oEAAiE;AACjE,4DAAyD;AACzD,kDAA8C;AAE9C,MAAM,cAAc,GAAG,SAAS,CAAA;AAEzB,KAAK,UAAU,sBAAsB,CAAC,cAAsB,EAAE,mBAA2B,IAAI;IAChG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CA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AC,CAAC;QAEzD,IAAI,aAAa,KAAK,YAAY,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;YACtD,OAAO,WAAW,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,YAAoB;IACvC,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,wLAAwL;AACxL,4LAA4L;AAC5L,yJAAyJ;AACzJ,uLAAuL;AACvL,uLAAuL;AACvL,iPAAiP;AACjP,6TAA6T","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { generateCodeSha256 } from '../utils/generateCodeSha256';\r\nimport { getTmpCacheDir } from '../utils/getOrCreateDir';\r\nimport { runSpawn } from '../utils/spawnExec';\r\n\r\nconst DepAnalyzerDir = \"./deps/\"\r\n\r\nexport async function generateCodeDependency(sourceCodePath: string, nugetPackagePath: string = null): Promise<string> {\r\n const startTime = Date.now();\r\n\r\n const normalizedPath = path.normalize(sourceCodePath);\r\n const codeDepsFileName = normalizedPath.replace(\".cs\", \"\").replace(\":\", \"\").replaceAll(\".\", \"\").split(\"\\\\\").reverse().join(\"_\");\r\n const codeDepsDir = getTmpCacheDir(DepAnalyzerDir);\r\n const codeDepsFilePath = path.join(codeDepsDir, codeDepsFileName + \".deps\");\r\n let depsStr;\r\n if (fs.existsSync(codeDepsFilePath)) {\r\n depsStr = getCachedCodeDeps(normalizedPath, codeDepsFilePath);\r\n }\r\n if (!depsStr) {\r\n const { success, message } = await runCsharpCodeAnalyzer(normalizedPath, nugetPackagePath);\r\n if (!success) {\r\n console.error(`Code analysis failed: ${message}`);\r\n return \"\";\r\n }\r\n depsStr = getDependency(codeDepsFilePath);\r\n }\r\n\r\n console.log(`Generate depencency time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return depsStr;\r\n}\r\n\r\nfunction runCsharpCodeAnalyzer(sourceCodePath: string, nugetPackagePath = null): Promise<any> {\r\n const args = ['-c', sourceCodePath];\r\n if (nugetPackagePath) {\r\n args.push('-p');\r\n args.push(nugetPackagePath);\r\n }\r\n const workDir = getTmpCacheDir(DepAnalyzerDir);\r\n console.log('📦 Running Csharp code analyzer...');\r\n return runSpawn(\"ccanalyzer\", args, workDir, codeAnalyzerErrorHandler, codeAnalyzerCloseHandler);\r\n}\r\n\r\nexport function codeAnalyzerErrorHandler(error) {\r\n console.error(`codeAnalyzerErrorHandler - failed: ${error.message}`);\r\n return true;\r\n}\r\n\r\nexport function codeAnalyzerCloseHandler(code, stdout, stderr) {\r\n if (code !== 0) {\r\n console.error(`Code Analyze failed with exit code ${code}`);\r\n return { success: false, message: stdout };\r\n }\r\n\r\n if (stderr) {\r\n console.error(`Warnings/Errors:\\n${stderr}`);\r\n return { success: false, message: stdout };\r\n }\r\n\r\n console.log(`Code Analyze succeeded:\\n${stdout}`);\r\n return { success: true, message: stdout };\r\n}\r\n\r\nfunction getCachedCodeDeps(sourceCodePath: string, depsFilePath: string) {\r\n try {\r\n const fileContent = fs.readFileSync(depsFilePath, 'utf-8');\r\n\r\n const lines = fileContent.split(/\\r?\\n/);\r\n\r\n const cachedSha256 = lines[0];\r\n const depsContent = lines.slice(1).join('\\n').trim();\r\n\r\n const currentSha256 = generateCodeSha256(sourceCodePath);\r\n\r\n if (currentSha256 === cachedSha256) {\r\n console.log('code unchanged, returning cached deps.');\r\n return depsContent;\r\n } else {\r\n console.log('code has changed.');\r\n return null;\r\n }\r\n } catch (err) {\r\n console.error('Error:', err);\r\n return null;\r\n }\r\n}\r\n\r\nfunction getDependency(depsFilePath: string) {\r\n const fileContent = fs.readFileSync(depsFilePath, 'utf-8').trim();\r\n const lines = fileContent.split(/\\r?\\n/);\r\n const dependencyStr = lines.slice(1).join('\\n');\r\n return dependencyStr;\r\n}\r\n\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs\");\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs\");\r\n// generateCodeDependency(\"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantConfigManager.cs\");\r\n// generateCodeDependency(\"C:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMeResponseBuilder.cs\");\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs\");\r\n// getDependency(\"D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\deps\\\\SqmidHelper_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps\");\r\n// getCachedCodeDeps(\"D:\\\\code\\\\UCMDynamics\\\\private\\\\DynamicCode\\\\Plugin\\\\UCMDynamics.AppointmentPlugin\\\\AppointmentOperation.cs\", \"D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\deps\\\\AppointmentOperation_UCMDynamicsAppointmentPlugin_Plugin_DynamicCode_private_UCMDynamics_code_D.deps\");"]}
1
+ {"version":3,"file":"generateCodeDependency.js","sourceRoot":"","sources":["../../src/analyze/generateCodeDependency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wDAuBC;AAaD,4DAGC;AAED,4DAaC;AAhED,uCAAyB;AACzB,2CAA6B;AAE7B,oEAAiE;AACjE,4DAAyD;AACzD,kDAA8C;AAC9C,kDAAmD;AAEnD,MAAM,cAAc,GAAG,SAAS,CAAA;AAEzB,KAAK,UAAU,sBAAsB,CAAC,cAAsB,EAAE,mBAA2B,IAAI;IAChG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChI,MAAM,WAAW,GAAG,IAAA,+BAAc,EAAC,cAAc,CAAC,CAAC;IACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC;IACZ,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,C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,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,YAAoB;IACvC,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,wLAAwL;AACxL,4LAA4L;AAC5L,yJAAyJ;AACzJ,uLAAuL;AACvL,uLAAuL;AACvL,iPAAiP;AACjP,6TAA6T","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { generateCodeSha256 } from '../utils/generateCodeSha256';\r\nimport { getTmpCacheDir } from '../utils/getOrCreateDir';\r\nimport { runSpawn } from '../utils/spawnExec';\r\nimport { LINESEPARATOR } from '../types/constants';\r\n\r\nconst DepAnalyzerDir = \"./deps/\"\r\n\r\nexport async function generateCodeDependency(sourceCodePath: string, nugetPackagePath: string = null): Promise<string> {\r\n const startTime = Date.now();\r\n\r\n const normalizedPath = path.normalize(sourceCodePath);\r\n const codeDepsFileName = normalizedPath.replace(\".cs\", \"\").replace(\":\", \"\").replaceAll(\".\", \"\").split(\"\\\\\").reverse().join(\"_\");\r\n const codeDepsDir = getTmpCacheDir(DepAnalyzerDir);\r\n const codeDepsFilePath = path.join(codeDepsDir, codeDepsFileName + \".deps\");\r\n let depsStr;\r\n if (fs.existsSync(codeDepsFilePath)) {\r\n depsStr = getCachedCodeDeps(normalizedPath, codeDepsFilePath);\r\n }\r\n if (!depsStr) {\r\n const { success, message } = await runCsharpCodeAnalyzer(normalizedPath, nugetPackagePath);\r\n if (!success) {\r\n console.error(`Code analysis failed: ${message}`);\r\n return \"\";\r\n }\r\n depsStr = getDependency(codeDepsFilePath);\r\n }\r\n\r\n console.log(`Generate depencency time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return depsStr;\r\n}\r\n\r\nfunction runCsharpCodeAnalyzer(sourceCodePath: string, nugetPackagePath = null): Promise<any> {\r\n const args = ['-c', sourceCodePath];\r\n if (nugetPackagePath) {\r\n args.push('-p');\r\n args.push(nugetPackagePath);\r\n }\r\n const workDir = getTmpCacheDir(DepAnalyzerDir);\r\n console.log('📦 Running Csharp code analyzer...');\r\n return runSpawn(\"ccanalyzer\", args, workDir, codeAnalyzerErrorHandler, codeAnalyzerCloseHandler);\r\n}\r\n\r\nexport function codeAnalyzerErrorHandler(error) {\r\n console.error(`codeAnalyzerErrorHandler - failed: ${error.message}`);\r\n return true;\r\n}\r\n\r\nexport function codeAnalyzerCloseHandler(code, stdout, stderr) {\r\n if (code !== 0) {\r\n console.error(`Code Analyze failed with exit code ${code}`);\r\n return { success: false, message: stdout };\r\n }\r\n\r\n if (stderr) {\r\n console.error(`Warnings/Errors:\\n${stderr}`);\r\n return { success: false, message: stdout };\r\n }\r\n\r\n console.log(`Code Analyze succeeded:\\n${stdout}`);\r\n return { success: true, message: stdout };\r\n}\r\n\r\nfunction getCachedCodeDeps(sourceCodePath: string, depsFilePath: string) {\r\n try {\r\n const fileContent = fs.readFileSync(depsFilePath, 'utf-8');\r\n\r\n const lines = fileContent.split(LINESEPARATOR);\r\n\r\n const cachedSha256 = lines[0];\r\n const depsContent = lines.slice(1).join('\\n').trim();\r\n\r\n const currentSha256 = generateCodeSha256(sourceCodePath);\r\n\r\n if (currentSha256 === cachedSha256) {\r\n console.log('code unchanged, returning cached deps.');\r\n return depsContent;\r\n } else {\r\n console.log('code has changed.');\r\n return null;\r\n }\r\n } catch (err) {\r\n console.error('Error:', err);\r\n return null;\r\n }\r\n}\r\n\r\nfunction getDependency(depsFilePath: string) {\r\n const fileContent = fs.readFileSync(depsFilePath, 'utf-8').trim();\r\n const lines = fileContent.split(LINESEPARATOR);\r\n const dependencyStr = lines.slice(1).join('\\n');\r\n return dependencyStr;\r\n}\r\n\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs\");\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs\");\r\n// generateCodeDependency(\"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantConfigManager.cs\");\r\n// generateCodeDependency(\"C:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMeResponseBuilder.cs\");\r\n// generateCodeDependency(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs\");\r\n// getDependency(\"D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\deps\\\\SqmidHelper_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps\");\r\n// getCachedCodeDeps(\"D:\\\\code\\\\UCMDynamics\\\\private\\\\DynamicCode\\\\Plugin\\\\UCMDynamics.AppointmentPlugin\\\\AppointmentOperation.cs\", \"D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\deps\\\\AppointmentOperation_UCMDynamicsAppointmentPlugin_Plugin_DynamicCode_private_UCMDynamics_code_D.deps\");"]}
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.installOrUpdateAnalyzerTool = installOrUpdateAnalyzerTool;
4
+ const constants_1 = require("../types/constants");
4
5
  const runCommand_1 = require("../utils/runCommand");
5
6
  const packageId = 'Csharp.Code.Analyzer';
6
7
  function getInstalledVersion() {
7
8
  const output = (0, runCommand_1.runCommand)('dotnet tool list --global');
8
- const lines = output.split(/\r?\n/).slice(2); // skip header lines
9
+ const lines = output.split(constants_1.LINESEPARATOR).slice(2); // skip header lines
9
10
  for (const line of lines) {
10
11
  const parts = line.trim().split(/\s+/);
11
12
  if (parts[0].toLowerCase() === packageId.toLowerCase()) {
@@ -17,7 +18,7 @@ function getInstalledVersion() {
17
18
  function getLatestVersion() {
18
19
  console.log(`Searching for latest version of ${packageId}`);
19
20
  const output = (0, runCommand_1.runCommand)(`dotnet tool search ${packageId}`);
20
- const lines = output.split(/\r?\n/).slice(2); // skip header lines
21
+ const lines = output.split(constants_1.LINESEPARATOR).slice(2); // skip header lines
21
22
  for (const line of lines) {
22
23
  const parts = line.trim().split(/\s+/);
23
24
  if (parts[0].toLowerCase() === packageId.toLowerCase()) {
@@ -1 +1 @@
1
- {"version":3,"file":"installAnalyzerTool.js","sourceRoot":"","sources":["../../src/analyze/installAnalyzerTool.ts"],"names":[],"mappings":";;AAsDA,kEA6BC;AAnFD,oDAAiD;AAEjD,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC,SAAS,mBAAmB;IACxB,MAAM,MAAM,GAAG,IAAA,uBAAU,EAAC,2BAA2B,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;IAClE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,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,cAAc,CAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,eAAe,aAAa,KAAK,CAAC,CAAC;YACpE,IAAA,uBAAU,EAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,yBAAyB,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,yCAAyC,aAAa,KAAK,CAAC,CAAC;QACrF,IAAA,uBAAU,EAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;AAChG,CAAC;AAED,iCAAiC","sourcesContent":["import { runCommand } from '../utils/runCommand';\r\n\r\nconst packageId = 'Csharp.Code.Analyzer';\r\n\r\nfunction getInstalledVersion(): string | null {\r\n const output = runCommand('dotnet tool list --global');\r\n const lines = output.split(/\\r?\\n/).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n return parts[1];\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nfunction getLatestVersion(): string | null {\r\n console.log(`Searching for latest version of ${packageId}`);\r\n const output = runCommand(`dotnet tool search ${packageId}`);\r\n const lines = output.split(/\\r?\\n/).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n const latestVersion = parts[1];\r\n console.log(`Get the latest version: ${latestVersion}`);\r\n return latestVersion;\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nfunction isNewerVersion(current: string, latest: string): boolean {\r\n if (!latest) {\r\n return false; // Cannot compare if latest version is not available\r\n }\r\n const parse = (v: string) => v.split('.').map(Number);\r\n const [cMajor, cMinor, cPatch] = parse(current);\r\n const [lMajor, lMinor, lPatch] = parse(latest);\r\n\r\n if (lMajor > cMajor) return true;\r\n if (lMajor === cMajor && lMinor > cMinor) return true;\r\n if (lMajor === cMajor && lMinor === cMinor && lPatch > cPatch) return true;\r\n return false;\r\n}\r\n\r\nfunction ensureNugetOrgSource() {\r\n const output = runCommand('dotnet nuget list source');\r\n if (!output.includes('https://api.nuget.org/v3/index.json')) {\r\n console.log('Adding nuget.org source...');\r\n runCommand('dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org');\r\n }\r\n}\r\n\r\n\r\nexport function installOrUpdateAnalyzerTool() {\r\n const startTime = Date.now();\r\n\r\n ensureNugetOrgSource();\r\n\r\n const installedVersion = getInstalledVersion();\r\n const latestVersion = getLatestVersion();\r\n\r\n if (!latestVersion) {\r\n console.error('!!!Cannot get latest version from NuGet.');\r\n if (!installedVersion) {\r\n console.error('!!!Cannot get installed version.');\r\n return;\r\n }\r\n }\r\n\r\n if (installedVersion) {\r\n console.log(`${packageId} is installed (version ${installedVersion})`);\r\n if (isNewerVersion(installedVersion, latestVersion)) {\r\n console.log(`Updating ${packageId} to version ${latestVersion}...`);\r\n runCommand(`dotnet tool update --global ${packageId}`);\r\n } else {\r\n console.log(`${packageId} is already up to date.`);\r\n }\r\n } else {\r\n console.log(`${packageId} is not installed. Installing version ${latestVersion}...`);\r\n runCommand(`dotnet tool install --global ${packageId}`);\r\n }\r\n console.log(`InstallOrUpdateAnalyzerTool time: ${(Date.now() - startTime) / 1000} seconds`);\r\n}\r\n\r\n// installOrUpdateAnalyzerTool();\r\n"]}
1
+ {"version":3,"file":"installAnalyzerTool.js","sourceRoot":"","sources":["../../src/analyze/installAnalyzerTool.ts"],"names":[],"mappings":";;AAuDA,kEA6BC;AApFD,kDAAmD;AACnD,oDAAiD;AAEjD,MAAM,SAAS,GAAG,sBAAsB,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,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,OAAO;QACX,CAAC;IACL,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,0BAA0B,gBAAgB,GAAG,CAAC,CAAC;QACvE,IAAI,cAAc,CAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,eAAe,aAAa,KAAK,CAAC,CAAC;YACpE,IAAA,uBAAU,EAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,yBAAyB,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,yCAAyC,aAAa,KAAK,CAAC,CAAC;QACrF,IAAA,uBAAU,EAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;AAChG,CAAC;AAED,iCAAiC","sourcesContent":["import { LINESEPARATOR } from '../types/constants';\r\nimport { runCommand } from '../utils/runCommand';\r\n\r\nconst packageId = 'Csharp.Code.Analyzer';\r\n\r\nfunction getInstalledVersion(): string | null {\r\n const output = runCommand('dotnet tool list --global');\r\n const lines = output.split(LINESEPARATOR).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n return parts[1];\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nfunction getLatestVersion(): string | null {\r\n console.log(`Searching for latest version of ${packageId}`);\r\n const output = runCommand(`dotnet tool search ${packageId}`);\r\n const lines = output.split(LINESEPARATOR).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n const latestVersion = parts[1];\r\n console.log(`Get the latest version: ${latestVersion}`);\r\n return latestVersion;\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nfunction isNewerVersion(current: string, latest: string): boolean {\r\n if (!latest) {\r\n return false; // Cannot compare if latest version is not available\r\n }\r\n const parse = (v: string) => v.split('.').map(Number);\r\n const [cMajor, cMinor, cPatch] = parse(current);\r\n const [lMajor, lMinor, lPatch] = parse(latest);\r\n\r\n if (lMajor > cMajor) return true;\r\n if (lMajor === cMajor && lMinor > cMinor) return true;\r\n if (lMajor === cMajor && lMinor === cMinor && lPatch > cPatch) return true;\r\n return false;\r\n}\r\n\r\nfunction ensureNugetOrgSource() {\r\n const output = runCommand('dotnet nuget list source');\r\n if (!output.includes('https://api.nuget.org/v3/index.json')) {\r\n console.log('Adding nuget.org source...');\r\n runCommand('dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org');\r\n }\r\n}\r\n\r\n\r\nexport function installOrUpdateAnalyzerTool() {\r\n const startTime = Date.now();\r\n\r\n ensureNugetOrgSource();\r\n\r\n const installedVersion = getInstalledVersion();\r\n const latestVersion = getLatestVersion();\r\n\r\n if (!latestVersion) {\r\n console.error('!!!Cannot get latest version from NuGet.');\r\n if (!installedVersion) {\r\n console.error('!!!Cannot get installed version.');\r\n return;\r\n }\r\n }\r\n\r\n if (installedVersion) {\r\n console.log(`${packageId} is installed (version ${installedVersion})`);\r\n if (isNewerVersion(installedVersion, latestVersion)) {\r\n console.log(`Updating ${packageId} to version ${latestVersion}...`);\r\n runCommand(`dotnet tool update --global ${packageId}`);\r\n } else {\r\n console.log(`${packageId} is already up to date.`);\r\n }\r\n } else {\r\n console.log(`${packageId} is not installed. Installing version ${latestVersion}...`);\r\n runCommand(`dotnet tool install --global ${packageId}`);\r\n }\r\n console.log(`InstallOrUpdateAnalyzerTool time: ${(Date.now() - startTime) / 1000} seconds`);\r\n}\r\n\r\n// installOrUpdateAnalyzerTool();\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import { BenchmarkRow } from '../types/benchmark';
2
2
  export declare const CACHEFile: string;
3
- export declare function generateBatchTests(path: any, enableAutoFix: boolean, keepFailedTests: boolean, isBenchmark?: boolean): Promise<BenchmarkRow[]>;
4
- export declare function generateTestByCodeFiles(paths: string[], enableAutoFix: boolean, keepFailedTests: boolean, isBenchmark?: boolean, projectPath?: string, solutionPath?: string): Promise<BenchmarkRow[]>;
3
+ export declare function generateBatchTests(path: any, enableAutoFix: boolean, keepFailedTests: boolean, isBenchmark?: boolean, source?: string): Promise<BenchmarkRow[]>;
4
+ export declare function generateTestByCodeFiles(paths: string[], enableAutoFix: boolean, keepFailedTests: boolean, isBenchmark?: boolean, source?: string, projectPath?: string, solutionPath?: string): Promise<BenchmarkRow[]>;
5
5
  export declare function commentOutCsFile(testFilePath: string): void;
6
6
  export declare function isDirectory(path: string): boolean;
@@ -46,25 +46,26 @@ const csharpUtGen_1 = require("../gen/csharpUtGen");
46
46
  const getFolderCodeFile_1 = require("./getFolderCodeFile");
47
47
  const getProjectCodeFile_1 = require("./getProjectCodeFile");
48
48
  const getSolutionCodeFile_1 = require("./getSolutionCodeFile");
49
+ const stdListener_1 = require("../vsPlugin/stdListener");
49
50
  exports.CACHEFile = path.join(__dirname, "../genResultsCache.json");
50
- async function generateBatchTests(path, enableAutoFix, keepFailedTests, isBenchmark = false) {
51
+ async function generateBatchTests(path, enableAutoFix, keepFailedTests, isBenchmark = false, source = constants_1.CSHARPUTGEN) {
51
52
  let benchmarkRows;
52
53
  let projectPath;
53
54
  let solutionPath;
54
55
  if (Array.isArray(path)) {
55
- benchmarkRows = await generateTestByCodeFiles(path, enableAutoFix, keepFailedTests, isBenchmark);
56
+ benchmarkRows = await generateTestByCodeFiles(path, enableAutoFix, keepFailedTests, isBenchmark, source);
56
57
  }
57
58
  else if (isFileWithSuffix(path, '.csproj')) {
58
59
  projectPath = path;
59
60
  const codeFiles = await (0, getProjectCodeFile_1.getSourceFilesFromCsproj)(path);
60
- benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark);
61
+ benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark, source, projectPath);
61
62
  }
62
63
  else if (isFileWithSuffix(path, '.sln')) {
63
64
  solutionPath = path;
64
65
  const projectToFiles = await (0, getSolutionCodeFile_1.getSourceFilesFromSolution)(path);
65
66
  Object.entries(projectToFiles).forEach(async ([project, files]) => {
66
67
  console.log(`Project: ${project}`);
67
- const projectBenchmarkRows = await generateTestByCodeFiles(files, enableAutoFix, keepFailedTests, isBenchmark, project, solutionPath);
68
+ const projectBenchmarkRows = await generateTestByCodeFiles(files, enableAutoFix, keepFailedTests, isBenchmark, source, project, solutionPath);
68
69
  benchmarkRows.push(...projectBenchmarkRows);
69
70
  });
70
71
  }
@@ -74,47 +75,62 @@ async function generateBatchTests(path, enableAutoFix, keepFailedTests, isBenchm
74
75
  return [];
75
76
  }
76
77
  const codeFiles = await (0, getFolderCodeFile_1.getAllCsFiles)(path);
77
- benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark);
78
+ benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark, source);
78
79
  }
79
80
  return benchmarkRows;
80
81
  }
81
- async function generateTestByCodeFiles(paths, enableAutoFix, keepFailedTests, isBenchmark = false, projectPath, solutionPath) {
82
- const startTime = Date.now();
83
- const testProjectPaths = [];
84
- const genResults = getCachedGenResults();
85
- for (const codeFilePath of paths) {
86
- if (!fs.existsSync(codeFilePath)) {
87
- console.error(`Path does not exist: ${codeFilePath}`);
88
- continue;
89
- }
90
- if (isBenchmark && genResults.some(result => result.codeFilePath === codeFilePath)) {
91
- console.log(`Test code already generated for: ${codeFilePath}`);
92
- continue;
82
+ async function generateTestByCodeFiles(paths, enableAutoFix, keepFailedTests, isBenchmark = false, source = constants_1.CSHARPUTGEN, projectPath, solutionPath) {
83
+ try {
84
+ const startTime = Date.now();
85
+ const testProjectPaths = [];
86
+ const genResults = getCachedGenResults();
87
+ if (source === constants_1.CSVSPLUGIN) {
88
+ (0, stdListener_1.startStdListener)();
93
89
  }
94
- const genResult = await (0, csharpUtGen_1.generateCsharpUtCode)(codeFilePath, "", enableAutoFix, keepFailedTests, constants_1.CSHARPUTGEN, true);
95
- if (!genResult?.success && genResult?.buildResult) {
96
- // comment build failed code to unblock following tests
97
- commentOutCsFile(genResult.testFilePath);
90
+ for (const codeFilePath of paths) {
91
+ if (!fs.existsSync(codeFilePath)) {
92
+ console.error(`Path does not exist: ${codeFilePath}`);
93
+ continue;
94
+ }
95
+ if (isBenchmark && genResults.some(result => result.codeFilePath === codeFilePath)) {
96
+ console.log(`Test code already generated for: ${codeFilePath}`);
97
+ continue;
98
+ }
99
+ let genResult = await (0, csharpUtGen_1.generateCsharpUtCode)(codeFilePath, "", enableAutoFix, keepFailedTests, source, true);
100
+ if (!genResult?.success && genResult?.buildResult) {
101
+ // comment build failed code to unblock following tests
102
+ commentOutCsFile(genResult.testFilePath);
103
+ }
104
+ genResult.testFilePath && console.log(`Updated gen test to file: ${genResult.testFilePath}`);
105
+ genResult && genResults.push({
106
+ solutionPath,
107
+ projectPath,
108
+ codeFilePath,
109
+ testFilePath: genResult.testFilePath,
110
+ success: genResult.success,
111
+ buildResult: genResult.buildResult,
112
+ testResult: genResult.testResult,
113
+ });
114
+ if (genResult.testProjectPath && !testProjectPaths.includes(genResult.testProjectPath)) {
115
+ testProjectPaths.push(genResult.testProjectPath);
116
+ }
117
+ fs.writeFileSync(exports.CACHEFile, JSON.stringify(genResults), 'utf-8');
118
+ console.log(`Current progress: ${genResults?.length / paths.length} (${genResults?.length}/${paths.length})`);
98
119
  }
99
- genResult.testFilePath && console.log(`Updated gen test to file: ${genResult.testFilePath}`);
100
- genResult && genResults.push({
101
- solutionPath,
102
- projectPath,
103
- codeFilePath,
104
- testFilePath: genResult.testFilePath,
105
- success: genResult.success,
106
- buildResult: genResult.buildResult,
107
- testResult: genResult.testResult,
108
- });
109
- if (genResult.testProjectPath && !testProjectPaths.includes(genResult.testProjectPath)) {
110
- testProjectPaths.push(genResult.testProjectPath);
120
+ await (0, generateCodeCoverageReport_1.generateCodeCoverageReport)(testProjectPaths, paths);
121
+ console.log(`Batch Generate UT time: ${(Date.now() - startTime) / 1000} seconds`);
122
+ return genResults;
123
+ }
124
+ catch (error) {
125
+ console.error("Error in generateTestByCodeFiles:", error);
126
+ return [];
127
+ }
128
+ finally {
129
+ // Close the std listener if it was started in this function
130
+ if (source === constants_1.CSVSPLUGIN && stdListener_1.readLineInterface) {
131
+ stdListener_1.readLineInterface.close();
111
132
  }
112
- fs.writeFileSync(exports.CACHEFile, JSON.stringify(genResults), 'utf-8');
113
- console.log(`Current progress: ${genResults?.length / paths.length} (${genResults?.length}/${paths.length})`);
114
133
  }
115
- await (0, generateCodeCoverageReport_1.generateCodeCoverageReport)(testProjectPaths, paths);
116
- console.log(`Batch Generate UT time: ${(Date.now() - startTime) / 1000} seconds`);
117
- return genResults;
118
134
  }
119
135
  function isFileWithSuffix(filePath, suffix) {
120
136
  return filePath.toLowerCase().endsWith(suffix.toLowerCase());
@@ -130,7 +146,7 @@ function getCachedGenResults() {
130
146
  function commentOutCsFile(testFilePath) {
131
147
  const content = fs.readFileSync(testFilePath, 'utf-8');
132
148
  const commented = content
133
- .split(/\r?\n/)
149
+ .split(constants_1.LINESEPARATOR)
134
150
  .map(line => `// ${line}`)
135
151
  .join('\n');
136
152
  fs.writeFileSync(testFilePath, commented, 'utf-8');
@@ -1 +1 @@
1
- {"version":3,"file":"generateCodeTests.js","sourceRoot":"","sources":["../../src/batch/generateCodeTests.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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OAAO,UAAU,CAAC;AACtB,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB,EAAE,MAAc;IACtD,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB;IACxB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAS,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAS,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,SAAgB,gBAAgB,CAAC,YAAoB;IACjD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,OAAO;SACpB,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhB,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,WAAW,CAAC,IAAY;IACpC,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { BenchmarkRow } from '../types/benchmark';\r\nimport { CSHARPUTGEN } from '../types/constants';\r\nimport { generateCodeCoverageReport } from '../codeCoverage/generateCodeCoverageReport';\r\nimport { generateCsharpUtCode } from \"../gen/csharpUtGen\";\r\nimport { getAllCsFiles } from './getFolderCodeFile';\r\nimport { getSourceFilesFromCsproj } from './getProjectCodeFile';\r\nimport { getSourceFilesFromSolution } from './getSolutionCodeFile';\r\n\r\nexport const CACHEFile = path.join(__dirname, \"../genResultsCache.json\");\r\nexport async function generateBatchTests(\r\n path: any,\r\n enableAutoFix: boolean,\r\n keepFailedTests: boolean,\r\n isBenchmark: boolean = false): Promise<BenchmarkRow[]> {\r\n let benchmarkRows;\r\n let projectPath;\r\n let solutionPath;\r\n if (Array.isArray(path)) {\r\n benchmarkRows = await generateTestByCodeFiles(path, enableAutoFix, keepFailedTests, isBenchmark);\r\n } else if (isFileWithSuffix(path, '.csproj')) {\r\n projectPath = path;\r\n const codeFiles = await getSourceFilesFromCsproj(path);\r\n benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark);\r\n } else if (isFileWithSuffix(path, '.sln')) {\r\n solutionPath = path;\r\n const projectToFiles = await getSourceFilesFromSolution(path);\r\n Object.entries(projectToFiles).forEach(async ([project, files]) => {\r\n console.log(`Project: ${project}`);\r\n const projectBenchmarkRows = await generateTestByCodeFiles(files, enableAutoFix, keepFailedTests, isBenchmark, project, solutionPath);\r\n benchmarkRows.push(...projectBenchmarkRows);\r\n });\r\n } else {\r\n if (!isDirectory(path)) {\r\n console.error(`Invalid path: ${path}. It should be a directory, .csproj, or .sln file.`);\r\n return [];\r\n }\r\n const codeFiles = await getAllCsFiles(path);\r\n benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark);\r\n }\r\n\r\n return benchmarkRows;\r\n}\r\n\r\nexport async function generateTestByCodeFiles(\r\n paths: string[],\r\n enableAutoFix: boolean,\r\n keepFailedTests: boolean,\r\n isBenchmark: boolean = false,\r\n projectPath?: string,\r\n solutionPath?: string\r\n): Promise<BenchmarkRow[]> {\r\n const startTime = Date.now();\r\n\r\n const testProjectPaths = [];\r\n const genResults = getCachedGenResults();\r\n for (const codeFilePath of paths) {\r\n if (!fs.existsSync(codeFilePath)) {\r\n console.error(`Path does not exist: ${codeFilePath}`);\r\n continue;\r\n }\r\n\r\n if (isBenchmark && genResults.some(result => result.codeFilePath === codeFilePath)) {\r\n console.log(`Test code already generated for: ${codeFilePath}`);\r\n continue;\r\n }\r\n\r\n const genResult = await generateCsharpUtCode(codeFilePath, \"\", enableAutoFix, keepFailedTests, CSHARPUTGEN, true);\r\n if (!genResult?.success && genResult?.buildResult) {\r\n // comment build failed code to unblock following tests\r\n commentOutCsFile(genResult.testFilePath);\r\n }\r\n genResult.testFilePath && console.log(`Updated gen test to file: ${genResult.testFilePath}`);\r\n\r\n genResult && genResults.push({\r\n solutionPath,\r\n projectPath,\r\n codeFilePath,\r\n testFilePath: genResult.testFilePath, \r\n success: genResult.success,\r\n buildResult: genResult.buildResult,\r\n testResult: genResult.testResult,\r\n });\r\n\r\n if (genResult.testProjectPath && !testProjectPaths.includes(genResult.testProjectPath)) {\r\n testProjectPaths.push(genResult.testProjectPath);\r\n }\r\n\r\n fs.writeFileSync(CACHEFile, JSON.stringify(genResults), 'utf-8');\r\n console.log(`Current progress: ${genResults?.length / paths.length} (${genResults?.length}/${paths.length})`);\r\n }\r\n\r\n await generateCodeCoverageReport(testProjectPaths, paths);\r\n\r\n console.log(`Batch Generate UT time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return genResults;\r\n}\r\n\r\nfunction isFileWithSuffix(filePath: string, suffix: string): boolean {\r\n return filePath.toLowerCase().endsWith(suffix.toLowerCase());\r\n}\r\n\r\nfunction getCachedGenResults() {\r\n if (!fs.existsSync(CACHEFile)) {\r\n return [];\r\n }\r\n const cachedData = fs.readFileSync(CACHEFile, 'utf-8');\r\n const genResults = JSON.parse(cachedData);\r\n return genResults;\r\n}\r\n\r\nexport function commentOutCsFile(testFilePath: string) {\r\n const content = fs.readFileSync(testFilePath, 'utf-8');\r\n const commented = content\r\n .split(/\\r?\\n/)\r\n .map(line => `// ${line}`)\r\n .join('\\n');\r\n\r\n fs.writeFileSync(testFilePath, commented, 'utf-8');\r\n console.log(`Commented out test file: ${testFilePath}`);\r\n}\r\n\r\nexport function isDirectory(path: string): boolean {\r\n try {\r\n return fs.statSync(path).isDirectory();\r\n } catch (err) {\r\n return false;\r\n }\r\n}"]}
1
+ {"version":3,"file":"generateCodeTests.js","sourceRoot":"","sources":["../../src/batch/generateCodeTests.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,gDAiCC;AAED,0DAsEC;AAeD,4CASC;AAED,kCAMC;AAtJD,uCAAyB;AACzB,2CAA6B;AAG7B,kDAA4E;AAC5E,2FAAwF;AACxF,oDAA0D;AAC1D,2DAAoD;AACpD,6DAAgE;AAChE,+DAAmE;AACnE,yDAA8E;AAEjE,QAAA,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;AAClE,KAAK,UAAU,kBAAkB,CACpC,IAAS,EACT,aAAsB,EACtB,eAAwB,EACxB,cAAuB,KAAK,EAC5B,SAAiB,uBAAW;IAC5B,IAAI,aAAa,CAAC;IAClB,IAAI,WAAW,CAAC;IAChB,IAAI,YAAY,CAAC;IACjB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,aAAa,GAAG,MAAM,uBAAuB,CAAC,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7G,CAAC;SAAM,IAAI,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;QAC3C,WAAW,GAAG,IAAI,CAAC;QACnB,MAAM,SAAS,GAAG,MAAM,IAAA,6CAAwB,EAAC,IAAI,CAAC,CAAC;QACvD,aAAa,GAAG,MAAM,uBAAuB,CAAC,SAAS,EAAE,aAAa,EA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AAY,CAAC,iBAAS,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,SAAgB,gBAAgB,CAAC,YAAoB;IACjD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,OAAO;SACpB,KAAK,CAAC,yBAAa,CAAC;SACpB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhB,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,WAAW,CAAC,IAAY;IACpC,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { BenchmarkRow } from '../types/benchmark';\r\nimport { CSHARPUTGEN, CSVSPLUGIN, LINESEPARATOR } from '../types/constants';\r\nimport { generateCodeCoverageReport } from '../codeCoverage/generateCodeCoverageReport';\r\nimport { generateCsharpUtCode } from \"../gen/csharpUtGen\";\r\nimport { getAllCsFiles } from './getFolderCodeFile';\r\nimport { getSourceFilesFromCsproj } from './getProjectCodeFile';\r\nimport { getSourceFilesFromSolution } from './getSolutionCodeFile';\r\nimport { readLineInterface, startStdListener } from \"../vsPlugin/stdListener\";\r\n\r\nexport const CACHEFile = path.join(__dirname, \"../genResultsCache.json\");\r\nexport async function generateBatchTests(\r\n path: any,\r\n enableAutoFix: boolean,\r\n keepFailedTests: boolean,\r\n isBenchmark: boolean = false,\r\n source: string = CSHARPUTGEN): Promise<BenchmarkRow[]> {\r\n let benchmarkRows;\r\n let projectPath;\r\n let solutionPath;\r\n if (Array.isArray(path)) {\r\n benchmarkRows = await generateTestByCodeFiles(path, enableAutoFix, keepFailedTests, isBenchmark, source);\r\n } else if (isFileWithSuffix(path, '.csproj')) {\r\n projectPath = path;\r\n const codeFiles = await getSourceFilesFromCsproj(path);\r\n benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark, source, projectPath);\r\n } else if (isFileWithSuffix(path, '.sln')) {\r\n solutionPath = path;\r\n const projectToFiles = await getSourceFilesFromSolution(path);\r\n Object.entries(projectToFiles).forEach(async ([project, files]) => {\r\n console.log(`Project: ${project}`);\r\n const projectBenchmarkRows = await generateTestByCodeFiles(files, enableAutoFix, keepFailedTests, isBenchmark, source, project, solutionPath);\r\n benchmarkRows.push(...projectBenchmarkRows);\r\n });\r\n } else {\r\n if (!isDirectory(path)) {\r\n console.error(`Invalid path: ${path}. It should be a directory, .csproj, or .sln file.`);\r\n return [];\r\n }\r\n const codeFiles = await getAllCsFiles(path);\r\n benchmarkRows = await generateTestByCodeFiles(codeFiles, enableAutoFix, keepFailedTests, isBenchmark, source);\r\n }\r\n\r\n return benchmarkRows;\r\n}\r\n\r\nexport async function generateTestByCodeFiles(\r\n paths: string[],\r\n enableAutoFix: boolean,\r\n keepFailedTests: boolean,\r\n isBenchmark: boolean = false,\r\n source: string = CSHARPUTGEN,\r\n projectPath?: string,\r\n solutionPath?: string,\r\n): Promise<BenchmarkRow[]> {\r\n try {\r\n const startTime = Date.now();\r\n\r\n const testProjectPaths = [];\r\n const genResults = getCachedGenResults();\r\n\r\n if (source === CSVSPLUGIN) {\r\n startStdListener();\r\n }\r\n\r\n for (const codeFilePath of paths) {\r\n if (!fs.existsSync(codeFilePath)) {\r\n console.error(`Path does not exist: ${codeFilePath}`);\r\n continue;\r\n }\r\n\r\n if (isBenchmark && genResults.some(result => result.codeFilePath === codeFilePath)) {\r\n console.log(`Test code already generated for: ${codeFilePath}`);\r\n continue;\r\n }\r\n\r\n let genResult = await generateCsharpUtCode(codeFilePath, \"\", enableAutoFix, keepFailedTests, source, true);\r\n\r\n if (!genResult?.success && genResult?.buildResult) {\r\n // comment build failed code to unblock following tests\r\n commentOutCsFile(genResult.testFilePath);\r\n }\r\n genResult.testFilePath && console.log(`Updated gen test to file: ${genResult.testFilePath}`);\r\n\r\n genResult && genResults.push({\r\n solutionPath,\r\n projectPath,\r\n codeFilePath,\r\n testFilePath: genResult.testFilePath, \r\n success: genResult.success,\r\n buildResult: genResult.buildResult,\r\n testResult: genResult.testResult,\r\n });\r\n\r\n if (genResult.testProjectPath && !testProjectPaths.includes(genResult.testProjectPath)) {\r\n testProjectPaths.push(genResult.testProjectPath);\r\n }\r\n\r\n fs.writeFileSync(CACHEFile, JSON.stringify(genResults), 'utf-8');\r\n console.log(`Current progress: ${genResults?.length / paths.length} (${genResults?.length}/${paths.length})`);\r\n }\r\n\r\n await generateCodeCoverageReport(testProjectPaths, paths);\r\n\r\n console.log(`Batch Generate UT time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return genResults;\r\n } catch (error) {\r\n console.error(\"Error in generateTestByCodeFiles:\", error);\r\n return [];\r\n } finally {\r\n // Close the std listener if it was started in this function\r\n if (source === CSVSPLUGIN && readLineInterface) {\r\n readLineInterface.close();\r\n }\r\n }\r\n}\r\n\r\nfunction isFileWithSuffix(filePath: string, suffix: string): boolean {\r\n return filePath.toLowerCase().endsWith(suffix.toLowerCase());\r\n}\r\n\r\nfunction getCachedGenResults() {\r\n if (!fs.existsSync(CACHEFile)) {\r\n return [];\r\n }\r\n const cachedData = fs.readFileSync(CACHEFile, 'utf-8');\r\n const genResults = JSON.parse(cachedData);\r\n return genResults;\r\n}\r\n\r\nexport function commentOutCsFile(testFilePath: string) {\r\n const content = fs.readFileSync(testFilePath, 'utf-8');\r\n const commented = content\r\n .split(LINESEPARATOR)\r\n .map(line => `// ${line}`)\r\n .join('\\n');\r\n\r\n fs.writeFileSync(testFilePath, commented, 'utf-8');\r\n console.log(`Commented out test file: ${testFilePath}`);\r\n}\r\n\r\nexport function isDirectory(path: string): boolean {\r\n try {\r\n return fs.statSync(path).isDirectory();\r\n } catch (err) {\r\n return false;\r\n }\r\n}"]}
@@ -1 +1 @@
1
- export declare function generateBenchmarkReport(inputPath: any, enableAutoFix: boolean, keepFailedTests: boolean): Promise<void>;
1
+ export declare function generateBenchmarkReport(inputPath: any, enableAutoFix: boolean, keepFailedTests: boolean, source: string): Promise<void>;
@@ -38,8 +38,8 @@ const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
39
  const generateCodeTests_1 = require("../batch/generateCodeTests");
40
40
  const formatToMarkdown_1 = require("./formatToMarkdown");
41
- async function generateBenchmarkReport(inputPath, enableAutoFix, keepFailedTests) {
42
- const benchmarkRows = await (0, generateCodeTests_1.generateBatchTests)(inputPath, enableAutoFix, keepFailedTests, true);
41
+ async function generateBenchmarkReport(inputPath, enableAutoFix, keepFailedTests, source) {
42
+ const benchmarkRows = await (0, generateCodeTests_1.generateBatchTests)(inputPath, enableAutoFix, keepFailedTests, true, source);
43
43
  convertToMarkdown(benchmarkRows);
44
44
  }
45
45
  function formatCachedGenResults() {
@@ -1 +1 @@
1
- {"version":3,"file":"generateBenchmarkReport.js","sourceRoot":"","sources":["../../src/benchmark/generateBenchmarkReport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,0DAIC;AAXD,uCAAyB;AACzB,2CAA6B;AAE7B,kEAA2E;AAE3E,yDAAqD;AAE9C,KAAK,UAAU,uBAAuB,CAAC,SAAc,EAAE,aAAsB,EAAE,eAAwB;IAC1G,MAAM,aAAa,GAAG,MAAM,IAAA,sCAAkB,EAAC,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IAEhG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,sBAAsB;IAC3B,MAAM,sBAAsB,GAAG,EAAE,CAAC,YAAY,CAAC,6BAAS,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC9D,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,iBAAiB,CAAC,aAAa;IACpC,MAAM,eAAe,GAAG,IAAA,kCAAe,EAAC,aAAa,CAAC,CAAC;IACvD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxF,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,kCAAkC,mBAAmB,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,sBAAsB;AACtB,6KAA6K;AAC7K,wKAAwK;AACxK,kJAAkJ;AAClJ,gJAAgJ;AAChJ,iKAAiK;AACjK,oKAAoK;AACpK,wKAAwK;AACxK,mLAAmL;AACnL,sKAAsK;AACtK,uKAAuK;AACvK,sKAAsK;AACtK,0KAA0K;AAC1K,sKAAsK;AACtK,wKAAwK;AACxK,kKAAkK;AAClK,4KAA4K;AAC5K,8KAA8K;AAC9K,wKAAwK;AACxK,kLAAkL;AAClL,KAAK;AAEL,kDAAkD;AAElD,4BAA4B;AAG5B,wJAAwJ;AACxJ,0JAA0J;AAC1J,oLAAoL","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { CACHEFile, generateBatchTests } from '../batch/generateCodeTests';\r\n\r\nimport { toMarkdownTable } from './formatToMarkdown';\r\n\r\nexport async function generateBenchmarkReport(inputPath: any, enableAutoFix: boolean, keepFailedTests: boolean) {\r\n const benchmarkRows = await generateBatchTests(inputPath, enableAutoFix, keepFailedTests, true);\r\n\r\n convertToMarkdown(benchmarkRows);\r\n}\r\n\r\nfunction formatCachedGenResults() {\r\n const cachedBenchmarkRowsStr = fs.readFileSync(CACHEFile, 'utf-8');\r\n const cacheBenchmarkRows = JSON.parse(cachedBenchmarkRowsStr);\r\n convertToMarkdown(cacheBenchmarkRows);\r\n}\r\n\r\nfunction convertToMarkdown(benchmarkRows) {\r\n const formattedReport = toMarkdownTable(benchmarkRows);\r\n const benchmarkReportPath = path.join(__dirname, `../benchmarkReport_${Date.now()}.md`);\r\n fs.writeFileSync(benchmarkReportPath, formattedReport, 'utf-8');\r\n console.log(`Benchmark report generated at: ${benchmarkReportPath}`);\r\n}\r\n\r\n// const codeFiles = [\r\n// // \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\Teaser\\\\PostProcess\\\\AlertContentPostProcessor.cs\",\r\n// // \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantRankResponseBuilder.cs\",\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\DataModel\\\\EplantRank.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\EplantConfigManager.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantPlantRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMeResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\LocationSearch\\\\GeoLocationIDFirstCondition.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantTreeRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantTreeResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantUserUpdateCondition.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantUserUpdateRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantUserUpdateResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\LocationSearch\\\\LocationsResponseCombiner.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs'\r\n// ];\r\n\r\n// generateBenchmarkReport(codeFiles, true, true);\r\n\r\n// formatCachedGenResults();\r\n\r\n\r\n// generateBenchmarkReport(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\\", true, true);\r\n// generateBenchmarkReport(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\\", true, true);\r\n// generateBenchmarkReport(\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\SharedSegments.Plugins.csproj\", true, true);"]}
1
+ {"version":3,"file":"generateBenchmarkReport.js","sourceRoot":"","sources":["../../src/benchmark/generateBenchmarkReport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,0DAIC;AAXD,uCAAyB;AACzB,2CAA6B;AAE7B,kEA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LAAoL","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { CACHEFile, generateBatchTests } from '../batch/generateCodeTests';\r\n\r\nimport { toMarkdownTable } from './formatToMarkdown';\r\n\r\nexport async function generateBenchmarkReport(inputPath: any, enableAutoFix: boolean, keepFailedTests: boolean, source: string) {\r\n const benchmarkRows = await generateBatchTests(inputPath, enableAutoFix, keepFailedTests, true, source);\r\n\r\n convertToMarkdown(benchmarkRows);\r\n}\r\n\r\nfunction formatCachedGenResults() {\r\n const cachedBenchmarkRowsStr = fs.readFileSync(CACHEFile, 'utf-8');\r\n const cacheBenchmarkRows = JSON.parse(cachedBenchmarkRowsStr);\r\n convertToMarkdown(cacheBenchmarkRows);\r\n}\r\n\r\nfunction convertToMarkdown(benchmarkRows) {\r\n const formattedReport = toMarkdownTable(benchmarkRows);\r\n const benchmarkReportPath = path.join(__dirname, `../benchmarkReport_${Date.now()}.md`);\r\n fs.writeFileSync(benchmarkReportPath, formattedReport, 'utf-8');\r\n console.log(`Benchmark report generated at: ${benchmarkReportPath}`);\r\n}\r\n\r\n// const codeFiles = [\r\n// // \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\Teaser\\\\PostProcess\\\\AlertContentPostProcessor.cs\",\r\n// // \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantRankResponseBuilder.cs\",\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\DataModel\\\\EplantRank.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\EplantConfigManager.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs',\r\n// 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantPlantRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMeResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\LocationSearch\\\\GeoLocationIDFirstCondition.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantTreeRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantTreeResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantUserUpdateCondition.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantUserUpdateRequestBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantUserUpdateResponseBuilder.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\LocationSearch\\\\LocationsResponseCombiner.cs',\r\n// // 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs'\r\n// ];\r\n\r\n// generateBenchmarkReport(codeFiles, true, true);\r\n\r\n// formatCachedGenResults();\r\n\r\n\r\n// generateBenchmarkReport(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\\", true, true);\r\n// generateBenchmarkReport(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\\", true, true);\r\n// generateBenchmarkReport(\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\SharedSegments.Plugins.csproj\", true, true);"]}
@@ -37,8 +37,9 @@ exports.extractCoberturaXmlPath = extractCoberturaXmlPath;
37
37
  exports.getLineCoverage = getLineCoverage;
38
38
  const fs = __importStar(require("fs"));
39
39
  const fast_xml_parser_1 = require("fast-xml-parser");
40
+ const constants_1 = require("../types/constants");
40
41
  function extractCoberturaXmlPath(log) {
41
- const lines = log.split(/\r?\n/);
42
+ const lines = log.split(constants_1.LINESEPARATOR);
42
43
  const startIndex = lines.findIndex((line) => line.trim() === "Attachments:");
43
44
  if (startIndex === -1)
44
45
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"extractCodeCoverageInfo.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCodeCoverageInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,0DAcC;AAED,0CA0BC;AA7CD,uCAAyB;AACzB,qDAA4C;AAE5C,SAAgB,uBAAuB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEjC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,cAAc,CAAC,CAAC;IAC7E,IAAI,UAAU,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,eAAuB;IACnD,YAAY;IACZ,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC;QACzB,gBAAgB,EAAE,KAAK;QACvB,mBAAmB,EAAE,EAAE;KAC1B,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAExC,mBAAmB;IACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEzE,qCAAqC;IACrC,qDAAqD;IACrD,0CAA0C;IAC1C,sDAAsD;IACtD,uCAAuC;IAEvC,gDAAgD;IAChD,kCAAkC;IAClC,6CAA6C;IAC7C,qDAAqD;IACrD,iEAAiE;IACjE,MAAM;AACV,CAAC;AAED,uKAAuK;AACvK,uKAAuK;AACvK,mKAAmK","sourcesContent":["import * as fs from 'fs';\r\nimport { XMLParser } from 'fast-xml-parser';\r\n\r\nexport function extractCoberturaXmlPath(log: string): string | null {\r\n const lines = log.split(/\\r?\\n/);\r\n\r\n const startIndex = lines.findIndex((line) => line.trim() === \"Attachments:\");\r\n if (startIndex === -1) return null;\r\n\r\n for (let i = startIndex + 1; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n if (line.endsWith(\".cobertura.xml\")) {\r\n return line;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function getLineCoverage(coverageXmlPath: string) {\r\n // parse XML\r\n const xmlContent = fs.readFileSync(coverageXmlPath, 'utf-8');\r\n const parser = new XMLParser({\r\n ignoreAttributes: false,\r\n attributeNamePrefix: '',\r\n });\r\n const result = parser.parse(xmlContent);\r\n\r\n // extract coverage\r\n const coverage = result.coverage;\r\n const totalLineRate = parseFloat(coverage['line-rate']);\r\n console.log(`Total Line Coverage: ${(totalLineRate * 100).toFixed(2)}%`);\r\n\r\n // // extract coverage for each class\r\n // const packages = coverage.packages?.package ?? [];\r\n // const classes = Array.isArray(packages)\r\n // ? packages.flatMap(p => p.classes?.class ?? [])\r\n // : packages.classes?.class ?? [];\r\n\r\n // console.log('\\n📁 Per-Class Line Coverage:');\r\n // classes.forEach((cls: any) => {\r\n // const file = cls.filename || cls.name;\r\n // const lineRate = parseFloat(cls['line-rate']);\r\n // console.log(`- ${file}: ${(lineRate * 100).toFixed(2)}%`);\r\n // });\r\n}\r\n\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\505883d3-b9b2-47e2-99e5-468b7120268f\\\\jixiongge_CPC-jixio-9B9DD_2025-07-11.17_14_56.cobertura.xml\");\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\3bdc7736-f79d-4866-874a-58bd31be18d4\\\\jixiongge_CPC-jixio-9B9DD_2025-07-10.21_45_35.cobertura.xml\");\r\n// getCodeCoverageSetting(\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\");"]}
1
+ {"version":3,"file":"extractCodeCoverageInfo.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCodeCoverageInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,0DAcC;AAED,0CA0BC;AA9CD,uCAAyB;AACzB,qDAA4C;AAC5C,kDAAmD;AAEnD,SAAgB,uBAAuB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;IAEvC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,E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","sourcesContent":["import * as fs from 'fs';\r\nimport { XMLParser } from 'fast-xml-parser';\r\nimport { LINESEPARATOR } from '../types/constants';\r\n\r\nexport function extractCoberturaXmlPath(log: string): string | null {\r\n const lines = log.split(LINESEPARATOR);\r\n\r\n const startIndex = lines.findIndex((line) => line.trim() === \"Attachments:\");\r\n if (startIndex === -1) return null;\r\n\r\n for (let i = startIndex + 1; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n if (line.endsWith(\".cobertura.xml\")) {\r\n return line;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function getLineCoverage(coverageXmlPath: string) {\r\n // parse XML\r\n const xmlContent = fs.readFileSync(coverageXmlPath, 'utf-8');\r\n const parser = new XMLParser({\r\n ignoreAttributes: false,\r\n attributeNamePrefix: '',\r\n });\r\n const result = parser.parse(xmlContent);\r\n\r\n // extract coverage\r\n const coverage = result.coverage;\r\n const totalLineRate = parseFloat(coverage['line-rate']);\r\n console.log(`Total Line Coverage: ${(totalLineRate * 100).toFixed(2)}%`);\r\n\r\n // // extract coverage for each class\r\n // const packages = coverage.packages?.package ?? [];\r\n // const classes = Array.isArray(packages)\r\n // ? packages.flatMap(p => p.classes?.class ?? [])\r\n // : packages.classes?.class ?? [];\r\n\r\n // console.log('\\n📁 Per-Class Line Coverage:');\r\n // classes.forEach((cls: any) => {\r\n // const file = cls.filename || cls.name;\r\n // const lineRate = parseFloat(cls['line-rate']);\r\n // console.log(`- ${file}: ${(lineRate * 100).toFixed(2)}%`);\r\n // });\r\n}\r\n\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\505883d3-b9b2-47e2-99e5-468b7120268f\\\\jixiongge_CPC-jixio-9B9DD_2025-07-11.17_14_56.cobertura.xml\");\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\3bdc7736-f79d-4866-874a-58bd31be18d4\\\\jixiongge_CPC-jixio-9B9DD_2025-07-10.21_45_35.cobertura.xml\");\r\n// getCodeCoverageSetting(\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\");"]}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractCoverageReportPath = extractCoverageReportPath;
4
+ const constants_1 = require("../types/constants");
4
5
  function extractCoverageReportPath(log) {
5
- const lines = log.split(/\r?\n/);
6
+ const lines = log.split(constants_1.LINESEPARATOR);
6
7
  const resultLine = lines.find((line) => line.trim().includes("index.html"));
7
8
  if (!resultLine)
8
9
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"extractCoverageReportPath.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCoverageReportPath.ts"],"names":[],"mappings":";;AAAA,8DAWC;AAXD,SAAgB,yBAAyB,CAAC,GAAW;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAE1E,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAED,cAAc;AACd,kCAAkC;AAClC,6OAA6O;AAC7O,8GAA8G;AAC9G,0CAA0C;AAC1C,oIAAoI;AACpI,0DAA0D;AAC1D,KAAK;AAEL,+CAA+C;AAC/C,0DAA0D","sourcesContent":["export function extractCoverageReportPath(log: string): string {\r\n const lines = log.split(/\\r?\\n/);\r\n\r\n const resultLine = lines.find((line) => line.trim().includes(\"index.html\"));\r\n if (!resultLine) return null;\r\n\r\n const startIndex = resultLine.indexOf(\"'\");\r\n const endIndex = resultLine.lastIndexOf(\"'\");\r\n const reportRelativePath = resultLine.substring(startIndex + 1, endIndex);\r\n\r\n return reportRelativePath;\r\n}\r\n\r\n// const log =\r\n// `2025-08-05T14:27:36: Arguments\r\n// 2025-08-05T14:27:36: -reports:D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\codecoverage\\\\TestResults\\\\2638fc6b-b1d0-4c73-8a5f-475f12da315e\\\\jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified.xml\r\n// 2025-08-05T14:27:36: -targetdir:CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\r\n// 2025-08-05T14:27:36: -reporttypes:Html\r\n// 2025-08-05T14:27:36: Writing report file 'CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\\\\index.html'\r\n// 2025-08-05T14:27:36: Report generation took 0.1 seconds\r\n// `;\r\n\r\n// const path = extractCoverageReportPath(log);\r\n// console.log(`Extracted coverage report path: ${path}`);"]}
1
+ {"version":3,"file":"extractCoverageReportPath.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCoverageReportPath.ts"],"names":[],"mappings":";;AAEA,8DAWC;AAbD,kDAAmD;AAEnD,SAAgB,yBAAyB,CAAC,GAAW;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAE1E,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAED,cAAc;AACd,kCAAkC;AAClC,6OAA6O;AAC7O,8GAA8G;AAC9G,0CAA0C;AAC1C,oIAAoI;AACpI,0DAA0D;AAC1D,KAAK;AAEL,+CAA+C;AAC/C,0DAA0D","sourcesContent":["import { LINESEPARATOR } from \"../types/constants\";\r\n\r\nexport function extractCoverageReportPath(log: string): string {\r\n const lines = log.split(LINESEPARATOR);\r\n\r\n const resultLine = lines.find((line) => line.trim().includes(\"index.html\"));\r\n if (!resultLine) return null;\r\n\r\n const startIndex = resultLine.indexOf(\"'\");\r\n const endIndex = resultLine.lastIndexOf(\"'\");\r\n const reportRelativePath = resultLine.substring(startIndex + 1, endIndex);\r\n\r\n return reportRelativePath;\r\n}\r\n\r\n// const log =\r\n// `2025-08-05T14:27:36: Arguments\r\n// 2025-08-05T14:27:36: -reports:D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\codecoverage\\\\TestResults\\\\2638fc6b-b1d0-4c73-8a5f-475f12da315e\\\\jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified.xml\r\n// 2025-08-05T14:27:36: -targetdir:CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\r\n// 2025-08-05T14:27:36: -reporttypes:Html\r\n// 2025-08-05T14:27:36: Writing report file 'CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\\\\index.html'\r\n// 2025-08-05T14:27:36: Report generation took 0.1 seconds\r\n// `;\r\n\r\n// const path = extractCoverageReportPath(log);\r\n// console.log(`Extracted coverage report path: ${path}`);"]}
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkTestReportToolInstall = checkTestReportToolInstall;
4
4
  exports.installTestReportTool = installTestReportTool;
5
+ const constants_1 = require("../types/constants");
5
6
  const runCommand_1 = require("../utils/runCommand");
6
7
  const packageId = 'dotnet-reportgenerator-globaltool';
7
8
  function checkTestReportToolInstall() {
8
9
  const output = (0, runCommand_1.runCommand)('dotnet tool list --global');
9
- const lines = output.split(/\r?\n/).slice(2); // skip header lines
10
+ const lines = output.split(constants_1.LINESEPARATOR).slice(2); // skip header lines
10
11
  for (const line of lines) {
11
12
  const parts = line.trim().split(/\s+/);
12
13
  if (parts[0].toLowerCase() === packageId.toLowerCase()) {
@@ -1 +1 @@
1
- {"version":3,"file":"reportTool.js","sourceRoot":"","sources":["../../src/codeCoverage/reportTool.ts"],"names":[],"mappings":";;AAIA,gEAUC;AAED,sDAGC;AAnBD,oDAAiD;AAEjD,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,SAAgB,0BAA0B;IACtC,MAAM,MAAM,GAAG,IAAA,uBAAU,EAAC,2BAA2B,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;IAClE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,qBAAqB;IACjC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,kCAAkC,CAAC,CAAC;IAC5D,IAAA,uBAAU,EAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { runCommand } from '../utils/runCommand';\r\n\r\nconst packageId = 'dotnet-reportgenerator-globaltool';\r\n\r\nexport function checkTestReportToolInstall(): boolean {\r\n const output = runCommand('dotnet tool list --global');\r\n const lines = output.split(/\\r?\\n/).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nexport function installTestReportTool() {\r\n console.log(`${packageId} is not installed. Installing...`);\r\n runCommand(`dotnet tool install --global ${packageId}`);\r\n}"]}
1
+ {"version":3,"file":"reportTool.js","sourceRoot":"","sources":["../../src/codeCoverage/reportTool.ts"],"names":[],"mappings":";;AAKA,gEAUC;AAED,sDAGC;AApBD,kDAAmD;AACnD,oDAAiD;AAEjD,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,SAAgB,0BAA0B;IACtC,MAAM,MAAM,GAAG,IAAA,uBAAU,EAAC,2BAA2B,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;IACxE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,qBAAqB;IACjC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,kCAAkC,CAAC,CAAC;IAC5D,IAAA,uBAAU,EAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { LINESEPARATOR } from '../types/constants';\r\nimport { runCommand } from '../utils/runCommand';\r\n\r\nconst packageId = 'dotnet-reportgenerator-globaltool';\r\n\r\nexport function checkTestReportToolInstall(): boolean {\r\n const output = runCommand('dotnet tool list --global');\r\n const lines = output.split(LINESEPARATOR).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nexport function installTestReportTool() {\r\n console.log(`${packageId} is not installed. Installing...`);\r\n runCommand(`dotnet tool install --global ${packageId}`);\r\n}"]}
@@ -19,8 +19,8 @@ function main() {
19
19
  .scriptName('csharp-ut')
20
20
  .option('source', {
21
21
  describe: 'where the test copilot is running',
22
- choices: ['local', 'vsplugin'],
23
- default: 'local',
22
+ choices: ['csharpUtGen', 'csvsplugin', 'csVsCodePlugin', 'pipeline'],
23
+ default: 'csharpUtGen',
24
24
  type: 'string',
25
25
  })
26
26
  .option('mode', {
@@ -69,7 +69,7 @@ function main() {
69
69
  describe: 'The path to the NuGet packages used by the code analyzer. Used scenario: when the code analyzer is executed in CI pipeline',
70
70
  type: 'string',
71
71
  })
72
- .command('utcmd', 'Generate unit test using command line', () => { }, (c) => {
72
+ .command('utcmd', 'Generate unit test', () => { }, (c) => {
73
73
  console.log('Command executed with options:', c);
74
74
  (0, utGenWrapper_1.generateUtCode)(c);
75
75
  })
@@ -80,10 +80,6 @@ function main() {
80
80
  .command('utbenchmark', 'Generate unit test report for all project/solution files using command line', () => { }, (c) => {
81
81
  console.log('Command executed with options:', c);
82
82
  (0, utGenWrapper_1.generateUtBenchmark)(c);
83
- })
84
- .command('utvsplugin', 'Generate unit test by interact with Visual Studio plugin', () => { }, (c) => {
85
- console.log('Command executed with options:', c);
86
- (0, utGenWrapper_1.generateUtWithVsPlugin)(c);
87
83
  })
88
84
  .help()
89
85
  .alias('help', 'h')
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":";;;;;;AAEA,iDAAkH;AAElH,wDAAgC;AAChC,2CAAwC;AACxC,iFAAwE;AAExE,mPAAmP;AACnP,sPAAsP;AACtP,0PAA0P;AAC1P,kQAAkQ;AAClQ,qPAAqP;AACrP,SAAS,IAAI;IACT,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,gCAAgC;SAC/B,UAAU,CAAC,WAAW,CAAC;SACvB,MAAM,CACH,QAAQ,EACR;QACI,QAAQ,EAAE,mCAAmC;QAC7C,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;QAC9B,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,MAAM,EACN;QACI,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,yBAAyB,EAAE,uCAAuC;QAC5E,OAAO,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;QAC/B,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,gBAAgB,EAChB;QACI,QAAQ,EAAE,mCAAmC;QAC7C,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,mEAAmE;QACpF,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,WAAW,EACX;QACI,QAAQ,EAAE,yBAAyB;QACnC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,iDAAiD;QAClE,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,UAAU,EACV;QACI,Q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,CAAC;QACjD,IAAA,kCAAmB,EAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CACJ;SACA,OAAO,CACJ,YAAY,EACZ,0DAA0D,EAC1D,GAAG,EAAE,GAAG,CAAC,EACT,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,qCAAsB,EAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CACJ;SACA,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;SAClB,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,IAAA,+CAAmB,GAAE,CAAC;AACtB,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\r\n\r\nimport { generateBatchUtCode, generateUtBenchmark, generateUtCode, generateUtWithVsPlugin } from './utGenWrapper';\r\n\r\nimport Yargs from 'yargs/yargs';\r\nimport { hideBin } from 'yargs/helpers';\r\nimport { setupSignalHandlers } from '../exit/setupProcessSignalHandler';\r\n\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\nfunction main() {\r\n Yargs(hideBin(process.argv))\r\n // Yargs(hideBin(hardcodedArgs))\r\n .scriptName('csharp-ut')\r\n .option(\r\n 'source',\r\n {\r\n describe: 'where the test copilot is running',\r\n choices: ['local', 'vsplugin'],\r\n default: 'local',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'mode',\r\n {\r\n alias: 'm',\r\n describe: 'test copilot work mode.', // Note: only generate is supported now\r\n choices: ['generate', 'repair'],\r\n default: 'generate',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'keepFailedTest',\r\n {\r\n describe: 'whether to keep failed test cases',\r\n choices: [0, 1], // 0 means delete failed test cases, 1 means keep failed test cases\r\n default: 1,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'enableCov',\r\n {\r\n describe: 'whether to run coverage',\r\n choices: [0, 1], // 0 means not run coverage, 1 means run coverage\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'LLMModel',\r\n {\r\n describe: 'use which LLM model', // Note: only gpt4o is supported now\r\n default: \"gpt4o\",\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'sourceCodePath',\r\n {\r\n alias: 's',\r\n describe: 'source code file path / project path or solution path for batch generation',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'testCodePath',\r\n {\r\n alias: 't',\r\n describe: 'Target file or directory',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'autofix',\r\n {\r\n alias: 'af',\r\n describe: 'whether to auto fix generated test code',\r\n choices: [0, 1], // 0 means not auto fix, 1 means auto fix\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'nugetPackagePath',\r\n {\r\n alias: 'np',\r\n describe: 'The path to the NuGet packages used by the code analyzer. Used scenario: when the code analyzer is executed in CI pipeline',\r\n type: 'string',\r\n }\r\n )\r\n .command(\r\n 'utcmd',\r\n 'Generate unit test using command line',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtCode(c);\r\n }\r\n )\r\n .command(\r\n 'utbatch',\r\n 'Generate unit test report for all project/solution files using command line',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateBatchUtCode(c);\r\n }\r\n )\r\n .command(\r\n 'utbenchmark',\r\n 'Generate unit test report for all project/solution files using command line',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtBenchmark(c);\r\n }\r\n )\r\n .command(\r\n 'utvsplugin',\r\n 'Generate unit test by interact with Visual Studio plugin',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtWithVsPlugin(c);\r\n }\r\n )\r\n .help()\r\n .alias('help', 'h')\r\n .parse();\r\n}\r\n\r\nsetupSignalHandlers();\r\nmain();"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":";;;;;;AAEA,iDAA0F;AAE1F,wDAAgC;AAChC,2CAAwC;AACxC,iFAAwE;AAExE,mPAAmP;AACnP,sPAAsP;AACtP,0PAA0P;AAC1P,kQAAkQ;AAClQ,qPAAqP;AACrP,SAAS,IAAI;IACT,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,gCAAgC;SAC/B,UAAU,CAAC,WAAW,CAAC;S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,EAAE,yCAAyC;QAC1D,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,kBAAkB,EAClB;QACI,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,4HAA4H;QACtI,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,OAAO,CACJ,OAAO,EACP,oBAAoB,EACpB,GAAG,EAAE,GAAG,CAAC,EACT,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,6BAAc,EAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CACJ;SACA,OAAO,CACJ,SAAS,EACT,6EAA6E,EAC7E,GAAG,EAAE,GAAG,CAAC,EACT,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,kCAAmB,EAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CACJ;SACA,OAAO,CACJ,aAAa,EACb,6EAA6E,EAC7E,GAAG,EAAE,GAAG,CAAC,EACT,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,kCAAmB,EAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CACJ;SACA,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;SAClB,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,IAAA,+CAAmB,GAAE,CAAC;AACtB,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\r\n\r\nimport { generateBatchUtCode, generateUtBenchmark, generateUtCode } from './utGenWrapper';\r\n\r\nimport Yargs from 'yargs/yargs';\r\nimport { hideBin } from 'yargs/helpers';\r\nimport { setupSignalHandlers } from '../exit/setupProcessSignalHandler';\r\n\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\nfunction main() {\r\n Yargs(hideBin(process.argv))\r\n // Yargs(hideBin(hardcodedArgs))\r\n .scriptName('csharp-ut')\r\n .option(\r\n 'source',\r\n {\r\n describe: 'where the test copilot is running',\r\n choices: ['csharpUtGen', 'csvsplugin', 'csVsCodePlugin', 'pipeline'],\r\n default: 'csharpUtGen',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'mode',\r\n {\r\n alias: 'm',\r\n describe: 'test copilot work mode.', // Note: only generate is supported now\r\n choices: ['generate', 'repair'],\r\n default: 'generate',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'keepFailedTest',\r\n {\r\n describe: 'whether to keep failed test cases',\r\n choices: [0, 1], // 0 means delete failed test cases, 1 means keep failed test cases\r\n default: 1,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'enableCov',\r\n {\r\n describe: 'whether to run coverage',\r\n choices: [0, 1], // 0 means not run coverage, 1 means run coverage\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'LLMModel',\r\n {\r\n describe: 'use which LLM model', // Note: only gpt4o is supported now\r\n default: \"gpt4o\",\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'sourceCodePath',\r\n {\r\n alias: 's',\r\n describe: 'source code file path / project path or solution path for batch generation',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'testCodePath',\r\n {\r\n alias: 't',\r\n describe: 'Target file or directory',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'autofix',\r\n {\r\n alias: 'af',\r\n describe: 'whether to auto fix generated test code',\r\n choices: [0, 1], // 0 means not auto fix, 1 means auto fix\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'nugetPackagePath',\r\n {\r\n alias: 'np',\r\n describe: 'The path to the NuGet packages used by the code analyzer. Used scenario: when the code analyzer is executed in CI pipeline',\r\n type: 'string',\r\n }\r\n )\r\n .command(\r\n 'utcmd',\r\n 'Generate unit test',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtCode(c);\r\n }\r\n )\r\n .command(\r\n 'utbatch',\r\n 'Generate unit test report for all project/solution files using command line',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateBatchUtCode(c);\r\n }\r\n )\r\n .command(\r\n 'utbenchmark',\r\n 'Generate unit test report for all project/solution files using command line',\r\n () => { },\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtBenchmark(c);\r\n }\r\n )\r\n .help()\r\n .alias('help', 'h')\r\n .parse();\r\n}\r\n\r\nsetupSignalHandlers();\r\nmain();"]}
@@ -1,4 +1,3 @@
1
1
  export declare function generateUtCode(c: any): Promise<void>;
2
2
  export declare function generateBatchUtCode(c: any): Promise<void>;
3
3
  export declare function generateUtBenchmark(c: any): Promise<void>;
4
- export declare function generateUtWithVsPlugin(c: any): Promise<void>;