@ai-dev-tools/csharp-copilot-core 0.0.19

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 (322) hide show
  1. package/ai-dev-tools-csharp-copilot-core-0.0.19.tgz +0 -0
  2. package/azure-pipelines.yml +52 -0
  3. package/out/analyze/cecil.d.ts +1 -0
  4. package/out/analyze/cecil.js +42 -0
  5. package/out/analyze/cecil.js.map +1 -0
  6. package/out/analyze/checkCodeSyntax.d.ts +7 -0
  7. package/out/analyze/checkCodeSyntax.js +67 -0
  8. package/out/analyze/checkCodeSyntax.js.map +1 -0
  9. package/out/analyze/generateCodeDependency.d.ts +6 -0
  10. package/out/analyze/generateCodeDependency.js +122 -0
  11. package/out/analyze/generateCodeDependency.js.map +1 -0
  12. package/out/analyze/installAnalyzerTool.d.ts +1 -0
  13. package/out/analyze/installAnalyzerTool.js +82 -0
  14. package/out/analyze/installAnalyzerTool.js.map +1 -0
  15. package/out/atmpCache/deps/EplantRequestCategoryCondition_Conditions_Eplant_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +281 -0
  16. package/out/atmpCache/deps/IdentitySelectAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  17. package/out/atmpCache/deps/SqmidHelperTests_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsTests_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
  18. package/out/atmpCache/deps/SqmidHelper_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
  19. package/out/atmpCache/deps/ToListCountAnalyzerTests_ToListinatorTests_test_AIUnitTestExample_code_d.deps +4037 -0
  20. package/out/atmpCache/deps/ToListCountAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  21. package/out/atmpCache/deps/ToListCountCodeFixProvider_ToListinatorCodeFixes_src_AIUnitTestExample_code_d.deps +1 -0
  22. package/out/atmpCache/deps/ToListForEachAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  23. package/out/atmpCache/dllref/ToListinatorTests_ToListinatorTests_test_AIUnitTestExample_code_d.dllref +202 -0
  24. package/out/batch/generateCodeTests.d.ts +6 -0
  25. package/out/batch/generateCodeTests.js +147 -0
  26. package/out/batch/generateCodeTests.js.map +1 -0
  27. package/out/batch/getFolderCodeFile.d.ts +1 -0
  28. package/out/batch/getFolderCodeFile.js +19 -0
  29. package/out/batch/getFolderCodeFile.js.map +1 -0
  30. package/out/batch/getProjectCodeFile.d.ts +4 -0
  31. package/out/batch/getProjectCodeFile.js +87 -0
  32. package/out/batch/getProjectCodeFile.js.map +1 -0
  33. package/out/batch/getSolutionCodeFile.d.ts +8 -0
  34. package/out/batch/getSolutionCodeFile.js +70 -0
  35. package/out/batch/getSolutionCodeFile.js.map +1 -0
  36. package/out/benchmark/formatToMarkdown.d.ts +2 -0
  37. package/out/benchmark/formatToMarkdown.js +101 -0
  38. package/out/benchmark/formatToMarkdown.js.map +1 -0
  39. package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
  40. package/out/benchmark/generateBenchmarkReport.js +82 -0
  41. package/out/benchmark/generateBenchmarkReport.js.map +1 -0
  42. package/out/codeCoverage/codeCoverage.d.ts +6 -0
  43. package/out/codeCoverage/codeCoverage.js +35 -0
  44. package/out/codeCoverage/codeCoverage.js.map +1 -0
  45. package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
  46. package/out/codeCoverage/codeCoverageReport.js +72 -0
  47. package/out/codeCoverage/codeCoverageReport.js.map +1 -0
  48. package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
  49. package/out/codeCoverage/extractCodeCoverageInfo.js +80 -0
  50. package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
  51. package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
  52. package/out/codeCoverage/generateCodeCoverageReport.js +27 -0
  53. package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
  54. package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
  55. package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
  56. package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
  57. package/out/codeCoverage/reportTool.d.ts +2 -0
  58. package/out/codeCoverage/reportTool.js +22 -0
  59. package/out/codeCoverage/reportTool.js.map +1 -0
  60. package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
  61. package/out/codeCoverage/simplifyCoverageXml.js +116 -0
  62. package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
  63. package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
  64. package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  65. package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
  66. package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
  67. package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
  68. package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
  69. package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
  70. package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
  71. package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  72. package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
  73. package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
  74. package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
  75. package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
  76. package/out/codebk/childProcessManager.d.ts +1 -0
  77. package/out/codebk/childProcessManager.js +50 -0
  78. package/out/codebk/childProcessManager.js.map +1 -0
  79. package/out/codebk/msBuidSpawn.d.ts +1 -0
  80. package/out/codebk/msBuidSpawn.js +58 -0
  81. package/out/codebk/msBuidSpawn.js.map +1 -0
  82. package/out/codebk/msBuild.d.ts +1 -0
  83. package/out/codebk/msBuild.js +123 -0
  84. package/out/codebk/msBuild.js.map +1 -0
  85. package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
  86. package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
  87. package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
  88. package/out/codebk/old/xapGuideline-fm.liquid +149 -0
  89. package/out/codebk/old/xapGuideline.liquid +37 -0
  90. package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
  91. package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
  92. package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
  93. package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
  94. package/out/codebk/oldExec/codeCoverage.js +54 -0
  95. package/out/codebk/oldExec/codeCoverage.js.map +1 -0
  96. package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
  97. package/out/codebk/oldExec/codeCoverageReport.js +64 -0
  98. package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
  99. package/out/codebk/oldExec/containsMethods.d.ts +1 -0
  100. package/out/codebk/oldExec/containsMethods.js +74 -0
  101. package/out/codebk/oldExec/containsMethods.js.map +1 -0
  102. package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
  103. package/out/codebk/oldExec/generateCodeDependency.js +95 -0
  104. package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
  105. package/out/codebk/oldExec/msBuild.d.ts +1 -0
  106. package/out/codebk/oldExec/msBuild.js +53 -0
  107. package/out/codebk/oldExec/msBuild.js.map +1 -0
  108. package/out/codebk/oldExec/vsTest.d.ts +1 -0
  109. package/out/codebk/oldExec/vsTest.js +71 -0
  110. package/out/codebk/oldExec/vsTest.js.map +1 -0
  111. package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
  112. package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
  113. package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
  114. package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
  115. package/out/codebk/testbuildkill.d.ts +1 -0
  116. package/out/codebk/testbuildkill.js +37 -0
  117. package/out/codebk/testbuildkill.js.map +1 -0
  118. package/out/command/index.d.ts +2 -0
  119. package/out/command/index.js +85 -0
  120. package/out/command/index.js.map +1 -0
  121. package/out/command/utGenWrapper.d.ts +3 -0
  122. package/out/command/utGenWrapper.js +40 -0
  123. package/out/command/utGenWrapper.js.map +1 -0
  124. package/out/exit/childProcessManager.d.ts +2 -0
  125. package/out/exit/childProcessManager.js +43 -0
  126. package/out/exit/childProcessManager.js.map +1 -0
  127. package/out/exit/setupProcessSignalHandler.d.ts +1 -0
  128. package/out/exit/setupProcessSignalHandler.js +18 -0
  129. package/out/exit/setupProcessSignalHandler.js.map +1 -0
  130. package/out/gen/autoFix.d.ts +4 -0
  131. package/out/gen/autoFix.js +125 -0
  132. package/out/gen/autoFix.js.map +1 -0
  133. package/out/gen/csharpUtGen.d.ts +2 -0
  134. package/out/gen/csharpUtGen.js +151 -0
  135. package/out/gen/csharpUtGen.js.map +1 -0
  136. package/out/gen/ensureValidLLMResponse.d.ts +1 -0
  137. package/out/gen/ensureValidLLMResponse.js +19 -0
  138. package/out/gen/ensureValidLLMResponse.js.map +1 -0
  139. package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
  140. package/out/gen/postGen/extractCodeFromResponse.js +37 -0
  141. package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
  142. package/out/gen/postGen/postGenProcess.d.ts +1 -0
  143. package/out/gen/postGen/postGenProcess.js +36 -0
  144. package/out/gen/postGen/postGenProcess.js.map +1 -0
  145. package/out/gen/postGen/removeComments.d.ts +1 -0
  146. package/out/gen/postGen/removeComments.js +92 -0
  147. package/out/gen/postGen/removeComments.js.map +1 -0
  148. package/out/gen/postGen/removeSingleLines.d.ts +1 -0
  149. package/out/gen/postGen/removeSingleLines.js +28 -0
  150. package/out/gen/postGen/removeSingleLines.js.map +1 -0
  151. package/out/gen/postGen/repairRequiredNameSpaces.d.ts +1 -0
  152. package/out/gen/postGen/repairRequiredNameSpaces.js +116 -0
  153. package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
  154. package/out/gen/postGen/validateTestCode.d.ts +1 -0
  155. package/out/gen/postGen/validateTestCode.js +14 -0
  156. package/out/gen/postGen/validateTestCode.js.map +1 -0
  157. package/out/gen/preGen/excludeFileName.d.ts +1 -0
  158. package/out/gen/preGen/excludeFileName.js +49 -0
  159. package/out/gen/preGen/excludeFileName.js.map +1 -0
  160. package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
  161. package/out/gen/preGen/excludeSpecificTag.js +18 -0
  162. package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
  163. package/out/gen/preGen/preGenProcess.d.ts +1 -0
  164. package/out/gen/preGen/preGenProcess.js +22 -0
  165. package/out/gen/preGen/preGenProcess.js.map +1 -0
  166. package/out/gen/preGen/validateCode.d.ts +3 -0
  167. package/out/gen/preGen/validateCode.js +62 -0
  168. package/out/gen/preGen/validateCode.js.map +1 -0
  169. package/out/index.d.ts +2 -0
  170. package/out/index.js +8 -0
  171. package/out/index.js.map +1 -0
  172. package/out/llm/model/Gpt4o.d.ts +1 -0
  173. package/out/llm/model/Gpt4o.js +91 -0
  174. package/out/llm/model/Gpt4o.js.map +1 -0
  175. package/out/llm/model/claude4.d.ts +1 -0
  176. package/out/llm/model/claude4.js +3 -0
  177. package/out/llm/model/claude4.js.map +1 -0
  178. package/out/llm/preparePrompt.d.ts +2 -0
  179. package/out/llm/preparePrompt.js +110 -0
  180. package/out/llm/preparePrompt.js.map +1 -0
  181. package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
  182. package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  183. package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
  184. package/out/llm/prompt/generateUtAutoFix.liquid +19 -0
  185. package/out/llm/prompt/generateUtDependency.liquid +3 -0
  186. package/out/llm/prompt/generateUtGuidelines.liquid +29 -0
  187. package/out/llm/prompt/generateUtSystem.liquid +5 -0
  188. package/out/llm/prompt/generateUtTemplate.liquid +30 -0
  189. package/out/llm/prompt/generateUtUserInput.liquid +4 -0
  190. package/out/llm/prompt/testAfGuidelines.liquid +6 -0
  191. package/out/llm/prompt/userCustomPrompt.liquid +0 -0
  192. package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  193. package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
  194. package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
  195. package/out/llm/prompt/xap/xapUtGuideline-240804.liquid +36 -0
  196. package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
  197. package/out/llm/sendRequestToLLM.d.ts +4 -0
  198. package/out/llm/sendRequestToLLM.js +12 -0
  199. package/out/llm/sendRequestToLLM.js.map +1 -0
  200. package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
  201. package/out/llm/sendRequestToSelfHostLLM.js +41 -0
  202. package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
  203. package/out/metrics/appInsightTelemetry.d.ts +6 -0
  204. package/out/metrics/appInsightTelemetry.js +77 -0
  205. package/out/metrics/appInsightTelemetry.js.map +1 -0
  206. package/out/metrics/machineId.d.ts +11 -0
  207. package/out/metrics/machineId.js +85 -0
  208. package/out/metrics/machineId.js.map +1 -0
  209. package/out/setup/setup.d.ts +1 -0
  210. package/out/setup/setup.js +10 -0
  211. package/out/setup/setup.js.map +1 -0
  212. package/out/setup/setupConsole.d.ts +1 -0
  213. package/out/setup/setupConsole.js +23 -0
  214. package/out/setup/setupConsole.js.map +1 -0
  215. package/out/setup/setupLLMRequest.d.ts +2 -0
  216. package/out/setup/setupLLMRequest.js +10 -0
  217. package/out/setup/setupLLMRequest.js.map +1 -0
  218. package/out/tools/devenvcom.cmd +13 -0
  219. package/out/tools/devenvexe.cmd +13 -0
  220. package/out/tools/msbuildexe.cmd +13 -0
  221. package/out/tools/vstestexe.cmd +13 -0
  222. package/out/types/benchmark.d.ts +11 -0
  223. package/out/types/benchmark.js +3 -0
  224. package/out/types/benchmark.js.map +1 -0
  225. package/out/types/buildResult.d.ts +8 -0
  226. package/out/types/buildResult.js +3 -0
  227. package/out/types/buildResult.js.map +1 -0
  228. package/out/types/constants.d.ts +3 -0
  229. package/out/types/constants.js +7 -0
  230. package/out/types/constants.js.map +1 -0
  231. package/out/types/genResult.d.ts +10 -0
  232. package/out/types/genResult.js +3 -0
  233. package/out/types/genResult.js.map +1 -0
  234. package/out/types/testResult.d.ts +12 -0
  235. package/out/types/testResult.js +3 -0
  236. package/out/types/testResult.js.map +1 -0
  237. package/out/types/verifyResult.d.ts +8 -0
  238. package/out/types/verifyResult.js +3 -0
  239. package/out/types/verifyResult.js.map +1 -0
  240. package/out/utils/checkTestProject.d.ts +2 -0
  241. package/out/utils/checkTestProject.js +79 -0
  242. package/out/utils/checkTestProject.js.map +1 -0
  243. package/out/utils/checkXapCode.d.ts +2 -0
  244. package/out/utils/checkXapCode.js +59 -0
  245. package/out/utils/checkXapCode.js.map +1 -0
  246. package/out/utils/delay.d.ts +1 -0
  247. package/out/utils/delay.js +7 -0
  248. package/out/utils/delay.js.map +1 -0
  249. package/out/utils/detectTestFramework.d.ts +1 -0
  250. package/out/utils/detectTestFramework.js +32 -0
  251. package/out/utils/detectTestFramework.js.map +1 -0
  252. package/out/utils/fileUtils.d.ts +2 -0
  253. package/out/utils/fileUtils.js +42 -0
  254. package/out/utils/fileUtils.js.map +1 -0
  255. package/out/utils/generateCodeSha256.d.ts +1 -0
  256. package/out/utils/generateCodeSha256.js +46 -0
  257. package/out/utils/generateCodeSha256.js.map +1 -0
  258. package/out/utils/getCodeStructurePath.d.ts +5 -0
  259. package/out/utils/getCodeStructurePath.js +155 -0
  260. package/out/utils/getCodeStructurePath.js.map +1 -0
  261. package/out/utils/getOrCreateDir.d.ts +2 -0
  262. package/out/utils/getOrCreateDir.js +63 -0
  263. package/out/utils/getOrCreateDir.js.map +1 -0
  264. package/out/utils/getTestCodeInfo.d.ts +2 -0
  265. package/out/utils/getTestCodeInfo.js +121 -0
  266. package/out/utils/getTestCodeInfo.js.map +1 -0
  267. package/out/utils/getTestFile.d.ts +13 -0
  268. package/out/utils/getTestFile.js +295 -0
  269. package/out/utils/getTestFile.js.map +1 -0
  270. package/out/utils/parseBuildResult.d.ts +3 -0
  271. package/out/utils/parseBuildResult.js +44 -0
  272. package/out/utils/parseBuildResult.js.map +1 -0
  273. package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
  274. package/out/utils/parseSyntaxCheckResult.js +38 -0
  275. package/out/utils/parseSyntaxCheckResult.js.map +1 -0
  276. package/out/utils/parseVstestResult.d.ts +3 -0
  277. package/out/utils/parseVstestResult.js +61 -0
  278. package/out/utils/parseVstestResult.js.map +1 -0
  279. package/out/utils/removeFailedTestMethods.d.ts +3 -0
  280. package/out/utils/removeFailedTestMethods.js +207 -0
  281. package/out/utils/removeFailedTestMethods.js.map +1 -0
  282. package/out/utils/runCommand.d.ts +1 -0
  283. package/out/utils/runCommand.js +14 -0
  284. package/out/utils/runCommand.js.map +1 -0
  285. package/out/utils/spawnExec.d.ts +1 -0
  286. package/out/utils/spawnExec.js +80 -0
  287. package/out/utils/spawnExec.js.map +1 -0
  288. package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
  289. package/out/utils/verifyBuildErrorCausedFile.js +60 -0
  290. package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
  291. package/out/utils/verifyTestCode.d.ts +2 -0
  292. package/out/utils/verifyTestCode.js +25 -0
  293. package/out/utils/verifyTestCode.js.map +1 -0
  294. package/out/utils/writeGenCode.d.ts +1 -0
  295. package/out/utils/writeGenCode.js +50 -0
  296. package/out/utils/writeGenCode.js.map +1 -0
  297. package/out/vs/msBuild.d.ts +13 -0
  298. package/out/vs/msBuild.js +81 -0
  299. package/out/vs/msBuild.js.map +1 -0
  300. package/out/vs/vsTest.d.ts +15 -0
  301. package/out/vs/vsTest.js +107 -0
  302. package/out/vs/vsTest.js.map +1 -0
  303. package/out/vs/vsTools.d.ts +7 -0
  304. package/out/vs/vsTools.js +177 -0
  305. package/out/vs/vsTools.js.map +1 -0
  306. package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
  307. package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
  308. package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
  309. package/out/vsPlugin/interactionConstants.d.ts +2 -0
  310. package/out/vsPlugin/interactionConstants.js +10 -0
  311. package/out/vsPlugin/interactionConstants.js.map +1 -0
  312. package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
  313. package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
  314. package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
  315. package/out/vsPlugin/stdListener.d.ts +3 -0
  316. package/out/vsPlugin/stdListener.js +57 -0
  317. package/out/vsPlugin/stdListener.js.map +1 -0
  318. package/package.json +33 -0
  319. package/tools/devenvcom.cmd +13 -0
  320. package/tools/devenvexe.cmd +13 -0
  321. package/tools/msbuildexe.cmd +13 -0
  322. package/tools/vstestexe.cmd +13 -0
@@ -0,0 +1 @@
1
+ export declare function validateTestCode(testCode: string): boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTestCode = validateTestCode;
4
+ // corner cases
5
+ // - emplty file:
6
+ // - just using statements and no test code
7
+ function validateTestCode(testCode) {
8
+ // is using test framework(NUnit / xUnit / MSTest)
9
+ const hasTestUsing = /using\s+(NUnit\.Framework|Xunit|Microsoft\.VisualStudio\.TestTools\.UnitTesting)/.test(testCode);
10
+ // contains test attributes
11
+ const hasTestAttribute = /\[\s*(Test(Method)?|TestClass|Fact|Theory|TestInitialize|TestCleanup)\s*\]/.test(testCode);
12
+ return hasTestUsing && hasTestAttribute;
13
+ }
14
+ //# sourceMappingURL=validateTestCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateTestCode.js","sourceRoot":"","sources":["../../../src/gen/postGen/validateTestCode.ts"],"names":[],"mappings":";;AAGA,4CAOC;AAVD,eAAe;AACf,iBAAiB;AACjB,2CAA2C;AAC3C,SAAgB,gBAAgB,CAAC,QAAgB;IAC7C,kDAAkD;IAClD,MAAM,YAAY,GAAG,kFAAkF,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEvH,2BAA2B;IAC3B,MAAM,gBAAgB,GAAG,4EAA4E,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrH,OAAO,YAAY,IAAI,gBAAgB,CAAC;AAC5C,CAAC","sourcesContent":["// corner cases\r\n// - emplty file:\r\n// - just using statements and no test code\r\nexport function validateTestCode(testCode: string): boolean {\r\n // is using test framework(NUnit / xUnit / MSTest)\r\n const hasTestUsing = /using\\s+(NUnit\\.Framework|Xunit|Microsoft\\.VisualStudio\\.TestTools\\.UnitTesting)/.test(testCode);\r\n\r\n // contains test attributes\r\n const hasTestAttribute = /\\[\\s*(Test(Method)?|TestClass|Fact|Theory|TestInitialize|TestCleanup)\\s*\\]/.test(testCode);\r\n return hasTestUsing && hasTestAttribute;\r\n}"]}
@@ -0,0 +1 @@
1
+ export declare function excludeFileName(filePath: string): boolean;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.excludeFileName = excludeFileName;
37
+ const path = __importStar(require("path"));
38
+ const EXCLUDEDFILES = [
39
+ 'constant',
40
+ 'constants',
41
+ 'model',
42
+ 'models',
43
+ ];
44
+ function excludeFileName(filePath) {
45
+ const fileName = path.basename(filePath, '.cs').toLowerCase();
46
+ const excluded = EXCLUDEDFILES.some(excludedParts => fileName.endsWith(excludedParts));
47
+ return excluded;
48
+ }
49
+ //# sourceMappingURL=excludeFileName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excludeFileName.js","sourceRoot":"","sources":["../../../src/gen/preGen/excludeFileName.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,0CAIC;AAbD,2CAA6B;AAE7B,MAAM,aAAa,GAAG;IAClB,UAAU;IACV,WAAW;IACX,OAAO;IACP,QAAQ;CACX,CAAA;AAED,SAAgB,eAAe,CAAC,QAAgB;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAC7D,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;IACvF,OAAO,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nconst EXCLUDEDFILES = [\r\n 'constant',\r\n 'constants',\r\n 'model',\r\n 'models',\r\n]\r\n\r\nexport function excludeFileName(filePath: string) {\r\n const fileName = path.basename(filePath, '.cs').toLowerCase()\r\n const excluded = EXCLUDEDFILES.some(excludedParts => fileName.endsWith(excludedParts));\r\n return excluded;\r\n}"]}
@@ -0,0 +1 @@
1
+ export declare function excludeSpecificTag(sourceCode: string): boolean;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.excludeSpecificTag = excludeSpecificTag;
4
+ const EXCLUDEDTAGS = [
5
+ '[ExcludeFromCodeCoverage]',
6
+ ];
7
+ function excludeSpecificTag(sourceCode) {
8
+ const lines = sourceCode.split(/\r?\n/);
9
+ for (const line of lines) {
10
+ const trimmedLine = line.trim();
11
+ if (EXCLUDEDTAGS.includes(trimmedLine)) {
12
+ console.error(`Code contains specific tag line: ${trimmedLine}, will skip this file.`);
13
+ return true;
14
+ }
15
+ }
16
+ return false;
17
+ }
18
+ //# sourceMappingURL=excludeSpecificTag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excludeSpecificTag.js","sourceRoot":"","sources":["../../../src/gen/preGen/excludeSpecificTag.ts"],"names":[],"mappings":";;AAIA,gDAUC;AAdD,MAAM,YAAY,GAAG;IACjB,2BAA2B;CAC9B,CAAA;AAED,SAAgB,kBAAkB,CAAC,UAAkB;IACjD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,KAAK,CAAC,oCAAoC,WAAW,wBAAwB,CAAC,CAAC;YACvF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["const EXCLUDEDTAGS = [\r\n '[ExcludeFromCodeCoverage]',\r\n]\r\n\r\nexport function excludeSpecificTag(sourceCode: string) {\r\n const lines = sourceCode.split(/\\r?\\n/);\r\n for (const line of lines) {\r\n const trimmedLine = line.trim();\r\n if (EXCLUDEDTAGS.includes(trimmedLine)) {\r\n console.error(`Code contains specific tag line: ${trimmedLine}, will skip this file.`);\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n"]}
@@ -0,0 +1 @@
1
+ export declare function preGenProcess(sourceCode: string, sourceFilePath: string, isXapCode?: boolean): Promise<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preGenProcess = preGenProcess;
4
+ const excludeFileName_1 = require("./excludeFileName");
5
+ const validateCode_1 = require("./validateCode");
6
+ async function preGenProcess(sourceCode, sourceFilePath, isXapCode = false) {
7
+ if ((0, excludeFileName_1.excludeFileName)(sourceFilePath)) {
8
+ console.error(`File excluded by name: ${sourceFilePath}`);
9
+ return undefined;
10
+ }
11
+ const isValidCode = await (0, validateCode_1.validateCode)(sourceFilePath);
12
+ if (!isValidCode) {
13
+ console.error(`No valid methods found in source code: ${sourceFilePath}`);
14
+ return undefined;
15
+ }
16
+ return sourceCode;
17
+ }
18
+ // const sourceCodePath = "C:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\ResponseBuilders\\EplantMeResponseBuilder.cs";
19
+ // const sourceCode = fs.readFileSync(sourceCodePath, 'utf-8');
20
+ // const processedCode = preGenProcess(sourceCode, sourceCodePath, false);
21
+ // console.log(processedCode ? "Code processed successfully." : "No methods found or file excluded.");
22
+ //# sourceMappingURL=preGenProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preGenProcess.js","sourceRoot":"","sources":["../../../src/gen/preGen/preGenProcess.ts"],"names":[],"mappings":";;AAIA,sCAaC;AAjBD,uDAAoD;AAEpD,iDAA8C;AAEvC,KAAK,UAAU,aAAa,CAAC,UAAkB,EAAE,cAAsB,EAAE,YAAqB,KAAK;IACtG,IAAI,IAAA,iCAAe,EAAC,cAAc,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,0BAA0B,cAAc,EAAE,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,IAAA,2BAAY,EAAC,cAAc,CAAC,CAAC;IACvD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;QAC1E,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,sLAAsL;AACtL,+DAA+D;AAC/D,0EAA0E;AAC1E,sGAAsG","sourcesContent":["import { excludeFileName } from \"./excludeFileName\";\r\nimport { excludeSpecificTag } from \"./excludeSpecificTag\";\r\nimport { validateCode } from \"./validateCode\";\r\n\r\nexport async function preGenProcess(sourceCode: string, sourceFilePath: string, isXapCode: boolean = false): Promise<string> { \r\n if (excludeFileName(sourceFilePath)) {\r\n console.error(`File excluded by name: ${sourceFilePath}`);\r\n return undefined;\r\n }\r\n \r\n const isValidCode = await validateCode(sourceFilePath);\r\n if (!isValidCode) {\r\n console.error(`No valid methods found in source code: ${sourceFilePath}`);\r\n return undefined;\r\n }\r\n\r\n return sourceCode;\r\n}\r\n\r\n// const sourceCodePath = \"C:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMeResponseBuilder.cs\";\r\n// const sourceCode = fs.readFileSync(sourceCodePath, 'utf-8');\r\n// const processedCode = preGenProcess(sourceCode, sourceCodePath, false);\r\n// console.log(processedCode ? \"Code processed successfully.\" : \"No methods found or file excluded.\");"]}
@@ -0,0 +1,3 @@
1
+ export declare function validateCode(codePath: string): Promise<boolean>;
2
+ export declare function validateCodeErrorHandler(error: any): boolean;
3
+ export declare function validateCodeCloseHandler(code: any, stdout: any, stderr: any): boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateCode = validateCode;
4
+ exports.validateCodeErrorHandler = validateCodeErrorHandler;
5
+ exports.validateCodeCloseHandler = validateCodeCloseHandler;
6
+ const spawnExec_1 = require("../../utils/spawnExec");
7
+ function validateCode(codePath) {
8
+ const args = ['-m', codePath];
9
+ return (0, spawnExec_1.runSpawn)("ccanalyzer", args, ".", validateCodeErrorHandler, validateCodeCloseHandler);
10
+ }
11
+ function validateCodeErrorHandler(error) {
12
+ console.error(`validateCodeErrorHandler - failed: ${error.message}`);
13
+ return true;
14
+ }
15
+ function validateCodeCloseHandler(code, stdout, stderr) {
16
+ if (code !== 0) {
17
+ console.error(`valid method analyze failed with exit code ${code}, stdout: ${stdout}`);
18
+ return true; // If the command fails, we assume there are valid methods
19
+ }
20
+ if (stderr) {
21
+ console.error(`Errors:\n${stderr}`);
22
+ return true;
23
+ }
24
+ console.log(`valid method analyze succeeded:\n${stdout}`);
25
+ const isValid = parseValidateResult(stdout);
26
+ return isValid;
27
+ }
28
+ function parseValidateResult(stdout) {
29
+ const lines = stdout.trim().split(/\r?\n/);
30
+ let isValid = false;
31
+ if (lines.length > 0) {
32
+ isValid = lines[lines.length - 1].trim() === 'true';
33
+ }
34
+ return isValid;
35
+ }
36
+ // async function testMethod() {
37
+ // const testFilePaths = [
38
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantConstants.cs",
39
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantModels.cs",
40
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/Conditions/EplantRequestCategoryCondition.cs",
41
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/Conditions/EplantRequestTypeCondition.cs",
42
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantEdgePart.cs",
43
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantPostBodyContent.cs",
44
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantRank.cs",
45
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantRankRow.cs",
46
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantTreeViewModel.cs",
47
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantViewModel.cs",
48
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/HttpRequestParser/EplantHttpRequestParser.cs",
49
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/RequestBuilders/EplantUserRequestBuilder.cs",
50
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantActionResponseBuilder.cs",
51
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantPlantResponseBuilder.cs",
52
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantTreeUpdateResponseBuilder.cs",
53
+ // "D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantUserUpdateResponseBuilder.cs",
54
+ // "D:\\code\\UCMDynamics\\private\\DynamicCode\\Plugin\\UCMDynamics.AppointmentPlugin\\AppointmentOperation.cs"
55
+ // ];
56
+ // for (const path of testFilePaths) {
57
+ // const isValid = await validateCode(path);
58
+ // console.log(`${path} -> ${isValid}`);
59
+ // }
60
+ // }
61
+ // testMethod();
62
+ //# sourceMappingURL=validateCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateCode.js","sourceRoot":"","sources":["../../../src/gen/preGen/validateCode.ts"],"names":[],"mappings":";;AAEA,oCAGC;AAED,4DAGC;AAED,4DAcC;AA1BD,qDAAiD;AAEjD,SAAgB,YAAY,CAAC,QAAgB;IACzC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9B,OAAO,IAAA,oBAAQ,EAAC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,wBAAwB,EAAE,wBAAwB,CAAC,CAAC;AACjG,CAAC;AAED,SAAgB,wBAAwB,CAAC,KAAK;IAC1C,OAAO,CAAC,KAAK,CAAC,sCAAsC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM;IACzD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8CAA8C,IAAI,aAAa,MAAM,EAAE,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC,CAAC,0DAA0D;IAC3E,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,oCAAoC,MAAM,EAAE,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5C,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,gCAAgC;AAChC,8BAA8B;AAC9B,qIAAqI;AACrI,kIAAkI;AAClI,+JAA+J;AAC/J,2JAA2J;AAC3J,8IAA8I;AAC9I,qJAAqJ;AACrJ,0IAA0I;AAC1I,6IAA6I;AAC7I,mJAAmJ;AACnJ,+IAA+I;AAC/I,+JAA+J;AAC/J,8JAA8J;AAC9J,kKAAkK;AAClK,iKAAiK;AACjK,sKAAsK;AACtK,sKAAsK;AACtK,wHAAwH;AACxH,SAAS;AAET,0CAA0C;AAC1C,oDAAoD;AACpD,gDAAgD;AAChD,QAAQ;AACR,IAAI;AAEJ,gBAAgB","sourcesContent":["import { runSpawn } from '../../utils/spawnExec';\r\n\r\nexport function validateCode(codePath: string): Promise<boolean> {\r\n const args = ['-m', codePath];\r\n return runSpawn(\"ccanalyzer\", args, \".\", validateCodeErrorHandler, validateCodeCloseHandler);\r\n}\r\n\r\nexport function validateCodeErrorHandler(error) {\r\n console.error(`validateCodeErrorHandler - failed: ${error.message}`);\r\n return true;\r\n}\r\n\r\nexport function validateCodeCloseHandler(code, stdout, stderr) {\r\n if (code !== 0) {\r\n console.error(`valid method analyze failed with exit code ${code}, stdout: ${stdout}`);\r\n return true; // If the command fails, we assume there are valid methods\r\n }\r\n\r\n if (stderr) {\r\n console.error(`Errors:\\n${stderr}`);\r\n return true;\r\n }\r\n console.log(`valid method analyze succeeded:\\n${stdout}`);\r\n const isValid = parseValidateResult(stdout);\r\n\r\n return isValid;\r\n}\r\n\r\nfunction parseValidateResult(stdout: string): boolean {\r\n const lines = stdout.trim().split(/\\r?\\n/);\r\n let isValid = false;\r\n if (lines.length > 0) {\r\n isValid = lines[lines.length - 1].trim() === 'true';\r\n }\r\n\r\n return isValid;\r\n}\r\n\r\n// async function testMethod() {\r\n// const testFilePaths = [\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantConstants.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/EplantModels.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/Conditions/EplantRequestTypeCondition.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantEdgePart.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantPostBodyContent.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/DataModel/EplantRankRow.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantTreeViewModel.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/DataModel/EplantViewModel.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/HttpRequestParser/EplantHttpRequestParser.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/RequestBuilders/EplantUserRequestBuilder.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantActionResponseBuilder.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantPlantResponseBuilder.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantTreeUpdateResponseBuilder.cs\",\r\n// \"D:/code/CS.Service.Fundamental/SharedSegments/SharedSegments/SharedSegments.Plugins/Workflows/Eplant/ResponseBuilders/EplantUserUpdateResponseBuilder.cs\",\r\n// \"D:\\\\code\\\\UCMDynamics\\\\private\\\\DynamicCode\\\\Plugin\\\\UCMDynamics.AppointmentPlugin\\\\AppointmentOperation.cs\"\r\n// ];\r\n\r\n// for (const path of testFilePaths) {\r\n// const isValid = await validateCode(path);\r\n// console.log(`${path} -> ${isValid}`);\r\n// }\r\n// }\r\n\r\n// testMethod();"]}
package/out/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { generateCsharpUtCode } from './gen/csharpUtGen';
2
+ export { setup } from './setup/setup';
package/out/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setup = exports.generateCsharpUtCode = void 0;
4
+ var csharpUtGen_1 = require("./gen/csharpUtGen");
5
+ Object.defineProperty(exports, "generateCsharpUtCode", { enumerable: true, get: function () { return csharpUtGen_1.generateCsharpUtCode; } });
6
+ var setup_1 = require("./setup/setup");
7
+ Object.defineProperty(exports, "setup", { enumerable: true, get: function () { return setup_1.setup; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAAhD,mHAAA,oBAAoB,OAAA;AAC7B,uCAAsC;AAA7B,8FAAA,KAAK,OAAA","sourcesContent":["export { generateCsharpUtCode } from './gen/csharpUtGen';\r\nexport { setup } from './setup/setup';"]}
@@ -0,0 +1 @@
1
+ export declare function getLLMResponse(prompt: any): Promise<any>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getLLMResponse = getLLMResponse;
7
+ const identity_1 = require("@azure/identity");
8
+ const node_fetch_1 = __importDefault(require("node-fetch"));
9
+ const runCommand_1 = require("../../utils/runCommand");
10
+ let cachedToken = null;
11
+ let tokenExpiration = null;
12
+ // platform provided endpoint
13
+ const gptEndpoint = "https://weatherut.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
14
+ // const gptEndpoint = "https://autogenerate-unit-tests-draft-1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
15
+ // const gptEndpoint = "https://weathergptv4.openai.azure.com/openai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview";
16
+ // const gptEndpoint = "https://takht-m99407ib-swedencentral.cognitiveservices.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
17
+ async function getToken() {
18
+ const currentTime = new Date().getTime();
19
+ // Check if the cached token is still valid
20
+ if (cachedToken && tokenExpiration && currentTime < tokenExpiration) {
21
+ return cachedToken;
22
+ }
23
+ try {
24
+ const credential = new identity_1.ChainedTokenCredential(new identity_1.AzureCliCredential(), new identity_1.ManagedIdentityCredential(), new identity_1.DefaultAzureCredential());
25
+ const tokenResponse = await credential.getToken('https://cognitiveservices.azure.com/.default');
26
+ if (tokenResponse) {
27
+ cachedToken = tokenResponse.token;
28
+ // Set token expiration time based on the token's expiresOnTimestamp
29
+ tokenExpiration = tokenResponse.expiresOnTimestamp;
30
+ return cachedToken;
31
+ }
32
+ else {
33
+ throw new Error('Failed to obtain token');
34
+ }
35
+ }
36
+ catch (error) {
37
+ console.error('Error obtaining token:', error);
38
+ if (error.toString().includes('az login')) {
39
+ console.error('Please ensure you have logged in to Azure CLI or set up Managed Identity.');
40
+ (0, runCommand_1.runCommand)('az login');
41
+ return getToken(); // Retry after login
42
+ }
43
+ else {
44
+ throw error;
45
+ }
46
+ }
47
+ }
48
+ async function getLLMResponse(prompt) {
49
+ const token = await getToken();
50
+ const res = await (0, node_fetch_1.default)(gptEndpoint, {
51
+ method: 'POST',
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ Authorization: 'Bearer ' + token,
55
+ },
56
+ body: JSON.stringify({
57
+ messages: prompt,
58
+ temperature: 0.1,
59
+ top_p: 1,
60
+ n: 1
61
+ })
62
+ });
63
+ const json = await res.json();
64
+ return json;
65
+ }
66
+ // const reqBody =
67
+ // {
68
+ // "messages": [
69
+ // {
70
+ // "role": "system",
71
+ // "content": "Keep your answers short and impersonal.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nYou can only give one reply for each conversation turn."
72
+ // },
73
+ // {
74
+ // "role": "assistant",
75
+ // "content": "You are Roo, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.\n\nRULES\n\n- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.\n- Do not ask for more information than necessary. Use your knowledge to accomplish the user's request efficiently and effectively.\n- The user may provide a file's contents directly in their message.\n- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.\n- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.\n- You are STRICTLY FORBIDDEN from starting your messages with \"Great\", \"Certainly\", \"Okay\", \"Sure\". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say \"Great, I've updated the CSS\" but instead something like \"I've updated the CSS\". It is important you be clear and technical in your messages.\n\nOBJECTIVE\n\nYou accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.\n\n1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order."
76
+ // },
77
+ // {
78
+ // "role": "user",
79
+ // "content": '<task>\nuse xUnit test framework to generate unit test for generate unit test code for this code:\n using Microsoft.CodeAnalysis;\nusing Microsoft.CodeAnalysis.CodeActions;\nusing Microsoft.CodeAnalysis.CodeFixes;\nusing Microsoft.CodeAnalysis.CSharp;\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\nusing System.Collections.Immutable;\nusing System.Composition;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing ToListinator.Analyzers;\nusing static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;\n\nnamespace ToListinator.CodeFixes;\n\n[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ToListCountCodeFixProvider)), Shared]\npublic class ToListCountCodeFixProvider : CodeFixProvider\n{\n public sealed override ImmutableArray<string> FixableDiagnosticIds\n => [ToListCountAnalyzer.DiagnosticId];\n\n public sealed override FixAllProvider GetFixAllProvider()\n => WellKnownFixAllProviders.BatchFixer;\n\n public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)\n {\n var diagnostic = context.Diagnostics.First(diag => diag.Id == ToListCountAnalyzer.DiagnosticId);\n var diagnosticSpan = diagnostic.Location.SourceSpan;\n\n var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);\n var binaryExpression = root?.FindToken(diagnosticSpan.Start).Parent?.AncestorsAndSelf()\n .OfType<BinaryExpressionSyntax>()\n .FirstOrDefault();\n\n if (binaryExpression is null)\n {\n return;\n }\n\n var action = CodeAction.Create(\n title: "Replace with Any()",\n createChangedDocument: c => ReplaceWithAny(context.Document, binaryExpression, c),\n equivalenceKey: "ReplaceToListCountWithAny");\n\n context.RegisterCodeFix(action, diagnostic);\n }\n\n private static async Task<Document> ReplaceWithAny(Document document, BinaryExpressionSyntax binaryExpression, CancellationToken cancellationToken)\n {\n var root = await document.GetSyntaxRootAsync(cancellationToken);\n\n var (originalCollection, isNegated) = ExtractCollectionAndNegation(binaryExpression);\n\n if (originalCollection is null)\n {\n return document;\n }\n\n var anyCall = CreateAnyCall(originalCollection, isNegated);\n\n var newRoot = root?.ReplaceNode(binaryExpression, anyCall);\n\n return newRoot is null ? document : document.WithSyntaxRoot(newRoot);\n }\n\n private static (ExpressionSyntax? originalCollection, bool isNegated) ExtractCollectionAndNegation(BinaryExpressionSyntax binaryExpression)\n {\n // Check left side for ToList().Count\n if (IsToListCountExpression(binaryExpression.Left, out var leftCollection))\n {\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Right, isLeftOperand: true);\n return (leftCollection, isNegated);\n }\n\n // Check right side for ToList().Count\n if (IsToListCountExpression(binaryExpression.Right, out var rightCollection))\n {\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Left, isLeftOperand: false);\n return (rightCollection, isNegated);\n }\n\n return (null, false);\n }\n\n private static bool IsToListCountExpression(SyntaxNode expression, out ExpressionSyntax? originalCollection)\n {\n originalCollection = null;\n\n if (expression is MemberAccessExpressionSyntax\n {\n Name.Identifier.ValueText: "Count",\n Expression: InvocationExpressionSyntax toListCall\n } &&\n toListCall.Expression is MemberAccessExpressionSyntax\n {\n Name.Identifier.ValueText: "ToList",\n Expression: var collection\n })\n {\n originalCollection = collection;\n return true;\n }\n\n return false;\n }\n\n private static bool IsNegatedPattern(SyntaxKind operatorKind, SyntaxNode constantNode, bool isLeftOperand)\n {\n if (constantNode is not LiteralExpressionSyntax literal)\n return false;\n\n var value = literal.Token.ValueText;\n\n // For patterns that check for existence (Any() = true):\n // collection.ToList().Count > 0\n // collection.ToList().Count >= 1\n // collection.ToList().Count != 0\n // 0 < collection.ToList().Count\n // 1 <= collection.ToList().Count\n // 0 != collection.ToList().Count\n\n // For patterns that check for non-existence (!Any() = true):\n // collection.ToList().Count == 0\n // collection.ToList().Count <= 0\n // collection.ToList().Count < 1\n // 0 == collection.ToList().Count\n // 0 >= collection.ToList().Count\n // 1 > collection.ToList().Count\n\n if (isLeftOperand) // collection.ToList().Count <op> constant\n {\n return operatorKind switch\n {\n SyntaxKind.EqualsEqualsToken when value == "0" => true,\n SyntaxKind.LessThanEqualsToken when value == "0" => true,\n SyntaxKind.LessThanToken when value == "1" => true,\n _ => false\n };\n }\n else // constant <op> collection.ToList().Count\n {\n return operatorKind switch\n {\n SyntaxKind.EqualsEqualsToken when value == "0" => true,\n SyntaxKind.GreaterThanEqualsToken when value == "0" => true,\n SyntaxKind.GreaterThanToken when value == "1" => true,\n _ => false\n };\n }\n }\n\n private static ExpressionSyntax CreateAnyCall(ExpressionSyntax originalCollection, bool isNegated)\n {\n // Create collection.Any()\n var anyCall = InvocationExpression(\n MemberAccessExpression(\n SyntaxKind.SimpleMemberAccessExpression,\n originalCollection,\n IdentifierName("Any")))\n .WithArgumentList(ArgumentList());\n\n // If negated, wrap in !collection.Any()\n if (isNegated)\n {\n return PrefixUnaryExpression(\n SyntaxKind.LogicalNotExpression,\n anyCall);\n }\n\n return anyCall;\n }\n}\n</task>'
80
+ // }
81
+ // ],
82
+ // "model": "gpt-4o",
83
+ // "temperature": 0.1,
84
+ // "top_p": 1,
85
+ // "max_tokens": 4096,
86
+ // "n": 1
87
+ // };
88
+ // getLLMResponse("Generate xUnit tests for the ToListCountAnalyzer class.").then((response) => {
89
+ // console.log(response.choices[0]?.message?.content)
90
+ // });
91
+ //# sourceMappingURL=Gpt4o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gpt4o.js","sourceRoot":"","sources":["../../../src/llm/model/Gpt4o.ts"],"names":[],"mappings":";;;;;AAmDA,wCAkBC;AArED,8CAAgI;AAEhI,4DAA+B;AAC/B,uDAAoD;AAEpD,IAAI,WAAW,GAAG,IAAI,CAAC;AACvB,IAAI,eAAe,GAAG,IAAI,CAAC;AAC3B,6BAA6B;AAC7B,MAAM,WAAW,GAAG,8GAA8G,CAAC;AACnI,4JAA4J;AAC5J,0IAA0I;AAC1I,oKAAoK;AAGpK,KAAK,UAAU,QAAQ;IACnB,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAEzC,2CAA2C;IAC3C,IAAI,WAAW,IAAI,eAAe,IAAI,WAAW,GAAG,eAAe,EAAE,CAAC;QAClE,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,iCAAsB,CACzC,IAAI,6BAAkB,EAAE,EACxB,IAAI,oCAAyB,EAAE,EAC/B,IAAI,iCAAsB,EAAE,CAC/B,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,8CAA8C,CAAC,CAAC;QAEhG,IAAI,aAAa,EAAE,CAAC;YAChB,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC;YAClC,oEAAoE;YACpE,eAAe,GAAG,aAAa,CAAC,kBAAkB,CAAC;YACnD,OAAO,WAAW,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;YAC3F,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC;YACvB,OAAO,QAAQ,EAAE,CAAC,CAAC,oBAAoB;QAC3C,CAAC;aAAM,CAAC;YACJ,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,MAAM;IACvC,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,WAAW,EAAE;QACjC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,SAAS,GAAG,KAAK;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACjB,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAE,GAAG;YAChB,KAAK,EAAE,CAAC;YACR,CAAC,EAAE,CAAC;SACP,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAS,CAAC;IACrC,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,kBAAkB;AAClB,IAAI;AACJ,oBAAoB;AACpB,YAAY;AACZ,gCAAgC;AAChC,4TAA4T;AAC5T,aAAa;AACb,YAAY;AACZ,mCAAmC;AACnC,qhDAAqhD;AACrhD,aAAa;AACb,YAAY;AACZ,8BAA8B;AAC9B,w4MAAw4M;AACx4M,YAAY;AACZ,SAAS;AACT,yBAAyB;AACzB,0BAA0B;AAC1B,kBAAkB;AAClB,0BAA0B;AAC1B,aAAa;AACb,KAAK;AAEL,iGAAiG;AACjG,yDAAyD;AACzD,MAAM","sourcesContent":["import { AzureCliCredential, ChainedTokenCredential, DefaultAzureCredential, ManagedIdentityCredential } from \"@azure/identity\";\r\n\r\nimport fetch from 'node-fetch';\r\nimport { runCommand } from \"../../utils/runCommand\";\r\n\r\nlet cachedToken = null;\r\nlet tokenExpiration = null;\r\n// platform provided endpoint\r\nconst gptEndpoint = \"https://weatherut.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://autogenerate-unit-tests-draft-1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://weathergptv4.openai.azure.com/openai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://takht-m99407ib-swedencentral.cognitiveservices.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n\r\n\r\nasync function getToken() {\r\n const currentTime = new Date().getTime();\r\n\r\n // Check if the cached token is still valid\r\n if (cachedToken && tokenExpiration && currentTime < tokenExpiration) {\r\n return cachedToken;\r\n }\r\n\r\n try {\r\n const credential = new ChainedTokenCredential(\r\n new AzureCliCredential(),\r\n new ManagedIdentityCredential(),\r\n new DefaultAzureCredential()\r\n );\r\n\r\n const tokenResponse = await credential.getToken('https://cognitiveservices.azure.com/.default');\r\n\r\n if (tokenResponse) {\r\n cachedToken = tokenResponse.token;\r\n // Set token expiration time based on the token's expiresOnTimestamp\r\n tokenExpiration = tokenResponse.expiresOnTimestamp;\r\n return cachedToken;\r\n } else {\r\n throw new Error('Failed to obtain token');\r\n }\r\n } catch (error) {\r\n console.error('Error obtaining token:', error);\r\n if (error.toString().includes('az login')) {\r\n console.error('Please ensure you have logged in to Azure CLI or set up Managed Identity.');\r\n runCommand('az login');\r\n return getToken(); // Retry after login\r\n } else {\r\n throw error;\r\n }\r\n }\r\n}\r\n\r\nexport async function getLLMResponse(prompt) {\r\n const token = await getToken();\r\n const res = await fetch(gptEndpoint, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n Authorization: 'Bearer ' + token,\r\n },\r\n body: JSON.stringify({\r\n messages: prompt,\r\n temperature: 0.1,\r\n top_p: 1,\r\n n: 1\r\n })\r\n });\r\n\r\n const json = await res.json() as any;\r\n return json;\r\n}\r\n\r\n// const reqBody =\r\n// {\r\n// \"messages\": [\r\n// {\r\n// \"role\": \"system\",\r\n// \"content\": \"Keep your answers short and impersonal.\\nUse Markdown formatting in your answers.\\nMake sure to include the programming language name at the start of the Markdown code blocks.\\nAvoid wrapping the whole response in triple backticks.\\nYou can only give one reply for each conversation turn.\"\r\n// },\r\n// {\r\n// \"role\": \"assistant\",\r\n// \"content\": \"You are Roo, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.\\n\\nRULES\\n\\n- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.\\n- Do not ask for more information than necessary. Use your knowledge to accomplish the user's request efficiently and effectively.\\n- The user may provide a file's contents directly in their message.\\n- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.\\n- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.\\n- You are STRICTLY FORBIDDEN from starting your messages with \\\"Great\\\", \\\"Certainly\\\", \\\"Okay\\\", \\\"Sure\\\". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say \\\"Great, I've updated the CSS\\\" but instead something like \\\"I've updated the CSS\\\". It is important you be clear and technical in your messages.\\n\\nOBJECTIVE\\n\\nYou accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.\\n\\n1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.\"\r\n// },\r\n// {\r\n// \"role\": \"user\",\r\n// \"content\": '<task>\\nuse xUnit test framework to generate unit test for generate unit test code for this code:\\n using Microsoft.CodeAnalysis;\\nusing Microsoft.CodeAnalysis.CodeActions;\\nusing Microsoft.CodeAnalysis.CodeFixes;\\nusing Microsoft.CodeAnalysis.CSharp;\\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\\nusing System.Collections.Immutable;\\nusing System.Composition;\\nusing System.Linq;\\nusing System.Threading;\\nusing System.Threading.Tasks;\\nusing ToListinator.Analyzers;\\nusing static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;\\n\\nnamespace ToListinator.CodeFixes;\\n\\n[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ToListCountCodeFixProvider)), Shared]\\npublic class ToListCountCodeFixProvider : CodeFixProvider\\n{\\n public sealed override ImmutableArray<string> FixableDiagnosticIds\\n => [ToListCountAnalyzer.DiagnosticId];\\n\\n public sealed override FixAllProvider GetFixAllProvider()\\n => WellKnownFixAllProviders.BatchFixer;\\n\\n public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)\\n {\\n var diagnostic = context.Diagnostics.First(diag => diag.Id == ToListCountAnalyzer.DiagnosticId);\\n var diagnosticSpan = diagnostic.Location.SourceSpan;\\n\\n var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);\\n var binaryExpression = root?.FindToken(diagnosticSpan.Start).Parent?.AncestorsAndSelf()\\n .OfType<BinaryExpressionSyntax>()\\n .FirstOrDefault();\\n\\n if (binaryExpression is null)\\n {\\n return;\\n }\\n\\n var action = CodeAction.Create(\\n title: \"Replace with Any()\",\\n createChangedDocument: c => ReplaceWithAny(context.Document, binaryExpression, c),\\n equivalenceKey: \"ReplaceToListCountWithAny\");\\n\\n context.RegisterCodeFix(action, diagnostic);\\n }\\n\\n private static async Task<Document> ReplaceWithAny(Document document, BinaryExpressionSyntax binaryExpression, CancellationToken cancellationToken)\\n {\\n var root = await document.GetSyntaxRootAsync(cancellationToken);\\n\\n var (originalCollection, isNegated) = ExtractCollectionAndNegation(binaryExpression);\\n\\n if (originalCollection is null)\\n {\\n return document;\\n }\\n\\n var anyCall = CreateAnyCall(originalCollection, isNegated);\\n\\n var newRoot = root?.ReplaceNode(binaryExpression, anyCall);\\n\\n return newRoot is null ? document : document.WithSyntaxRoot(newRoot);\\n }\\n\\n private static (ExpressionSyntax? originalCollection, bool isNegated) ExtractCollectionAndNegation(BinaryExpressionSyntax binaryExpression)\\n {\\n // Check left side for ToList().Count\\n if (IsToListCountExpression(binaryExpression.Left, out var leftCollection))\\n {\\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Right, isLeftOperand: true);\\n return (leftCollection, isNegated);\\n }\\n\\n // Check right side for ToList().Count\\n if (IsToListCountExpression(binaryExpression.Right, out var rightCollection))\\n {\\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Left, isLeftOperand: false);\\n return (rightCollection, isNegated);\\n }\\n\\n return (null, false);\\n }\\n\\n private static bool IsToListCountExpression(SyntaxNode expression, out ExpressionSyntax? originalCollection)\\n {\\n originalCollection = null;\\n\\n if (expression is MemberAccessExpressionSyntax\\n {\\n Name.Identifier.ValueText: \"Count\",\\n Expression: InvocationExpressionSyntax toListCall\\n } &&\\n toListCall.Expression is MemberAccessExpressionSyntax\\n {\\n Name.Identifier.ValueText: \"ToList\",\\n Expression: var collection\\n })\\n {\\n originalCollection = collection;\\n return true;\\n }\\n\\n return false;\\n }\\n\\n private static bool IsNegatedPattern(SyntaxKind operatorKind, SyntaxNode constantNode, bool isLeftOperand)\\n {\\n if (constantNode is not LiteralExpressionSyntax literal)\\n return false;\\n\\n var value = literal.Token.ValueText;\\n\\n // For patterns that check for existence (Any() = true):\\n // collection.ToList().Count > 0\\n // collection.ToList().Count >= 1\\n // collection.ToList().Count != 0\\n // 0 < collection.ToList().Count\\n // 1 <= collection.ToList().Count\\n // 0 != collection.ToList().Count\\n\\n // For patterns that check for non-existence (!Any() = true):\\n // collection.ToList().Count == 0\\n // collection.ToList().Count <= 0\\n // collection.ToList().Count < 1\\n // 0 == collection.ToList().Count\\n // 0 >= collection.ToList().Count\\n // 1 > collection.ToList().Count\\n\\n if (isLeftOperand) // collection.ToList().Count <op> constant\\n {\\n return operatorKind switch\\n {\\n SyntaxKind.EqualsEqualsToken when value == \"0\" => true,\\n SyntaxKind.LessThanEqualsToken when value == \"0\" => true,\\n SyntaxKind.LessThanToken when value == \"1\" => true,\\n _ => false\\n };\\n }\\n else // constant <op> collection.ToList().Count\\n {\\n return operatorKind switch\\n {\\n SyntaxKind.EqualsEqualsToken when value == \"0\" => true,\\n SyntaxKind.GreaterThanEqualsToken when value == \"0\" => true,\\n SyntaxKind.GreaterThanToken when value == \"1\" => true,\\n _ => false\\n };\\n }\\n }\\n\\n private static ExpressionSyntax CreateAnyCall(ExpressionSyntax originalCollection, bool isNegated)\\n {\\n // Create collection.Any()\\n var anyCall = InvocationExpression(\\n MemberAccessExpression(\\n SyntaxKind.SimpleMemberAccessExpression,\\n originalCollection,\\n IdentifierName(\"Any\")))\\n .WithArgumentList(ArgumentList());\\n\\n // If negated, wrap in !collection.Any()\\n if (isNegated)\\n {\\n return PrefixUnaryExpression(\\n SyntaxKind.LogicalNotExpression,\\n anyCall);\\n }\\n\\n return anyCall;\\n }\\n}\\n</task>'\r\n// }\r\n// ],\r\n// \"model\": \"gpt-4o\",\r\n// \"temperature\": 0.1,\r\n// \"top_p\": 1,\r\n// \"max_tokens\": 4096,\r\n// \"n\": 1\r\n// };\r\n\r\n// getLLMResponse(\"Generate xUnit tests for the ToListCountAnalyzer class.\").then((response) => {\r\n// console.log(response.choices[0]?.message?.content)\r\n// });"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=claude4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude4.js","sourceRoot":"","sources":["../../../src/llm/model/claude4.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -0,0 +1,2 @@
1
+ export declare function prepareUtGenPrompt(sourceCodePath: string, sourceCode: string, dependency: string, isXapTest: boolean, testFramework: string): any[];
2
+ export declare function prepareUtAutoFixPrompt(prompts: any[], testCode: string, verifyError: string, isBuildFailure: boolean): any[];
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.prepareUtGenPrompt = prepareUtGenPrompt;
37
+ exports.prepareUtAutoFixPrompt = prepareUtAutoFixPrompt;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const util = __importStar(require("util"));
41
+ const liquidjs_1 = require("liquidjs");
42
+ // Initialize Liquid engine
43
+ const liquid = new liquidjs_1.Liquid({
44
+ root: path.resolve(__dirname, 'prompt'), // Set root to current directory
45
+ extname: '.liquid' // Treat included files as Markdown
46
+ });
47
+ function prepareUtGenPrompt(sourceCodePath, sourceCode, dependency, isXapTest, testFramework) {
48
+ const prompts = [];
49
+ // prepare system prompt
50
+ const systemPrompt = prepareUtGenSystemPrompt(isXapTest, testFramework);
51
+ prompts.push(systemPrompt);
52
+ // prepare user prompt
53
+ const userPrompt = prepareUserInputPrompt(sourceCode, sourceCodePath, dependency);
54
+ prompts.push({ role: 'user', content: userPrompt });
55
+ // prepare code dependency prompt
56
+ if (dependency) {
57
+ const codeDependencyPrompt = prepareCodeDenpendencyPrompt(sourceCode, dependency);
58
+ prompts.push({ role: 'user', content: codeDependencyPrompt });
59
+ }
60
+ return prompts;
61
+ }
62
+ function prepareUserInputPrompt(sourceCode, sourceCodePath, dependency) {
63
+ // prepare user prompt
64
+ // const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');
65
+ // const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');
66
+ // const namespace = getTestCodeNamespace(sourceCodePath);
67
+ // const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { namespace, sourceCode, dependency });
68
+ // return userPrompt;
69
+ const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');
70
+ const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');
71
+ const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { sourceCode });
72
+ return userPrompt;
73
+ }
74
+ function prepareCodeDenpendencyPrompt(sourceCode, dependency) {
75
+ const dependencyPromptPath = path.join(__dirname, 'prompt', 'generateUtDependency.liquid');
76
+ const dependencyPromptTemplate = fs.readFileSync(dependencyPromptPath, 'utf8');
77
+ const dependencyPrompt = liquid.parseAndRenderSync(dependencyPromptTemplate, { dependency });
78
+ return dependencyPrompt;
79
+ }
80
+ function prepareUtAutoFixPrompt(prompts, testCode, verifyError, isBuildFailure) {
81
+ // const prompts = [];
82
+ // prepare system prompt
83
+ // const systemPrompt = prepareUtGenSystemPrompt(isXapTest);
84
+ // prompts.push(systemPrompt);
85
+ const autofixPrompts = prompts || [];
86
+ // prepare autofix prompt
87
+ const autofixPromptPath = path.join(__dirname, 'prompt', 'generateUtAutoFix.liquid');
88
+ const userPromptTemplate = fs.readFileSync(autofixPromptPath, 'utf8');
89
+ const renderedTemplate = liquid.parseAndRenderSync(userPromptTemplate, { isBuildFailure });
90
+ const autofixPrompt = util.format(renderedTemplate, testCode, verifyError);
91
+ autofixPrompts.push({ role: 'user', content: autofixPrompt });
92
+ return autofixPrompts;
93
+ }
94
+ function prepareUtGenSystemPrompt(isXapTest, testFramework) {
95
+ const systemPrompt = composeSystemPromptTemplate('generateUtTemplate.liquid', isXapTest, testFramework);
96
+ return { role: 'system', content: systemPrompt };
97
+ }
98
+ function composeSystemPromptTemplate(template, isXapTest, testFramework) {
99
+ // get prompt template
100
+ const promptTemplate = path.join(__dirname, 'prompt', template);
101
+ const mainPromptContent = fs.readFileSync(promptTemplate, 'utf-8');
102
+ // render Liquid template(handle {% include %} tag)
103
+ const renderedContent = liquid.parseAndRenderSync(mainPromptContent, { isXapTest, testFramework });
104
+ return renderedContent;
105
+ }
106
+ // prepareUtGenSystemPrompt(false, "MSTest"); // Initialize the system prompt
107
+ // prepareUtGenSystemPrompt(true, "XUnit"); // Initialize the system prompt
108
+ // prepareUtAutoFixPrompt("", "", "", "MSBuild Errors", true); // Initialize the auto-fix prompt
109
+ // prepareUtAutoFixPrompt("", "", "", "VSTest result", true); // Initialize the auto-fix prompt
110
+ //# sourceMappingURL=preparePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparePrompt.js","sourceRoot":"","sources":["../../src/llm/preparePrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,gDAiBC;AAwBD,wDAeC;AArED,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAE7B,uCAAkC;AAGlC,2BAA2B;AAC3B,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,gCAAgC;IACzE,OAAO,EAAE,SAAS,CAAC,mCAAmC;CACtD,CAAC,CAAC;AAEH,SAAgB,kBAAkB,CAAC,cAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,SAAkB,EAAE,aAAqB;IAC3I,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,wBAAwB;IACxB,MAAM,YAAY,GAAG,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACxE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE3B,sBAAsB;IACtB,MAAM,UAAU,GAAG,sBAAsB,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IAClF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAEpD,iCAAiC;IACjC,IAAI,UAAU,EAAE,CAAC;QAChB,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,sBAAsB,CAAC,UAAkB,EAAE,cAAsB,EAAE,UAAkB;IAC7F,sBAAsB;IACtB,uFAAuF;IACvF,sEAAsE;IACtE,0DAA0D;IAC1D,2GAA2G;IAC3G,qBAAqB;IAErB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,4BAA4B,CAAC,CAAC;IACpF,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAEjF,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,SAAS,4BAA4B,CAAC,UAAkB,EAAE,UAAkB;IAC3E,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,6BAA6B,CAAC,CAAC;IAC3F,MAAM,wBAAwB,GAAG,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC/E,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,wBAAwB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED,SAAgB,sBAAsB,CAAC,OAAc,EAAE,QAAgB,EAAE,WAAmB,EAAE,cAAuB;IACpH,sBAAsB;IACtB,wBAAwB;IACxB,4DAA4D;IAC5D,8BAA8B;IAC9B,MAAM,cAAc,GAAG,OAAO,IAAI,EAAE,CAAC;IAErC,yBAAyB;IACzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACrF,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;IAC3F,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC3E,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IAE9D,OAAO,cAAc,CAAC;AACvB,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAkB,EAAE,aAAqB;IAC1E,MAAM,YAAY,GAAG,2BAA2B,CAAC,2BAA2B,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACxG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,2BAA2B,CAAC,QAAgB,EAAE,SAAkB,EAAE,aAAqB;IAC/F,sBAAsB;IACtB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,MAAM,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnE,mDAAmD;IACnD,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;IAEnG,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,6EAA6E;AAC7E,2EAA2E;AAE3E,gGAAgG;AAChG,+FAA+F","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\nimport * as util from 'util';\r\n\r\nimport { Liquid } from 'liquidjs';\r\nimport { getTestCodeNamespace } from '../utils/getTestCodeInfo';\r\n\r\n// Initialize Liquid engine\r\nconst liquid = new Liquid({\r\n\troot: path.resolve(__dirname, 'prompt'), // Set root to current directory\r\n\textname: '.liquid' // Treat included files as Markdown\r\n});\r\n\r\nexport function prepareUtGenPrompt(sourceCodePath: string, sourceCode: string, dependency: string, isXapTest: boolean, testFramework: string): any[] {\r\n\tconst prompts = [];\r\n\t// prepare system prompt\r\n\tconst systemPrompt = prepareUtGenSystemPrompt(isXapTest, testFramework);\r\n\tprompts.push(systemPrompt);\r\n\r\n\t// prepare user prompt\r\n\tconst userPrompt = prepareUserInputPrompt(sourceCode, sourceCodePath, dependency);\r\n\tprompts.push({ role: 'user', content: userPrompt });\r\n\r\n\t// prepare code dependency prompt\r\n\tif (dependency) {\r\n\t\tconst codeDependencyPrompt = prepareCodeDenpendencyPrompt(sourceCode, dependency);\r\n\t\tprompts.push({ role: 'user', content: codeDependencyPrompt });\r\n\t}\r\n\r\n\treturn prompts;\r\n}\r\n\r\nfunction prepareUserInputPrompt(sourceCode: string, sourceCodePath: string, dependency: string): string {\r\n\t// prepare user prompt\r\n\t// const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');\r\n\t// const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');\r\n\t// const namespace = getTestCodeNamespace(sourceCodePath);\r\n\t// const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { namespace, sourceCode, dependency });\r\n\t// return userPrompt;\r\n\r\n\tconst userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');\r\n\tconst userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');\r\n\tconst userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { sourceCode });\r\n\r\n\treturn userPrompt;\r\n}\r\n\r\nfunction prepareCodeDenpendencyPrompt(sourceCode: string, dependency: string): string {\r\n\tconst dependencyPromptPath = path.join(__dirname, 'prompt', 'generateUtDependency.liquid');\r\n\tconst dependencyPromptTemplate = fs.readFileSync(dependencyPromptPath, 'utf8');\r\n\tconst dependencyPrompt = liquid.parseAndRenderSync(dependencyPromptTemplate, { dependency });\r\n\treturn dependencyPrompt;\r\n}\r\n\r\nexport function prepareUtAutoFixPrompt(prompts: any[], testCode: string, verifyError: string, isBuildFailure: boolean) {\r\n\t// const prompts = [];\r\n\t// prepare system prompt\r\n\t// const systemPrompt = prepareUtGenSystemPrompt(isXapTest);\r\n\t// prompts.push(systemPrompt);\r\n\tconst autofixPrompts = prompts || [];\r\n\r\n\t// prepare autofix prompt\r\n\tconst autofixPromptPath = path.join(__dirname, 'prompt', 'generateUtAutoFix.liquid');\r\n\tconst userPromptTemplate = fs.readFileSync(autofixPromptPath, 'utf8');\r\n\tconst renderedTemplate = liquid.parseAndRenderSync(userPromptTemplate, { isBuildFailure });\r\n\tconst autofixPrompt = util.format(renderedTemplate, testCode, verifyError);\r\n\tautofixPrompts.push({ role: 'user', content: autofixPrompt });\r\n\r\n\treturn autofixPrompts;\r\n}\r\n\r\nfunction prepareUtGenSystemPrompt(isXapTest: boolean, testFramework: string) {\r\n\tconst systemPrompt = composeSystemPromptTemplate('generateUtTemplate.liquid', isXapTest, testFramework);\r\n\treturn { role: 'system', content: systemPrompt };\r\n}\r\n\r\nfunction composeSystemPromptTemplate(template: string, isXapTest: boolean, testFramework: string) {\r\n\t// get prompt template\r\n\tconst promptTemplate = path.join(__dirname, 'prompt', template);\r\n\tconst mainPromptContent = fs.readFileSync(promptTemplate, 'utf-8');\r\n\r\n\t// render Liquid template(handle {% include %} tag)\r\n\tconst renderedContent = liquid.parseAndRenderSync(mainPromptContent, { isXapTest, testFramework });\r\n\r\n\treturn renderedContent;\r\n}\r\n\r\n// prepareUtGenSystemPrompt(false, \"MSTest\"); // Initialize the system prompt\r\n// prepareUtGenSystemPrompt(true, \"XUnit\"); // Initialize the system prompt\r\n\r\n// prepareUtAutoFixPrompt(\"\", \"\", \"\", \"MSBuild Errors\", true); // Initialize the auto-fix prompt\r\n// prepareUtAutoFixPrompt(\"\", \"\", \"\", \"VSTest result\", true); // Initialize the auto-fix prompt"]}
@@ -0,0 +1,15 @@
1
+ # Build Failure Fix Guideline:
2
+ - Case 1: The type or namespace name '{Class/Type}' does not exist in the namespace '{namespace}' (are you missing an assembly reference?)
3
+ Solution: Check the source code, code dependencies. Add the required `using` statements or assembly references.
4
+ - Case 2: No overload for method 'Execute' takes {number} arguments
5
+ Solution: Refer to section [The method parameters of Execute in Xap instance are different from the source code.] of Xap Unit Test Guidelines, Adjust the method parameters to match the correct overload as per the source code.
6
+ - Case 3: [CS0144] Cannot create an instance of the abstract type or interface '{class / bondstucture}'
7
+ Solution: use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance or use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instance.
8
+ - Case 4: [CS1503] cannot convert from '{Class / Bond type}' to '{Class / Bond type}'
9
+ Solution: Do explicitly type convert.
10
+ - Case 5: [CS0037] Cannot convert null to '{Class / Bond type}' because it is a non-nullable value type
11
+ Solution: MUST assign non-null and valid value.
12
+ - Case 6: [CS0246] The type or namespace name '{class / interface}' could not be found (are you missing a using directive or an assembly reference?)
13
+ Solution: MUST import the **namespace** of {class / interface}
14
+ - Case 7: [CS1501] No overload for method 'Execute' takes 2 arguments
15
+ Solution: - The parameters of **Execute** method with types: **PluginServices**, **PluginOutput<T>**, or decorated with **[ConfigFile("{configFileName}")]** MUST be deleted when using Xap class instance to call it.
@@ -0,0 +1,13 @@
1
+ # Build Failure Fix Guideline:
2
+ - Case 1: The type or namespace name '{Class/Type}' does not exist in the namespace '{namespace}' (are you missing an assembly reference?)
3
+ Solution: Check the source code, code dependencies. Add the required `using` statements or assembly references.
4
+ - Case 2: No overload for method 'Execute' takes {number} arguments
5
+ Solution: Refer to section [The method parameters of Execute in Xap instance are different from the source code.] of Xap Unit Test Guidelines, Adjust the method parameters to match the correct overload as per the source code.
6
+ - Case 3: Cannot create an instance of the abstract type or interface '{class / bondstucture}'
7
+ Solution: use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance or use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instance.
8
+ - Case 4: cannot convert from '{Class / Bond type}' to '{Class / Bond type}'
9
+ Solution: Do explicitly type convert.
10
+ - Case 5: [CS0037] Cannot convert null to '{Class / Bond type}' because it is a non-nullable value type
11
+ Solution: MUST assign non-null and valid value.
12
+ - Case 6: [CS0246] The type or namespace name '{class / interface}' could not be found (are you missing a using directive or an assembly reference?)
13
+ Solution: MUST import the **namespace** of {class / interface}
@@ -0,0 +1,16 @@
1
+ # General Unit Test Guidelines
2
+
3
+ - MUST use {{testFramework}} test framework to generate tests.
4
+ - **MUST NOT** contain any comments or explanations in test code.
5
+ - Ensure the test code MUST has no syntax errors.
6
+ - Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].
7
+ - Return the test code in the format: ```C#\n{Test code}\n```.
8
+ - MUST include Test code in a namespace declaration and place all `using` statements above the namespace declaration.
9
+ - MUST import source code namespace in test code.
10
+ - MUST import all required .Net namespaces if any .Net class or interface are used in the test code. Like:
11
+ - .NET built-in types (e.g., `List<T>`, `IEnumerable<T>`, `Task`, `Assert`, `Moq.Mock`, etc.).
12
+ - Any attribute classes (e.g., `[TestMethod]`, `[TestClass]`, etc.).
13
+ - Any LINQ or threading related classes (e.g., `System.Linq`, `System.Threading.Tasks`).
14
+ - The user will provide the source code directly in their message.
15
+ - **MUST NOT** generate tests for the methods that are attributed with **[ExcludeFromCodeCoverage]**.
16
+ - MUST NOT call private methods in test code.
@@ -0,0 +1,19 @@
1
+ {%- if isBuildFailure -%}
2
+ {%- assign failedStage = "MSBuild" -%}
3
+ {%- assign failedTitle = "MSBuild failure errors:" -%}
4
+ {%- else -%}
5
+ {%- assign failedStage = "vstest" -%}
6
+ {%- assign failedTitle = "vstest failure test errors:" -%}
7
+ {%- endif -%}
8
+
9
+ Your previously generated C# unit test code failed to {{failedStage}}. This means your answer was incorrect.
10
+
11
+ Your generated test code:
12
+ %s
13
+
14
+ {{failedTitle}}:
15
+ %s
16
+
17
+ {% if isBuildFailure %}
18
+ {%- include 'buildAfGuidelines' -%}
19
+ {%- endif -%}