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

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 (303) hide show
  1. package/package.json +1 -1
  2. package/out/analyze/cecil.d.ts +0 -1
  3. package/out/analyze/cecil.js +0 -42
  4. package/out/analyze/cecil.js.map +0 -1
  5. package/out/analyze/checkCodeSyntax.d.ts +0 -7
  6. package/out/analyze/checkCodeSyntax.js +0 -67
  7. package/out/analyze/checkCodeSyntax.js.map +0 -1
  8. package/out/analyze/generateCodeDependency.d.ts +0 -6
  9. package/out/analyze/generateCodeDependency.js +0 -126
  10. package/out/analyze/generateCodeDependency.js.map +0 -1
  11. package/out/analyze/installAnalyzerTool.d.ts +0 -1
  12. package/out/analyze/installAnalyzerTool.js +0 -82
  13. package/out/analyze/installAnalyzerTool.js.map +0 -1
  14. package/out/batch/generateCodeTests.d.ts +0 -6
  15. package/out/batch/generateCodeTests.js +0 -147
  16. package/out/batch/generateCodeTests.js.map +0 -1
  17. package/out/batch/getFolderCodeFile.d.ts +0 -1
  18. package/out/batch/getFolderCodeFile.js +0 -19
  19. package/out/batch/getFolderCodeFile.js.map +0 -1
  20. package/out/batch/getProjectCodeFile.d.ts +0 -4
  21. package/out/batch/getProjectCodeFile.js +0 -86
  22. package/out/batch/getProjectCodeFile.js.map +0 -1
  23. package/out/batch/getSolutionCodeFile.d.ts +0 -8
  24. package/out/batch/getSolutionCodeFile.js +0 -70
  25. package/out/batch/getSolutionCodeFile.js.map +0 -1
  26. package/out/benchmark/formatToMarkdown.d.ts +0 -2
  27. package/out/benchmark/formatToMarkdown.js +0 -101
  28. package/out/benchmark/formatToMarkdown.js.map +0 -1
  29. package/out/benchmark/generateBenchmarkReport.d.ts +0 -1
  30. package/out/benchmark/generateBenchmarkReport.js +0 -82
  31. package/out/benchmark/generateBenchmarkReport.js.map +0 -1
  32. package/out/codeCoverage/codeCoverage.d.ts +0 -6
  33. package/out/codeCoverage/codeCoverage.js +0 -39
  34. package/out/codeCoverage/codeCoverage.js.map +0 -1
  35. package/out/codeCoverage/codeCoverageReport.d.ts +0 -6
  36. package/out/codeCoverage/codeCoverageReport.js +0 -76
  37. package/out/codeCoverage/codeCoverageReport.js.map +0 -1
  38. package/out/codeCoverage/extractCodeCoverageInfo.d.ts +0 -2
  39. package/out/codeCoverage/extractCodeCoverageInfo.js +0 -80
  40. package/out/codeCoverage/extractCodeCoverageInfo.js.map +0 -1
  41. package/out/codeCoverage/extractCoverageReportPath.d.ts +0 -1
  42. package/out/codeCoverage/extractCoverageReportPath.js +0 -24
  43. package/out/codeCoverage/extractCoverageReportPath.js.map +0 -1
  44. package/out/codeCoverage/generateCodeCoverageReport.d.ts +0 -1
  45. package/out/codeCoverage/generateCodeCoverageReport.js +0 -30
  46. package/out/codeCoverage/generateCodeCoverageReport.js.map +0 -1
  47. package/out/codeCoverage/getCodeCoverageSetting.d.ts +0 -1
  48. package/out/codeCoverage/getCodeCoverageSetting.js +0 -58
  49. package/out/codeCoverage/getCodeCoverageSetting.js.map +0 -1
  50. package/out/codeCoverage/reportTool.d.ts +0 -2
  51. package/out/codeCoverage/reportTool.js +0 -22
  52. package/out/codeCoverage/reportTool.js.map +0 -1
  53. package/out/codeCoverage/simplifyCoverageXml.d.ts +0 -2
  54. package/out/codeCoverage/simplifyCoverageXml.js +0 -117
  55. package/out/codeCoverage/simplifyCoverageXml.js.map +0 -1
  56. package/out/codebk/250804prompt/buildAfGuidelines.liquid +0 -15
  57. package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +0 -13
  58. package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +0 -18
  59. package/out/codebk/250804prompt/generateUtAutoFix.liquid +0 -19
  60. package/out/codebk/250804prompt/generateUtGuidelines.liquid +0 -13
  61. package/out/codebk/250804prompt/generateUtSystem.liquid +0 -5
  62. package/out/codebk/250804prompt/generateUtUserInput.liquid +0 -27
  63. package/out/codebk/250804prompt/testAfGuidelines.liquid +0 -6
  64. package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +0 -13
  65. package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
  66. package/out/codebk/250804prompt/xap/xapCodeSample.liquid +0 -38
  67. package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +0 -36
  68. package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +0 -36
  69. package/out/codebk/childProcessManager.d.ts +0 -1
  70. package/out/codebk/childProcessManager.js +0 -50
  71. package/out/codebk/childProcessManager.js.map +0 -1
  72. package/out/codebk/msBuidSpawn.d.ts +0 -1
  73. package/out/codebk/msBuidSpawn.js +0 -58
  74. package/out/codebk/msBuidSpawn.js.map +0 -1
  75. package/out/codebk/msBuild.d.ts +0 -1
  76. package/out/codebk/msBuild.js +0 -123
  77. package/out/codebk/msBuild.js.map +0 -1
  78. package/out/codebk/old/generateXapTestAutoFix.liquid +0 -12
  79. package/out/codebk/old/generateXapTestGuidelines-fm.liquid +0 -68
  80. package/out/codebk/old/generateXapTestGuidelines.liquid +0 -28
  81. package/out/codebk/old/xapGuideline-fm.liquid +0 -149
  82. package/out/codebk/old/xapGuideline.liquid +0 -37
  83. package/out/codebk/oldExec/checkCodeSyntax.d.ts +0 -1
  84. package/out/codebk/oldExec/checkCodeSyntax.js +0 -81
  85. package/out/codebk/oldExec/checkCodeSyntax.js.map +0 -1
  86. package/out/codebk/oldExec/codeCoverage.d.ts +0 -1
  87. package/out/codebk/oldExec/codeCoverage.js +0 -54
  88. package/out/codebk/oldExec/codeCoverage.js.map +0 -1
  89. package/out/codebk/oldExec/codeCoverageReport.d.ts +0 -1
  90. package/out/codebk/oldExec/codeCoverageReport.js +0 -64
  91. package/out/codebk/oldExec/codeCoverageReport.js.map +0 -1
  92. package/out/codebk/oldExec/containsMethods.d.ts +0 -1
  93. package/out/codebk/oldExec/containsMethods.js +0 -74
  94. package/out/codebk/oldExec/containsMethods.js.map +0 -1
  95. package/out/codebk/oldExec/generateCodeDependency.d.ts +0 -1
  96. package/out/codebk/oldExec/generateCodeDependency.js +0 -95
  97. package/out/codebk/oldExec/generateCodeDependency.js.map +0 -1
  98. package/out/codebk/oldExec/msBuild.d.ts +0 -1
  99. package/out/codebk/oldExec/msBuild.js +0 -53
  100. package/out/codebk/oldExec/msBuild.js.map +0 -1
  101. package/out/codebk/oldExec/vsTest.d.ts +0 -1
  102. package/out/codebk/oldExec/vsTest.js +0 -71
  103. package/out/codebk/oldExec/vsTest.js.map +0 -1
  104. package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +0 -56
  105. package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +0 -21
  106. package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +0 -29
  107. package/out/codebk/prompts/xap/xapGuideline-o.liquid +0 -45
  108. package/out/codebk/testbuildkill.d.ts +0 -1
  109. package/out/codebk/testbuildkill.js +0 -37
  110. package/out/codebk/testbuildkill.js.map +0 -1
  111. package/out/command/index.d.ts +0 -2
  112. package/out/command/index.js +0 -94
  113. package/out/command/index.js.map +0 -1
  114. package/out/command/utGenWrapper.d.ts +0 -4
  115. package/out/command/utGenWrapper.js +0 -46
  116. package/out/command/utGenWrapper.js.map +0 -1
  117. package/out/exit/childProcessManager.d.ts +0 -2
  118. package/out/exit/childProcessManager.js +0 -43
  119. package/out/exit/childProcessManager.js.map +0 -1
  120. package/out/exit/setupProcessSignalHandler.d.ts +0 -1
  121. package/out/exit/setupProcessSignalHandler.js +0 -18
  122. package/out/exit/setupProcessSignalHandler.js.map +0 -1
  123. package/out/gen/autoFix.d.ts +0 -4
  124. package/out/gen/autoFix.js +0 -125
  125. package/out/gen/autoFix.js.map +0 -1
  126. package/out/gen/csharpUtGen.d.ts +0 -2
  127. package/out/gen/csharpUtGen.js +0 -125
  128. package/out/gen/csharpUtGen.js.map +0 -1
  129. package/out/gen/ensureValidLLMResponse.d.ts +0 -1
  130. package/out/gen/ensureValidLLMResponse.js +0 -19
  131. package/out/gen/ensureValidLLMResponse.js.map +0 -1
  132. package/out/gen/postGen/extractCodeFromResponse.d.ts +0 -1
  133. package/out/gen/postGen/extractCodeFromResponse.js +0 -37
  134. package/out/gen/postGen/extractCodeFromResponse.js.map +0 -1
  135. package/out/gen/postGen/postGenProcess.d.ts +0 -1
  136. package/out/gen/postGen/postGenProcess.js +0 -37
  137. package/out/gen/postGen/postGenProcess.js.map +0 -1
  138. package/out/gen/postGen/removeComments.d.ts +0 -1
  139. package/out/gen/postGen/removeComments.js +0 -92
  140. package/out/gen/postGen/removeComments.js.map +0 -1
  141. package/out/gen/postGen/removeSingleLines.d.ts +0 -1
  142. package/out/gen/postGen/removeSingleLines.js +0 -28
  143. package/out/gen/postGen/removeSingleLines.js.map +0 -1
  144. package/out/gen/postGen/repairRequiredNameSpaces.d.ts +0 -2
  145. package/out/gen/postGen/repairRequiredNameSpaces.js +0 -141
  146. package/out/gen/postGen/repairRequiredNameSpaces.js.map +0 -1
  147. package/out/gen/postGen/validateTestCode.d.ts +0 -1
  148. package/out/gen/postGen/validateTestCode.js +0 -14
  149. package/out/gen/postGen/validateTestCode.js.map +0 -1
  150. package/out/gen/preGen/excludeFileName.d.ts +0 -1
  151. package/out/gen/preGen/excludeFileName.js +0 -49
  152. package/out/gen/preGen/excludeFileName.js.map +0 -1
  153. package/out/gen/preGen/excludeSpecificTag.d.ts +0 -1
  154. package/out/gen/preGen/excludeSpecificTag.js +0 -18
  155. package/out/gen/preGen/excludeSpecificTag.js.map +0 -1
  156. package/out/gen/preGen/preGenProcess.d.ts +0 -1
  157. package/out/gen/preGen/preGenProcess.js +0 -22
  158. package/out/gen/preGen/preGenProcess.js.map +0 -1
  159. package/out/gen/preGen/validateCode.d.ts +0 -3
  160. package/out/gen/preGen/validateCode.js +0 -62
  161. package/out/gen/preGen/validateCode.js.map +0 -1
  162. package/out/index.d.ts +0 -3
  163. package/out/index.js +0 -10
  164. package/out/index.js.map +0 -1
  165. package/out/llm/model/Gpt.d.ts +0 -1
  166. package/out/llm/model/Gpt.js +0 -93
  167. package/out/llm/model/Gpt.js.map +0 -1
  168. package/out/llm/preparePrompt.d.ts +0 -2
  169. package/out/llm/preparePrompt.js +0 -135
  170. package/out/llm/preparePrompt.js.map +0 -1
  171. package/out/llm/prompt/buildAfGuidelines.liquid +0 -15
  172. package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +0 -13
  173. package/out/llm/prompt/general/generalUtGuidelines.liquid +0 -16
  174. package/out/llm/prompt/generateUtAutoFix.liquid +0 -23
  175. package/out/llm/prompt/generateUtDependency.liquid +0 -3
  176. package/out/llm/prompt/generateUtSystem.liquid +0 -5
  177. package/out/llm/prompt/generateUtTemplate.liquid +0 -32
  178. package/out/llm/prompt/generateUtUserInput.liquid +0 -4
  179. package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +0 -13
  180. package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
  181. package/out/llm/prompt/xap/xapCodeSample.liquid +0 -38
  182. package/out/llm/prompt/xap/xapUtGuideline.liquid +0 -37
  183. package/out/llm/sendRequestToLLM.d.ts +0 -4
  184. package/out/llm/sendRequestToLLM.js +0 -9
  185. package/out/llm/sendRequestToLLM.js.map +0 -1
  186. package/out/llm/sendRequestToSelfHostLLM.d.ts +0 -4
  187. package/out/llm/sendRequestToSelfHostLLM.js +0 -41
  188. package/out/llm/sendRequestToSelfHostLLM.js.map +0 -1
  189. package/out/metrics/appInsightTelemetry.d.ts +0 -6
  190. package/out/metrics/appInsightTelemetry.js +0 -77
  191. package/out/metrics/appInsightTelemetry.js.map +0 -1
  192. package/out/metrics/machineId.d.ts +0 -11
  193. package/out/metrics/machineId.js +0 -85
  194. package/out/metrics/machineId.js.map +0 -1
  195. package/out/setup/setup.d.ts +0 -1
  196. package/out/setup/setup.js +0 -10
  197. package/out/setup/setup.js.map +0 -1
  198. package/out/setup/setupConsole.d.ts +0 -1
  199. package/out/setup/setupConsole.js +0 -23
  200. package/out/setup/setupConsole.js.map +0 -1
  201. package/out/setup/setupLLMRequest.d.ts +0 -2
  202. package/out/setup/setupLLMRequest.js +0 -10
  203. package/out/setup/setupLLMRequest.js.map +0 -1
  204. package/out/tools/devenvcom.cmd +0 -13
  205. package/out/tools/devenvexe.cmd +0 -13
  206. package/out/tools/msbuildexe.cmd +0 -13
  207. package/out/tools/vstestexe.cmd +0 -13
  208. package/out/types/benchmark.d.ts +0 -11
  209. package/out/types/benchmark.js +0 -3
  210. package/out/types/benchmark.js.map +0 -1
  211. package/out/types/buildResult.d.ts +0 -8
  212. package/out/types/buildResult.js +0 -3
  213. package/out/types/buildResult.js.map +0 -1
  214. package/out/types/constants.d.ts +0 -6
  215. package/out/types/constants.js +0 -10
  216. package/out/types/constants.js.map +0 -1
  217. package/out/types/genResult.d.ts +0 -10
  218. package/out/types/genResult.js +0 -3
  219. package/out/types/genResult.js.map +0 -1
  220. package/out/types/testResult.d.ts +0 -12
  221. package/out/types/testResult.js +0 -3
  222. package/out/types/testResult.js.map +0 -1
  223. package/out/types/verifyResult.d.ts +0 -8
  224. package/out/types/verifyResult.js +0 -3
  225. package/out/types/verifyResult.js.map +0 -1
  226. package/out/utils/checkTestProject.d.ts +0 -2
  227. package/out/utils/checkTestProject.js +0 -79
  228. package/out/utils/checkTestProject.js.map +0 -1
  229. package/out/utils/checkXapCode.d.ts +0 -2
  230. package/out/utils/checkXapCode.js +0 -59
  231. package/out/utils/checkXapCode.js.map +0 -1
  232. package/out/utils/delay.d.ts +0 -1
  233. package/out/utils/delay.js +0 -7
  234. package/out/utils/delay.js.map +0 -1
  235. package/out/utils/detectTestFramework.d.ts +0 -1
  236. package/out/utils/detectTestFramework.js +0 -33
  237. package/out/utils/detectTestFramework.js.map +0 -1
  238. package/out/utils/fileUtils.d.ts +0 -2
  239. package/out/utils/fileUtils.js +0 -42
  240. package/out/utils/fileUtils.js.map +0 -1
  241. package/out/utils/generateCodeSha256.d.ts +0 -1
  242. package/out/utils/generateCodeSha256.js +0 -46
  243. package/out/utils/generateCodeSha256.js.map +0 -1
  244. package/out/utils/getCodeStructurePath.d.ts +0 -5
  245. package/out/utils/getCodeStructurePath.js +0 -155
  246. package/out/utils/getCodeStructurePath.js.map +0 -1
  247. package/out/utils/getOrCreateDir.d.ts +0 -2
  248. package/out/utils/getOrCreateDir.js +0 -63
  249. package/out/utils/getOrCreateDir.js.map +0 -1
  250. package/out/utils/getTestCodeInfo.d.ts +0 -2
  251. package/out/utils/getTestCodeInfo.js +0 -121
  252. package/out/utils/getTestCodeInfo.js.map +0 -1
  253. package/out/utils/getTestFile.d.ts +0 -13
  254. package/out/utils/getTestFile.js +0 -295
  255. package/out/utils/getTestFile.js.map +0 -1
  256. package/out/utils/parseBuildResult.d.ts +0 -3
  257. package/out/utils/parseBuildResult.js +0 -44
  258. package/out/utils/parseBuildResult.js.map +0 -1
  259. package/out/utils/parseSyntaxCheckResult.d.ts +0 -2
  260. package/out/utils/parseSyntaxCheckResult.js +0 -38
  261. package/out/utils/parseSyntaxCheckResult.js.map +0 -1
  262. package/out/utils/parseVstestResult.d.ts +0 -3
  263. package/out/utils/parseVstestResult.js +0 -61
  264. package/out/utils/parseVstestResult.js.map +0 -1
  265. package/out/utils/removeFailedTestMethods.d.ts +0 -3
  266. package/out/utils/removeFailedTestMethods.js +0 -207
  267. package/out/utils/removeFailedTestMethods.js.map +0 -1
  268. package/out/utils/runCommand.d.ts +0 -1
  269. package/out/utils/runCommand.js +0 -14
  270. package/out/utils/runCommand.js.map +0 -1
  271. package/out/utils/spawnExec.d.ts +0 -1
  272. package/out/utils/spawnExec.js +0 -80
  273. package/out/utils/spawnExec.js.map +0 -1
  274. package/out/utils/verifyBuildErrorCausedFile.d.ts +0 -1
  275. package/out/utils/verifyBuildErrorCausedFile.js +0 -60
  276. package/out/utils/verifyBuildErrorCausedFile.js.map +0 -1
  277. package/out/utils/verifyTestCode.d.ts +0 -2
  278. package/out/utils/verifyTestCode.js +0 -25
  279. package/out/utils/verifyTestCode.js.map +0 -1
  280. package/out/utils/writeGenCode.d.ts +0 -1
  281. package/out/utils/writeGenCode.js +0 -50
  282. package/out/utils/writeGenCode.js.map +0 -1
  283. package/out/vs/msBuild.d.ts +0 -13
  284. package/out/vs/msBuild.js +0 -49
  285. package/out/vs/msBuild.js.map +0 -1
  286. package/out/vs/vsTest.d.ts +0 -15
  287. package/out/vs/vsTest.js +0 -75
  288. package/out/vs/vsTest.js.map +0 -1
  289. package/out/vs/vsTools.d.ts +0 -7
  290. package/out/vs/vsTools.js +0 -177
  291. package/out/vs/vsTools.js.map +0 -1
  292. package/out/vsPlugin/getVsPluginVerifyResult.d.ts +0 -2
  293. package/out/vsPlugin/getVsPluginVerifyResult.js +0 -41
  294. package/out/vsPlugin/getVsPluginVerifyResult.js.map +0 -1
  295. package/out/vsPlugin/interactionConstants.d.ts +0 -2
  296. package/out/vsPlugin/interactionConstants.js +0 -10
  297. package/out/vsPlugin/interactionConstants.js.map +0 -1
  298. package/out/vsPlugin/sendStdToVsPlugin.d.ts +0 -1
  299. package/out/vsPlugin/sendStdToVsPlugin.js +0 -12
  300. package/out/vsPlugin/sendStdToVsPlugin.js.map +0 -1
  301. package/out/vsPlugin/stdListener.d.ts +0 -3
  302. package/out/vsPlugin/stdListener.js +0 -57
  303. package/out/vsPlugin/stdListener.js.map +0 -1
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.repairRequiredNameSpaces = repairRequiredNameSpaces;
4
- exports.repairXapRequiredNameSpaces = repairXapRequiredNameSpaces;
5
- const constants_1 = require("../../types/constants");
6
- function repairRequiredNameSpaces(code, testFramework) {
7
- const testFrameworkUsing = getTestFrameworkNameSpaces(testFramework);
8
- const requiredUsings = [
9
- testFrameworkUsing,
10
- ];
11
- code = repairMissingUsings(code, requiredUsings);
12
- return code;
13
- }
14
- function repairXapRequiredNameSpaces(code) {
15
- const xapUsings = [
16
- "using System;",
17
- "using System.Threading.Tasks;",
18
- "using System.Collections.Generic;",
19
- "using Xap.ExecutionFramework;",
20
- "using Xap.PluginFramework;",
21
- "using EMPTY = Microsoft.Bing.Xap.Plugins.Void;",
22
- ];
23
- code = repairMissingUsings(code, xapUsings);
24
- return code;
25
- }
26
- function repairMissingUsings(code, requiredUsings) {
27
- // get all using lines
28
- const usingRegex = /^\s*using\s+[^\r\n;]+;/gm;
29
- const existingUsings = Array.from(code.matchAll(usingRegex)).map(match => match[0].trim());
30
- const missingUsings = requiredUsings.filter(req => !existingUsings.includes(req));
31
- if (missingUsings.length === 0) {
32
- return code;
33
- }
34
- // find the end of the using block: the first non-using line, or the end of the file
35
- const lines = code.split(/\r?\n/);
36
- let insertIndex = 0;
37
- for (let i = 0; i < lines.length; i++) {
38
- if (!lines[i].trim().startsWith("using") && lines[i].trim() !== "") {
39
- insertIndex = i;
40
- break;
41
- }
42
- insertIndex = i + 1;
43
- }
44
- // build new code
45
- const newLines = [
46
- ...lines.slice(0, insertIndex),
47
- ...missingUsings,
48
- ...lines.slice(insertIndex)
49
- ];
50
- console.log("repaired namespaces:", missingUsings);
51
- return newLines.join('\n');
52
- }
53
- function getTestFrameworkNameSpaces(testFramework) {
54
- const msTestUsing = "using Microsoft.VisualStudio.TestTools.UnitTesting;";
55
- if (!testFramework) {
56
- return msTestUsing;
57
- }
58
- const FRAMEWORK_USINGS = {
59
- [constants_1.MSTESTFRAMEWORK]: msTestUsing,
60
- [constants_1.NUNITTESTFRAMEWORK]: "using NUnit.Framework;",
61
- [constants_1.XUNITTESTFRAMEWORK]: "using Xunit;"
62
- };
63
- return FRAMEWORK_USINGS[testFramework] || msTestUsing;
64
- }
65
- // const code = `
66
- // using Microsoft.VisualStudio.TestTools.UnitTesting;
67
- // using SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils;
68
- // using System;
69
- // using System.Collections.Generic;
70
- // using System.Text;
71
- // using Moq;
72
- // namespace SharedSegments.Plugins.Tests.Workflows.Overview.HttpRequestParser.Utils
73
- // {
74
- // [TestClass]
75
- // public class SqmidHelperTests
76
- // {
77
- // [TestMethod]
78
- // public void GetSqmidFromCookie_ValidCookiesWithBlisId_ReturnsDecodedBlisId()
79
- // {
80
- // // Arrange
81
- // var cookies = new Dictionary<string, string>
82
- // {
83
- // { "USRLOC", "BID=" + Convert.ToBase64String(Encoding.UTF8.GetBytes("test_decodedBlisId_test")) }
84
- // };
85
- // // Act
86
- // var result = SqmidHelper.GetSqmidFromCookie(cookies);
87
- // // Assert
88
- // Assert.AreEqual("decodedBlisId", result);
89
- // }
90
- // [TestMethod]
91
- // public void GetSqmidFromCookie_ValidCookiesWithoutBlisId_ReturnsNull()
92
- // {
93
- // // Arrange
94
- // var cookies = new Dictionary<string, string>
95
- // {
96
- // { "USRLOC", "SomeOtherValue=123" }
97
- // };
98
- // // Act
99
- // var result = SqmidHelper.GetSqmidFromCookie(cookies);
100
- // // Assert
101
- // Assert.IsNull(result);
102
- // }
103
- // [TestMethod]
104
- // public void GetSqmidFromCookie_EmptyCookies_ReturnsEmptyString()
105
- // {
106
- // // Arrange
107
- // var cookies = new Dictionary<string, string>();
108
- // // Act
109
- // var result = SqmidHelper.GetSqmidFromCookie(cookies);
110
- // // Assert
111
- // Assert.AreEqual(string.Empty, result);
112
- // }
113
- // [TestMethod]
114
- // public void GetSqmidFromCookie_NullCookies_ReturnsEmptyString()
115
- // {
116
- // // Arrange
117
- // IDictionary<string, string> cookies = null;
118
- // // Act
119
- // var result = SqmidHelper.GetSqmidFromCookie(cookies);
120
- // // Assert
121
- // Assert.AreEqual(string.Empty, result);
122
- // }
123
- // [TestMethod]
124
- // public void GetSqmidFromCookie_UsrLocWithEmptyValue_ReturnsEmptyString()
125
- // {
126
- // // Arrange
127
- // var cookies = new Dictionary<string, string>
128
- // {
129
- // { "USRLOC", "" }
130
- // };
131
- // // Act
132
- // var result = SqmidHelper.GetSqmidFromCookie(cookies);
133
- // // Assert
134
- // Assert.AreEqual(string.Empty, result);
135
- // }
136
- // }
137
- // }
138
- // `;
139
- // const cleanedCode = repairRequiredNameSpaces(code);
140
- // console.log(cleanedCode);
141
- //# sourceMappingURL=repairRequiredNameSpaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repairRequiredNameSpaces.js","sourceRoot":"","sources":["../../../src/gen/postGen/repairRequiredNameSpaces.ts"],"names":[],"mappings":";;AAEA,4DAQC;AAED,kEAYC;AAxBD,qDAAgG;AAEhG,SAAgB,wBAAwB,CAAC,IAAY,EAAE,aAAqB;IACxE,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG;QACnB,kBAAkB;KACrB,CAAC;IAEF,IAAI,GAAG,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,2BAA2B,CAAC,IAAY;IACpD,MAAM,SAAS,GAAG;QACd,eAAe;QACf,+BAA+B;QAC/B,mCAAmC;QACnC,+BAA+B;QAC/B,4BAA4B;QAC5B,gDAAgD;KACnD,CAAC;IAEF,IAAI,GAAG,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY,EAAE,cAAwB;IAC/D,sBAAsB;IACtB,MAAM,UAAU,GAAG,0BAA0B,CAAC;IAC9C,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3F,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAElF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,oFAAoF;IACpF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACjE,WAAW,GAAG,CAAC,CAAC;YAChB,MAAM;QACV,CAAC;QACD,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,iBAAiB;IACjB,MAAM,QAAQ,GAAG;QACb,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;QAC9B,GAAG,aAAa;QAChB,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;KAC9B,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;IAEnD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,0BAA0B,CAAC,aAAqB;IACrD,MAAM,WAAW,GAAG,qDAAqD,CAAC;IAE1E,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,MAAM,gBAAgB,GAAG;QACrB,CAAC,2BAAe,CAAC,EAAE,WAAW;QAC9B,CAAC,8BAAkB,CAAC,EAAE,wBAAwB;QAC9C,CAAC,8BAAkB,CAAC,EAAE,cAAc;KAC9B,CAAC;IAEX,OAAO,gBAAgB,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC;AAC1D,CAAC;AAID,iBAAiB;AACjB,sDAAsD;AACtD,2EAA2E;AAC3E,gBAAgB;AAChB,oCAAoC;AACpC,qBAAqB;AACrB,aAAa;AAEb,oFAAoF;AACpF,IAAI;AACJ,kBAAkB;AAClB,oCAAoC;AACpC,QAAQ;AACR,uBAAuB;AACvB,uFAAuF;AACvF,YAAY;AACZ,yBAAyB;AACzB,2DAA2D;AAC3D,gBAAgB;AAChB,mHAAmH;AACnH,iBAAiB;AAEjB,qBAAqB;AACrB,oEAAoE;AAEpE,wBAAwB;AACxB,wDAAwD;AACxD,YAAY;AAEZ,uBAAuB;AACvB,iFAAiF;AACjF,YAAY;AACZ,yBAAyB;AACzB,2DAA2D;AAC3D,gBAAgB;AAChB,qDAAqD;AACrD,iBAAiB;AAEjB,qBAAqB;AACrB,oEAAoE;AAEpE,wBAAwB;AACxB,qCAAqC;AACrC,YAAY;AAEZ,uBAAuB;AACvB,2EAA2E;AAC3E,YAAY;AACZ,yBAAyB;AACzB,8DAA8D;AAE9D,qBAAqB;AACrB,oEAAoE;AAEpE,wBAAwB;AACxB,qDAAqD;AACrD,YAAY;AAEZ,uBAAuB;AACvB,0EAA0E;AAC1E,YAAY;AACZ,yBAAyB;AACzB,0DAA0D;AAE1D,qBAAqB;AACrB,oEAAoE;AAEpE,wBAAwB;AACxB,qDAAqD;AACrD,YAAY;AAEZ,uBAAuB;AACvB,mFAAmF;AACnF,YAAY;AACZ,yBAAyB;AACzB,2DAA2D;AAC3D,gBAAgB;AAChB,mCAAmC;AACnC,iBAAiB;AAEjB,qBAAqB;AACrB,oEAAoE;AAEpE,wBAAwB;AACxB,qDAAqD;AACrD,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ,KAAK;AAEL,sDAAsD;AACtD,4BAA4B","sourcesContent":["import { MSTESTFRAMEWORK, NUNITTESTFRAMEWORK, XUNITTESTFRAMEWORK } from '../../types/constants';\r\n\r\nexport function repairRequiredNameSpaces(code: string, testFramework: string): string {\r\n const testFrameworkUsing = getTestFrameworkNameSpaces(testFramework);\r\n const requiredUsings = [\r\n testFrameworkUsing,\r\n ];\r\n\r\n code = repairMissingUsings(code, requiredUsings);\r\n return code;\r\n}\r\n\r\nexport function repairXapRequiredNameSpaces(code: string): string {\r\n const xapUsings = [\r\n \"using System;\",\r\n \"using System.Threading.Tasks;\",\r\n \"using System.Collections.Generic;\",\r\n \"using Xap.ExecutionFramework;\",\r\n \"using Xap.PluginFramework;\",\r\n \"using EMPTY = Microsoft.Bing.Xap.Plugins.Void;\",\r\n ];\r\n\r\n code = repairMissingUsings(code, xapUsings);\r\n return code;\r\n}\r\n\r\nfunction repairMissingUsings(code: string, requiredUsings: string[]): string {\r\n // get all using lines\r\n const usingRegex = /^\\s*using\\s+[^\\r\\n;]+;/gm;\r\n const existingUsings = Array.from(code.matchAll(usingRegex)).map(match => match[0].trim());\r\n\r\n const missingUsings = requiredUsings.filter(req => !existingUsings.includes(req));\r\n\r\n if (missingUsings.length === 0) {\r\n return code;\r\n }\r\n\r\n // find the end of the using block: the first non-using line, or the end of the file\r\n const lines = code.split(/\\r?\\n/);\r\n let insertIndex = 0;\r\n\r\n for (let i = 0; i < lines.length; i++) {\r\n if (!lines[i].trim().startsWith(\"using\") && lines[i].trim() !== \"\") {\r\n insertIndex = i;\r\n break;\r\n }\r\n insertIndex = i + 1;\r\n }\r\n\r\n // build new code\r\n const newLines = [\r\n ...lines.slice(0, insertIndex),\r\n ...missingUsings,\r\n ...lines.slice(insertIndex)\r\n ];\r\n\r\n console.log(\"repaired namespaces:\", missingUsings);\r\n\r\n return newLines.join('\\n');\r\n}\r\n\r\nfunction getTestFrameworkNameSpaces(testFramework: string): string {\r\n const msTestUsing = \"using Microsoft.VisualStudio.TestTools.UnitTesting;\";\r\n\r\n if (!testFramework) {\r\n return msTestUsing;\r\n }\r\n\r\n const FRAMEWORK_USINGS = {\r\n [MSTESTFRAMEWORK]: msTestUsing,\r\n [NUNITTESTFRAMEWORK]: \"using NUnit.Framework;\",\r\n [XUNITTESTFRAMEWORK]: \"using Xunit;\"\r\n } as const;\r\n\r\n return FRAMEWORK_USINGS[testFramework] || msTestUsing;\r\n}\r\n\r\n\r\n\r\n// const code = `\r\n// using Microsoft.VisualStudio.TestTools.UnitTesting;\r\n// using SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils;\r\n// using System;\r\n// using System.Collections.Generic;\r\n// using System.Text;\r\n// using Moq;\r\n\r\n// namespace SharedSegments.Plugins.Tests.Workflows.Overview.HttpRequestParser.Utils\r\n// {\r\n// [TestClass]\r\n// public class SqmidHelperTests\r\n// {\r\n// [TestMethod]\r\n// public void GetSqmidFromCookie_ValidCookiesWithBlisId_ReturnsDecodedBlisId()\r\n// {\r\n// // Arrange\r\n// var cookies = new Dictionary<string, string>\r\n// {\r\n// { \"USRLOC\", \"BID=\" + Convert.ToBase64String(Encoding.UTF8.GetBytes(\"test_decodedBlisId_test\")) }\r\n// };\r\n\r\n// // Act\r\n// var result = SqmidHelper.GetSqmidFromCookie(cookies);\r\n\r\n// // Assert\r\n// Assert.AreEqual(\"decodedBlisId\", result);\r\n// }\r\n\r\n// [TestMethod]\r\n// public void GetSqmidFromCookie_ValidCookiesWithoutBlisId_ReturnsNull()\r\n// {\r\n// // Arrange\r\n// var cookies = new Dictionary<string, string>\r\n// {\r\n// { \"USRLOC\", \"SomeOtherValue=123\" }\r\n// };\r\n\r\n// // Act\r\n// var result = SqmidHelper.GetSqmidFromCookie(cookies);\r\n\r\n// // Assert\r\n// Assert.IsNull(result);\r\n// }\r\n\r\n// [TestMethod]\r\n// public void GetSqmidFromCookie_EmptyCookies_ReturnsEmptyString()\r\n// {\r\n// // Arrange\r\n// var cookies = new Dictionary<string, string>();\r\n\r\n// // Act\r\n// var result = SqmidHelper.GetSqmidFromCookie(cookies);\r\n\r\n// // Assert\r\n// Assert.AreEqual(string.Empty, result);\r\n// }\r\n\r\n// [TestMethod]\r\n// public void GetSqmidFromCookie_NullCookies_ReturnsEmptyString()\r\n// {\r\n// // Arrange\r\n// IDictionary<string, string> cookies = null;\r\n\r\n// // Act\r\n// var result = SqmidHelper.GetSqmidFromCookie(cookies);\r\n\r\n// // Assert\r\n// Assert.AreEqual(string.Empty, result);\r\n// }\r\n\r\n// [TestMethod]\r\n// public void GetSqmidFromCookie_UsrLocWithEmptyValue_ReturnsEmptyString()\r\n// {\r\n// // Arrange\r\n// var cookies = new Dictionary<string, string>\r\n// {\r\n// { \"USRLOC\", \"\" }\r\n// };\r\n\r\n// // Act\r\n// var result = SqmidHelper.GetSqmidFromCookie(cookies);\r\n\r\n// // Assert\r\n// Assert.AreEqual(string.Empty, result);\r\n// }\r\n// }\r\n// }\r\n// `;\r\n\r\n// const cleanedCode = repairRequiredNameSpaces(code);\r\n// console.log(cleanedCode);"]}
@@ -1 +0,0 @@
1
- export declare function validateTestCode(testCode: string): boolean;
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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}"]}
@@ -1 +0,0 @@
1
- export declare function excludeFileName(filePath: string): boolean;
@@ -1,49 +0,0 @@
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
@@ -1 +0,0 @@
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}"]}
@@ -1 +0,0 @@
1
- export declare function excludeSpecificTag(sourceCode: string): boolean;
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
1
- export declare function preGenProcess(sourceCode: string, sourceFilePath: string, isXapCode?: boolean): Promise<string>;
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
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.\");"]}
@@ -1,3 +0,0 @@
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;
@@ -1,62 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,3 +0,0 @@
1
- export { generateCsharpUtCode } from './gen/csharpUtGen';
2
- export { generateBatchTests } from './batch/generateCodeTests';
3
- export { setup } from './setup/setup';
package/out/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setup = exports.generateBatchTests = 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 generateCodeTests_1 = require("./batch/generateCodeTests");
7
- Object.defineProperty(exports, "generateBatchTests", { enumerable: true, get: function () { return generateCodeTests_1.generateBatchTests; } });
8
- var setup_1 = require("./setup/setup");
9
- Object.defineProperty(exports, "setup", { enumerable: true, get: function () { return setup_1.setup; } });
10
- //# sourceMappingURL=index.js.map
package/out/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAAhD,mHAAA,oBAAoB,OAAA;AAC7B,+DAA+D;AAAtD,uHAAA,kBAAkB,OAAA;AAC3B,uCAAsC;AAA7B,8FAAA,KAAK,OAAA","sourcesContent":["export { generateCsharpUtCode } from './gen/csharpUtGen';\r\nexport { generateBatchTests } from './batch/generateCodeTests';\r\nexport { setup } from './setup/setup';"]}
@@ -1 +0,0 @@
1
- export declare function getLLMResponse(prompt: any): Promise<any>;
@@ -1,93 +0,0 @@
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://weatherutswedencentral.cognitiveservices.azure.com/openai/deployments/gpt-5-chat/chat/completions?api-version=2025-01-01-preview";
14
- // const gptEndpoint = "https://weatherut.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
15
- // const gptEndpoint = "https://autogenerate-unit-tests-draft-1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
16
- // const gptEndpoint = "https://weathergptv4.openai.azure.com/openai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview";
17
- // const gptEndpoint = "https://takht-m99407ib-swedencentral.cognitiveservices.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
18
- async function getToken() {
19
- const currentTime = new Date().getTime();
20
- // Check if the cached token is still valid
21
- if (cachedToken && tokenExpiration && currentTime < tokenExpiration) {
22
- return cachedToken;
23
- }
24
- try {
25
- const credential = new identity_1.ChainedTokenCredential(new identity_1.AzureCliCredential(), new identity_1.ManagedIdentityCredential(), new identity_1.DefaultAzureCredential() // CodeQL [SM05138] This is non-production testing code which is not deployed.
26
- );
27
- const tokenResponse = await credential.getToken('https://cognitiveservices.azure.com/.default');
28
- if (tokenResponse) {
29
- cachedToken = tokenResponse.token;
30
- // Set token expiration time based on the token's expiresOnTimestamp
31
- tokenExpiration = tokenResponse.expiresOnTimestamp;
32
- return cachedToken;
33
- }
34
- else {
35
- throw new Error('Failed to obtain token');
36
- }
37
- }
38
- catch (error) {
39
- console.error('Error obtaining token:', error);
40
- if (error.toString().includes('az login')) {
41
- console.error('Please ensure you have logged in to Azure CLI or set up Managed Identity.');
42
- (0, runCommand_1.runCommand)('az login');
43
- return getToken(); // Retry after login
44
- }
45
- else {
46
- throw error;
47
- }
48
- }
49
- }
50
- async function getLLMResponse(prompt) {
51
- const token = await getToken();
52
- const res = await (0, node_fetch_1.default)(gptEndpoint, {
53
- method: 'POST',
54
- headers: {
55
- 'Content-Type': 'application/json',
56
- Authorization: 'Bearer ' + token,
57
- },
58
- body: JSON.stringify({
59
- messages: prompt,
60
- temperature: 0.1,
61
- top_p: 1,
62
- n: 1
63
- })
64
- });
65
- const json = await res.json();
66
- return json;
67
- }
68
- // const reqBody =
69
- // {
70
- // "messages": [
71
- // {
72
- // "role": "system",
73
- // "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."
74
- // },
75
- // {
76
- // "role": "assistant",
77
- // "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."
78
- // },
79
- // {
80
- // "role": "user",
81
- // "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>'
82
- // }
83
- // ],
84
- // "model": "gpt-4o",
85
- // "temperature": 0.1,
86
- // "top_p": 1,
87
- // "max_tokens": 4096,
88
- // "n": 1
89
- // };
90
- // getLLMResponse("Generate xUnit tests for the ToListCountAnalyzer class.").then((response) => {
91
- // console.log(response.choices[0]?.message?.content)
92
- // });
93
- //# sourceMappingURL=Gpt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Gpt.js","sourceRoot":"","sources":["../../../src/llm/model/Gpt.ts"],"names":[],"mappings":";;;;;AAoDA,wCAkBC;AAtED,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,0IAA0I,CAAC;AAC/J,sIAAsI;AACtI,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,CAAC,8EAA8E;SAC9G,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://weatherutswedencentral.cognitiveservices.azure.com/openai/deployments/gpt-5-chat/chat/completions?api-version=2025-01-01-preview\";\r\n// const 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() // CodeQL [SM05138] This is non-production testing code which is not deployed.\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// });"]}
@@ -1,2 +0,0 @@
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[];