@ai-dev-tools/csharp-copilot-core 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/analyze/cecil.d.ts +1 -0
- package/out/analyze/cecil.js +42 -0
- package/out/analyze/cecil.js.map +1 -0
- package/out/analyze/checkCodeSyntax.d.ts +7 -0
- package/out/analyze/checkCodeSyntax.js +67 -0
- package/out/analyze/checkCodeSyntax.js.map +1 -0
- package/out/analyze/generateCodeDependency.d.ts +6 -0
- package/out/analyze/generateCodeDependency.js +127 -0
- package/out/analyze/generateCodeDependency.js.map +1 -0
- package/out/analyze/installAnalyzerTool.d.ts +1 -0
- package/out/analyze/installAnalyzerTool.js +83 -0
- package/out/analyze/installAnalyzerTool.js.map +1 -0
- package/out/batch/generateCodeTests.d.ts +6 -0
- package/out/batch/generateCodeTests.js +163 -0
- package/out/batch/generateCodeTests.js.map +1 -0
- package/out/batch/getFolderCodeFile.d.ts +1 -0
- package/out/batch/getFolderCodeFile.js +19 -0
- package/out/batch/getFolderCodeFile.js.map +1 -0
- package/out/batch/getProjectCodeFile.d.ts +4 -0
- package/out/batch/getProjectCodeFile.js +86 -0
- package/out/batch/getProjectCodeFile.js.map +1 -0
- package/out/batch/getSolutionCodeFile.d.ts +8 -0
- package/out/batch/getSolutionCodeFile.js +70 -0
- package/out/batch/getSolutionCodeFile.js.map +1 -0
- package/out/benchmark/formatToMarkdown.d.ts +2 -0
- package/out/benchmark/formatToMarkdown.js +101 -0
- package/out/benchmark/formatToMarkdown.js.map +1 -0
- package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
- package/out/benchmark/generateBenchmarkReport.js +82 -0
- package/out/benchmark/generateBenchmarkReport.js.map +1 -0
- package/out/codeCoverage/codeCoverage.d.ts +6 -0
- package/out/codeCoverage/codeCoverage.js +39 -0
- package/out/codeCoverage/codeCoverage.js.map +1 -0
- package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
- package/out/codeCoverage/codeCoverageReport.js +76 -0
- package/out/codeCoverage/codeCoverageReport.js.map +1 -0
- package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js +81 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
- package/out/codeCoverage/extractCoverageReportPath.d.ts +1 -0
- package/out/codeCoverage/extractCoverageReportPath.js +25 -0
- package/out/codeCoverage/extractCoverageReportPath.js.map +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.js +30 -0
- package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
- package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
- package/out/codeCoverage/reportTool.d.ts +2 -0
- package/out/codeCoverage/reportTool.js +23 -0
- package/out/codeCoverage/reportTool.js.map +1 -0
- package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
- package/out/codeCoverage/simplifyCoverageXml.js +117 -0
- package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
- package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
- package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
- package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
- package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
- package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
- package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
- package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
- package/out/codebk/childProcessManager.d.ts +1 -0
- package/out/codebk/childProcessManager.js +50 -0
- package/out/codebk/childProcessManager.js.map +1 -0
- package/out/codebk/msBuidSpawn.d.ts +1 -0
- package/out/codebk/msBuidSpawn.js +58 -0
- package/out/codebk/msBuidSpawn.js.map +1 -0
- package/out/codebk/msBuild.d.ts +1 -0
- package/out/codebk/msBuild.js +123 -0
- package/out/codebk/msBuild.js.map +1 -0
- package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
- package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
- package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
- package/out/codebk/old/xapGuideline-fm.liquid +149 -0
- package/out/codebk/old/xapGuideline.liquid +37 -0
- package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
- package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
- package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
- package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverage.js +54 -0
- package/out/codebk/oldExec/codeCoverage.js.map +1 -0
- package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverageReport.js +64 -0
- package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
- package/out/codebk/oldExec/containsMethods.d.ts +1 -0
- package/out/codebk/oldExec/containsMethods.js +74 -0
- package/out/codebk/oldExec/containsMethods.js.map +1 -0
- package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
- package/out/codebk/oldExec/generateCodeDependency.js +95 -0
- package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
- package/out/codebk/oldExec/msBuild.d.ts +1 -0
- package/out/codebk/oldExec/msBuild.js +53 -0
- package/out/codebk/oldExec/msBuild.js.map +1 -0
- package/out/codebk/oldExec/vsTest.d.ts +1 -0
- package/out/codebk/oldExec/vsTest.js +71 -0
- package/out/codebk/oldExec/vsTest.js.map +1 -0
- package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
- package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
- package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
- package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
- package/out/codebk/testbuildkill.d.ts +1 -0
- package/out/codebk/testbuildkill.js +37 -0
- package/out/codebk/testbuildkill.js.map +1 -0
- package/out/command/index.d.ts +2 -0
- package/out/command/index.js +90 -0
- package/out/command/index.js.map +1 -0
- package/out/command/utGenWrapper.d.ts +3 -0
- package/out/command/utGenWrapper.js +53 -0
- package/out/command/utGenWrapper.js.map +1 -0
- package/out/exit/childProcessManager.d.ts +2 -0
- package/out/exit/childProcessManager.js +43 -0
- package/out/exit/childProcessManager.js.map +1 -0
- package/out/exit/setupProcessSignalHandler.d.ts +1 -0
- package/out/exit/setupProcessSignalHandler.js +18 -0
- package/out/exit/setupProcessSignalHandler.js.map +1 -0
- package/out/gen/autoFix.d.ts +4 -0
- package/out/gen/autoFix.js +129 -0
- package/out/gen/autoFix.js.map +1 -0
- package/out/gen/csharpUtGen.d.ts +2 -0
- package/out/gen/csharpUtGen.js +125 -0
- package/out/gen/csharpUtGen.js.map +1 -0
- package/out/gen/ensureValidLLMResponse.d.ts +1 -0
- package/out/gen/ensureValidLLMResponse.js +19 -0
- package/out/gen/ensureValidLLMResponse.js.map +1 -0
- package/out/gen/postGen/addAiAnnotation.d.ts +1 -0
- package/out/gen/postGen/addAiAnnotation.js +57 -0
- package/out/gen/postGen/addAiAnnotation.js.map +1 -0
- package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
- package/out/gen/postGen/extractCodeFromResponse.js +38 -0
- package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
- package/out/gen/postGen/postGenProcess.d.ts +1 -0
- package/out/gen/postGen/postGenProcess.js +39 -0
- package/out/gen/postGen/postGenProcess.js.map +1 -0
- package/out/gen/postGen/removeComments.d.ts +1 -0
- package/out/gen/postGen/removeComments.js +92 -0
- package/out/gen/postGen/removeComments.js.map +1 -0
- package/out/gen/postGen/removeSingleLines.d.ts +1 -0
- package/out/gen/postGen/removeSingleLines.js +29 -0
- package/out/gen/postGen/removeSingleLines.js.map +1 -0
- package/out/gen/postGen/repairRequiredNameSpaces.d.ts +2 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js +142 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
- package/out/gen/postGen/validateTestCode.d.ts +1 -0
- package/out/gen/postGen/validateTestCode.js +14 -0
- package/out/gen/postGen/validateTestCode.js.map +1 -0
- package/out/gen/preGen/excludeFileName.d.ts +1 -0
- package/out/gen/preGen/excludeFileName.js +49 -0
- package/out/gen/preGen/excludeFileName.js.map +1 -0
- package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
- package/out/gen/preGen/excludeSpecificTag.js +19 -0
- package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
- package/out/gen/preGen/preGenProcess.d.ts +1 -0
- package/out/gen/preGen/preGenProcess.js +22 -0
- package/out/gen/preGen/preGenProcess.js.map +1 -0
- package/out/gen/preGen/validateCode.d.ts +3 -0
- package/out/gen/preGen/validateCode.js +63 -0
- package/out/gen/preGen/validateCode.js.map +1 -0
- package/out/index.d.ts +3 -0
- package/out/index.js +10 -0
- package/out/index.js.map +1 -0
- package/out/llm/model/Gpt.d.ts +1 -0
- package/out/llm/model/Gpt.js +93 -0
- package/out/llm/model/Gpt.js.map +1 -0
- package/out/llm/preparePrompt.d.ts +2 -0
- package/out/llm/preparePrompt.js +135 -0
- package/out/llm/preparePrompt.js.map +1 -0
- package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
- package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
- package/out/llm/prompt/generateUtAutoFix.liquid +23 -0
- package/out/llm/prompt/generateUtDependency.liquid +3 -0
- package/out/llm/prompt/generateUtSystem.liquid +5 -0
- package/out/llm/prompt/generateUtTemplate.liquid +32 -0
- package/out/llm/prompt/generateUtUserInput.liquid +4 -0
- package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
- package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
- package/out/llm/sendRequestToLLM.d.ts +4 -0
- package/out/llm/sendRequestToLLM.js +9 -0
- package/out/llm/sendRequestToLLM.js.map +1 -0
- package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
- package/out/llm/sendRequestToSelfHostLLM.js +41 -0
- package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
- package/out/metrics/appInsightTelemetry.d.ts +6 -0
- package/out/metrics/appInsightTelemetry.js +77 -0
- package/out/metrics/appInsightTelemetry.js.map +1 -0
- package/out/metrics/machineId.d.ts +11 -0
- package/out/metrics/machineId.js +85 -0
- package/out/metrics/machineId.js.map +1 -0
- package/out/setup/setup.d.ts +1 -0
- package/out/setup/setup.js +10 -0
- package/out/setup/setup.js.map +1 -0
- package/out/setup/setupConsole.d.ts +1 -0
- package/out/setup/setupConsole.js +23 -0
- package/out/setup/setupConsole.js.map +1 -0
- package/out/setup/setupLLMRequest.d.ts +2 -0
- package/out/setup/setupLLMRequest.js +10 -0
- package/out/setup/setupLLMRequest.js.map +1 -0
- package/out/tools/devenvcom.cmd +13 -0
- package/out/tools/devenvexe.cmd +13 -0
- package/out/tools/msbuildexe.cmd +13 -0
- package/out/tools/vstestexe.cmd +13 -0
- package/out/types/benchmark.d.ts +11 -0
- package/out/types/benchmark.js +3 -0
- package/out/types/benchmark.js.map +1 -0
- package/out/types/buildResult.d.ts +8 -0
- package/out/types/buildResult.js +3 -0
- package/out/types/buildResult.js.map +1 -0
- package/out/types/constants.d.ts +10 -0
- package/out/types/constants.js +14 -0
- package/out/types/constants.js.map +1 -0
- package/out/types/genResult.d.ts +10 -0
- package/out/types/genResult.js +3 -0
- package/out/types/genResult.js.map +1 -0
- package/out/types/testResult.d.ts +12 -0
- package/out/types/testResult.js +3 -0
- package/out/types/testResult.js.map +1 -0
- package/out/types/verifyResult.d.ts +8 -0
- package/out/types/verifyResult.js +3 -0
- package/out/types/verifyResult.js.map +1 -0
- package/out/utils/checkTestProject.d.ts +2 -0
- package/out/utils/checkTestProject.js +79 -0
- package/out/utils/checkTestProject.js.map +1 -0
- package/out/utils/checkXapCode.d.ts +2 -0
- package/out/utils/checkXapCode.js +59 -0
- package/out/utils/checkXapCode.js.map +1 -0
- package/out/utils/delay.d.ts +1 -0
- package/out/utils/delay.js +7 -0
- package/out/utils/delay.js.map +1 -0
- package/out/utils/detectTestFramework.d.ts +1 -0
- package/out/utils/detectTestFramework.js +33 -0
- package/out/utils/detectTestFramework.js.map +1 -0
- package/out/utils/fileUtils.d.ts +2 -0
- package/out/utils/fileUtils.js +42 -0
- package/out/utils/fileUtils.js.map +1 -0
- package/out/utils/generateCodeSha256.d.ts +1 -0
- package/out/utils/generateCodeSha256.js +46 -0
- package/out/utils/generateCodeSha256.js.map +1 -0
- package/out/utils/getCodeStructurePath.d.ts +5 -0
- package/out/utils/getCodeStructurePath.js +155 -0
- package/out/utils/getCodeStructurePath.js.map +1 -0
- package/out/utils/getOrCreateDir.d.ts +2 -0
- package/out/utils/getOrCreateDir.js +63 -0
- package/out/utils/getOrCreateDir.js.map +1 -0
- package/out/utils/getTestCodeInfo.d.ts +2 -0
- package/out/utils/getTestCodeInfo.js +121 -0
- package/out/utils/getTestCodeInfo.js.map +1 -0
- package/out/utils/getTestFile.d.ts +13 -0
- package/out/utils/getTestFile.js +297 -0
- package/out/utils/getTestFile.js.map +1 -0
- package/out/utils/parseBuildResult.d.ts +3 -0
- package/out/utils/parseBuildResult.js +45 -0
- package/out/utils/parseBuildResult.js.map +1 -0
- package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
- package/out/utils/parseSyntaxCheckResult.js +39 -0
- package/out/utils/parseSyntaxCheckResult.js.map +1 -0
- package/out/utils/parseVstestResult.d.ts +3 -0
- package/out/utils/parseVstestResult.js +62 -0
- package/out/utils/parseVstestResult.js.map +1 -0
- package/out/utils/removeFailedTestMethods.d.ts +3 -0
- package/out/utils/removeFailedTestMethods.js +208 -0
- package/out/utils/removeFailedTestMethods.js.map +1 -0
- package/out/utils/runCommand.d.ts +1 -0
- package/out/utils/runCommand.js +14 -0
- package/out/utils/runCommand.js.map +1 -0
- package/out/utils/spawnExec.d.ts +1 -0
- package/out/utils/spawnExec.js +80 -0
- package/out/utils/spawnExec.js.map +1 -0
- package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
- package/out/utils/verifyBuildErrorCausedFile.js +60 -0
- package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
- package/out/utils/verifyTestCode.d.ts +2 -0
- package/out/utils/verifyTestCode.js +25 -0
- package/out/utils/verifyTestCode.js.map +1 -0
- package/out/utils/writeFailedVerifyResult.d.ts +1 -0
- package/out/utils/writeFailedVerifyResult.js +67 -0
- package/out/utils/writeFailedVerifyResult.js.map +1 -0
- package/out/utils/writeGenCode.d.ts +1 -0
- package/out/utils/writeGenCode.js +63 -0
- package/out/utils/writeGenCode.js.map +1 -0
- package/out/vs/msBuild.d.ts +13 -0
- package/out/vs/msBuild.js +49 -0
- package/out/vs/msBuild.js.map +1 -0
- package/out/vs/vsTest.d.ts +15 -0
- package/out/vs/vsTest.js +75 -0
- package/out/vs/vsTest.js.map +1 -0
- package/out/vs/vsTools.d.ts +7 -0
- package/out/vs/vsTools.js +177 -0
- package/out/vs/vsTools.js.map +1 -0
- package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
- package/out/vsPlugin/interactionConstants.d.ts +2 -0
- package/out/vsPlugin/interactionConstants.js +10 -0
- package/out/vsPlugin/interactionConstants.js.map +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
- package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
- package/out/vsPlugin/stdListener.d.ts +3 -0
- package/out/vsPlugin/stdListener.js +57 -0
- package/out/vsPlugin/stdListener.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
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.extractCoberturaXmlPath = extractCoberturaXmlPath;
|
|
37
|
+
exports.getLineCoverage = getLineCoverage;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
40
|
+
const constants_1 = require("../types/constants");
|
|
41
|
+
function extractCoberturaXmlPath(log) {
|
|
42
|
+
const lines = log.split(constants_1.LINESEPARATOR);
|
|
43
|
+
const startIndex = lines.findIndex((line) => line.trim() === "Attachments:");
|
|
44
|
+
if (startIndex === -1)
|
|
45
|
+
return null;
|
|
46
|
+
for (let i = startIndex + 1; i < lines.length; i++) {
|
|
47
|
+
const line = lines[i].trim();
|
|
48
|
+
if (line.endsWith(".cobertura.xml")) {
|
|
49
|
+
return line;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function getLineCoverage(coverageXmlPath) {
|
|
55
|
+
// parse XML
|
|
56
|
+
const xmlContent = fs.readFileSync(coverageXmlPath, 'utf-8');
|
|
57
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
58
|
+
ignoreAttributes: false,
|
|
59
|
+
attributeNamePrefix: '',
|
|
60
|
+
});
|
|
61
|
+
const result = parser.parse(xmlContent);
|
|
62
|
+
// extract coverage
|
|
63
|
+
const coverage = result.coverage;
|
|
64
|
+
const totalLineRate = parseFloat(coverage['line-rate']);
|
|
65
|
+
console.log(`Total Line Coverage: ${(totalLineRate * 100).toFixed(2)}%`);
|
|
66
|
+
// // extract coverage for each class
|
|
67
|
+
// const packages = coverage.packages?.package ?? [];
|
|
68
|
+
// const classes = Array.isArray(packages)
|
|
69
|
+
// ? packages.flatMap(p => p.classes?.class ?? [])
|
|
70
|
+
// : packages.classes?.class ?? [];
|
|
71
|
+
// console.log('\n📁 Per-Class Line Coverage:');
|
|
72
|
+
// classes.forEach((cls: any) => {
|
|
73
|
+
// const file = cls.filename || cls.name;
|
|
74
|
+
// const lineRate = parseFloat(cls['line-rate']);
|
|
75
|
+
// console.log(`- ${file}: ${(lineRate * 100).toFixed(2)}%`);
|
|
76
|
+
// });
|
|
77
|
+
}
|
|
78
|
+
// getLineCoverage("C:\\Users\\jixiongge\\code\\atmp\\TestResults\\505883d3-b9b2-47e2-99e5-468b7120268f\\jixiongge_CPC-jixio-9B9DD_2025-07-11.17_14_56.cobertura.xml");
|
|
79
|
+
// getLineCoverage("C:\\Users\\jixiongge\\code\\atmp\\TestResults\\3bdc7736-f79d-4866-874a-58bd31be18d4\\jixiongge_CPC-jixio-9B9DD_2025-07-10.21_45_35.cobertura.xml");
|
|
80
|
+
// getCodeCoverageSetting("C:\\Users\\jixiongge\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj");
|
|
81
|
+
//# sourceMappingURL=extractCodeCoverageInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractCodeCoverageInfo.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCodeCoverageInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,0DAcC;AAED,0CA0BC;AA9CD,uCAAyB;AACzB,qDAA4C;AAC5C,kDAAmD;AAEnD,SAAgB,uBAAuB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;IAEvC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,cAAc,CAAC,CAAC;IAC7E,IAAI,UAAU,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAAC,eAAuB;IACnD,YAAY;IACZ,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC;QACzB,gBAAgB,EAAE,KAAK;QACvB,mBAAmB,EAAE,EAAE;KAC1B,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAExC,mBAAmB;IACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEzE,qCAAqC;IACrC,qDAAqD;IACrD,0CAA0C;IAC1C,sDAAsD;IACtD,uCAAuC;IAEvC,gDAAgD;IAChD,kCAAkC;IAClC,6CAA6C;IAC7C,qDAAqD;IACrD,iEAAiE;IACjE,MAAM;AACV,CAAC;AAED,uKAAuK;AACvK,uKAAuK;AACvK,mKAAmK","sourcesContent":["import * as fs from 'fs';\r\nimport { XMLParser } from 'fast-xml-parser';\r\nimport { LINESEPARATOR } from '../types/constants';\r\n\r\nexport function extractCoberturaXmlPath(log: string): string | null {\r\n const lines = log.split(LINESEPARATOR);\r\n\r\n const startIndex = lines.findIndex((line) => line.trim() === \"Attachments:\");\r\n if (startIndex === -1) return null;\r\n\r\n for (let i = startIndex + 1; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n if (line.endsWith(\".cobertura.xml\")) {\r\n return line;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function getLineCoverage(coverageXmlPath: string) {\r\n // parse XML\r\n const xmlContent = fs.readFileSync(coverageXmlPath, 'utf-8');\r\n const parser = new XMLParser({\r\n ignoreAttributes: false,\r\n attributeNamePrefix: '',\r\n });\r\n const result = parser.parse(xmlContent);\r\n\r\n // extract coverage\r\n const coverage = result.coverage;\r\n const totalLineRate = parseFloat(coverage['line-rate']);\r\n console.log(`Total Line Coverage: ${(totalLineRate * 100).toFixed(2)}%`);\r\n\r\n // // extract coverage for each class\r\n // const packages = coverage.packages?.package ?? [];\r\n // const classes = Array.isArray(packages)\r\n // ? packages.flatMap(p => p.classes?.class ?? [])\r\n // : packages.classes?.class ?? [];\r\n\r\n // console.log('\\n📁 Per-Class Line Coverage:');\r\n // classes.forEach((cls: any) => {\r\n // const file = cls.filename || cls.name;\r\n // const lineRate = parseFloat(cls['line-rate']);\r\n // console.log(`- ${file}: ${(lineRate * 100).toFixed(2)}%`);\r\n // });\r\n}\r\n\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\505883d3-b9b2-47e2-99e5-468b7120268f\\\\jixiongge_CPC-jixio-9B9DD_2025-07-11.17_14_56.cobertura.xml\");\r\n// getLineCoverage(\"C:\\\\Users\\\\jixiongge\\\\code\\\\atmp\\\\TestResults\\\\3bdc7736-f79d-4866-874a-58bd31be18d4\\\\jixiongge_CPC-jixio-9B9DD_2025-07-10.21_45_35.cobertura.xml\");\r\n// getCodeCoverageSetting(\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\");"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCoverageReportPath(log: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCoverageReportPath = extractCoverageReportPath;
|
|
4
|
+
const constants_1 = require("../types/constants");
|
|
5
|
+
function extractCoverageReportPath(log) {
|
|
6
|
+
const lines = log.split(constants_1.LINESEPARATOR);
|
|
7
|
+
const resultLine = lines.find((line) => line.trim().includes("index.html"));
|
|
8
|
+
if (!resultLine)
|
|
9
|
+
return null;
|
|
10
|
+
const startIndex = resultLine.indexOf("'");
|
|
11
|
+
const endIndex = resultLine.lastIndexOf("'");
|
|
12
|
+
const reportRelativePath = resultLine.substring(startIndex + 1, endIndex);
|
|
13
|
+
return reportRelativePath;
|
|
14
|
+
}
|
|
15
|
+
// const log =
|
|
16
|
+
// `2025-08-05T14:27:36: Arguments
|
|
17
|
+
// 2025-08-05T14:27:36: -reports:D:\\code\\ai-dev-tools\\csharp-ut-copilot\\csharp-ut-core\\out\\atmpCache\\codecoverage\\TestResults\\2638fc6b-b1d0-4c73-8a5f-475f12da315e\\jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified.xml
|
|
18
|
+
// 2025-08-05T14:27:36: -targetdir:CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified
|
|
19
|
+
// 2025-08-05T14:27:36: -reporttypes:Html
|
|
20
|
+
// 2025-08-05T14:27:36: Writing report file 'CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\\index.html'
|
|
21
|
+
// 2025-08-05T14:27:36: Report generation took 0.1 seconds
|
|
22
|
+
// `;
|
|
23
|
+
// const path = extractCoverageReportPath(log);
|
|
24
|
+
// console.log(`Extracted coverage report path: ${path}`);
|
|
25
|
+
//# sourceMappingURL=extractCoverageReportPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractCoverageReportPath.js","sourceRoot":"","sources":["../../src/codeCoverage/extractCoverageReportPath.ts"],"names":[],"mappings":";;AAEA,8DAWC;AAbD,kDAAmD;AAEnD,SAAgB,yBAAyB,CAAC,GAAW;IAChD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAE1E,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAED,cAAc;AACd,kCAAkC;AAClC,6OAA6O;AAC7O,8GAA8G;AAC9G,0CAA0C;AAC1C,oIAAoI;AACpI,0DAA0D;AAC1D,KAAK;AAEL,+CAA+C;AAC/C,0DAA0D","sourcesContent":["import { LINESEPARATOR } from \"../types/constants\";\r\n\r\nexport function extractCoverageReportPath(log: string): string {\r\n const lines = log.split(LINESEPARATOR);\r\n\r\n const resultLine = lines.find((line) => line.trim().includes(\"index.html\"));\r\n if (!resultLine) return null;\r\n\r\n const startIndex = resultLine.indexOf(\"'\");\r\n const endIndex = resultLine.lastIndexOf(\"'\");\r\n const reportRelativePath = resultLine.substring(startIndex + 1, endIndex);\r\n\r\n return reportRelativePath;\r\n}\r\n\r\n// const log =\r\n// `2025-08-05T14:27:36: Arguments\r\n// 2025-08-05T14:27:36: -reports:D:\\\\code\\\\ai-dev-tools\\\\csharp-ut-copilot\\\\csharp-ut-core\\\\out\\\\atmpCache\\\\codecoverage\\\\TestResults\\\\2638fc6b-b1d0-4c73-8a5f-475f12da315e\\\\jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified.xml\r\n// 2025-08-05T14:27:36: -targetdir:CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\r\n// 2025-08-05T14:27:36: -reporttypes:Html\r\n// 2025-08-05T14:27:36: Writing report file 'CoverageReport-jixiongge_VECTORWC_2025-08-05.14_27_19.cobertura_simplified\\\\index.html'\r\n// 2025-08-05T14:27:36: Report generation took 0.1 seconds\r\n// `;\r\n\r\n// const path = extractCoverageReportPath(log);\r\n// console.log(`Extracted coverage report path: ${path}`);"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateCodeCoverageReport(testProjectPaths: string[], sourceCodePaths: string[]): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCodeCoverageReport = generateCodeCoverageReport;
|
|
4
|
+
const getCodeStructurePath_1 = require("../utils/getCodeStructurePath");
|
|
5
|
+
const getCodeCoverageSetting_1 = require("./getCodeCoverageSetting");
|
|
6
|
+
const codeCoverage_1 = require("./codeCoverage");
|
|
7
|
+
const codeCoverageReport_1 = require("./codeCoverageReport");
|
|
8
|
+
const simplifyCoverageXml_1 = require("./simplifyCoverageXml");
|
|
9
|
+
async function generateCodeCoverageReport(testProjectPaths, sourceCodePaths) {
|
|
10
|
+
const startTime = Date.now();
|
|
11
|
+
for (const testProjectPath of testProjectPaths) {
|
|
12
|
+
const dllPath = (0, getCodeStructurePath_1.getBuiltDllPath)(testProjectPath);
|
|
13
|
+
const codeCoverageSetting = (0, getCodeCoverageSetting_1.getCodeCoverageSetting)(testProjectPath);
|
|
14
|
+
const { success, message } = await (0, codeCoverage_1.runCodeCoverage)(dllPath, codeCoverageSetting);
|
|
15
|
+
if (!message.endsWith("xml")) {
|
|
16
|
+
console.error(`Generating code coverage report failed, test project path: ${testProjectPath}, coverageSetting: ${codeCoverageSetting}, error: ${message}`);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const coberturaXmlPath = message;
|
|
20
|
+
const simplifiedXmlPath = (0, simplifyCoverageXml_1.simplifyCoverageXmlByFiles)(coberturaXmlPath, sourceCodePaths);
|
|
21
|
+
(0, codeCoverageReport_1.runCodeCoverageReport)(simplifiedXmlPath);
|
|
22
|
+
}
|
|
23
|
+
console.log(`code coverage report generation time: ${(Date.now() - startTime) / 1000} seconds`);
|
|
24
|
+
}
|
|
25
|
+
// const testProjectPaths = ["C:\\Users\\jixiongge\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj"];
|
|
26
|
+
// generateCodeCoverageReport(testProjectPaths);
|
|
27
|
+
// getAllCsFiles("D:\\code\\AIUnitTestExample\\src").then(paths => {
|
|
28
|
+
// generateCodeCoverageReport(["D:\\code\\AIUnitTestExample\\test\\ToListinator.Tests\\ToListinator.Tests.csproj"], paths);
|
|
29
|
+
// });
|
|
30
|
+
//# sourceMappingURL=generateCodeCoverageReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCodeCoverageReport.js","sourceRoot":"","sources":["../../src/codeCoverage/generateCodeCoverageReport.ts"],"names":[],"mappings":";;AAOA,gEAiBC;AAvBD,wEAAgE;AAChE,qEAAkE;AAClE,iDAAiD;AACjD,6DAA6D;AAC7D,+DAAmE;AAE5D,KAAK,UAAU,0BAA0B,CAAC,gBAA0B,EAAE,eAAyB;IAClG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAA,sCAAe,EAAC,eAAe,CAAC,CAAC;QACjD,MAAM,mBAAmB,GAAG,IAAA,+CAAsB,EAAC,eAAe,CAAC,CAAC;QACpE,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,IAAA,8BAAe,EAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAC/E,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,8DAA8D,eAAe,sBAAsB,mBAAmB,YAAY,OAAO,EAAE,CAAC,CAAA;YAC1J,SAAS;QACb,CAAC;QAED,MAAM,gBAAgB,GAAG,OAAO,CAAC;QACjC,MAAM,iBAAiB,GAAG,IAAA,gDAA0B,EAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACxF,IAAA,0CAAqB,EAAC,iBAAiB,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;AACpG,CAAC;AAED,sKAAsK;AACtK,gDAAgD;AAChD,oEAAoE;AACpE,+HAA+H;AAC/H,MAAM","sourcesContent":["import { getAllCsFiles } from \"../batch/getFolderCodeFile\";\r\nimport { getBuiltDllPath } from \"../utils/getCodeStructurePath\";\r\nimport { getCodeCoverageSetting } from \"./getCodeCoverageSetting\";\r\nimport { runCodeCoverage } from \"./codeCoverage\";\r\nimport { runCodeCoverageReport } from \"./codeCoverageReport\";\r\nimport { simplifyCoverageXmlByFiles } from \"./simplifyCoverageXml\";\r\n\r\nexport async function generateCodeCoverageReport(testProjectPaths: string[], sourceCodePaths: string[]) {\r\n const startTime = Date.now();\r\n for (const testProjectPath of testProjectPaths){\r\n const dllPath = getBuiltDllPath(testProjectPath);\r\n const codeCoverageSetting = getCodeCoverageSetting(testProjectPath);\r\n const {success, message} = await runCodeCoverage(dllPath, codeCoverageSetting);\r\n if (!message.endsWith(\"xml\")) {\r\n console.error(`Generating code coverage report failed, test project path: ${testProjectPath}, coverageSetting: ${codeCoverageSetting}, error: ${message}`)\r\n continue;\r\n }\r\n\r\n const coberturaXmlPath = message;\r\n const simplifiedXmlPath = simplifyCoverageXmlByFiles(coberturaXmlPath, sourceCodePaths);\r\n runCodeCoverageReport(simplifiedXmlPath);\r\n }\r\n\r\n console.log(`code coverage report generation time: ${(Date.now() - startTime) / 1000} seconds`);\r\n}\r\n\r\n// const testProjectPaths = [\"C:\\\\Users\\\\jixiongge\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\"];\r\n// generateCodeCoverageReport(testProjectPaths);\r\n// getAllCsFiles(\"D:\\\\code\\\\AIUnitTestExample\\\\src\").then(paths => {\r\n// generateCodeCoverageReport([\"D:\\\\code\\\\AIUnitTestExample\\\\test\\\\ToListinator.Tests\\\\ToListinator.Tests.csproj\"], paths);\r\n// });"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCodeCoverageSetting(testProjectPath: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
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.getCodeCoverageSetting = getCodeCoverageSetting;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const getCodeStructurePath_1 = require("../utils/getCodeStructurePath");
|
|
40
|
+
function getCodeCoverageSetting(testProjectPath) {
|
|
41
|
+
let currentDir = path.dirname(testProjectPath);
|
|
42
|
+
const repoRoot = (0, getCodeStructurePath_1.getCodeRepoRoot)(testProjectPath);
|
|
43
|
+
while (currentDir !== repoRoot) {
|
|
44
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
if (!entry.isFile()) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (entry.name.toLowerCase().endsWith('.runsettings')) {
|
|
50
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
51
|
+
return fullPath;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
currentDir = path.dirname(currentDir);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=getCodeCoverageSetting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCodeCoverageSetting.js","sourceRoot":"","sources":["../../src/codeCoverage/getCodeCoverageSetting.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wDAqBC;AAzBD,uCAAyB;AACzB,2CAA6B;AAC7B,wEAAgE;AAEhE,SAAgB,sBAAsB,CAAC,eAAuB;IAC1D,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,IAAA,sCAAe,EAAC,eAAe,CAAC,CAAC;IAElD,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClB,SAAS;YACb,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBACnD,OAAO,QAAQ,CAAC;YACpB,CAAC;QACL,CAAC;QAED,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\nimport { getCodeRepoRoot } from '../utils/getCodeStructurePath';\r\n\r\nexport function getCodeCoverageSetting(testProjectPath: string) {\r\n let currentDir = path.dirname(testProjectPath);\r\n const repoRoot = getCodeRepoRoot(testProjectPath);\r\n\r\n while (currentDir !== repoRoot) {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n for (const entry of entries) {\r\n if (!entry.isFile()) {\r\n continue;\r\n }\r\n\r\n if (entry.name.toLowerCase().endsWith('.runsettings')) {\r\n const fullPath = path.join(currentDir, entry.name);\r\n return fullPath;\r\n }\r\n }\r\n\r\n currentDir = path.dirname(currentDir);\r\n }\r\n\r\n return null;\r\n}"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkTestReportToolInstall = checkTestReportToolInstall;
|
|
4
|
+
exports.installTestReportTool = installTestReportTool;
|
|
5
|
+
const constants_1 = require("../types/constants");
|
|
6
|
+
const runCommand_1 = require("../utils/runCommand");
|
|
7
|
+
const packageId = 'dotnet-reportgenerator-globaltool';
|
|
8
|
+
function checkTestReportToolInstall() {
|
|
9
|
+
const output = (0, runCommand_1.runCommand)('dotnet tool list --global');
|
|
10
|
+
const lines = output.split(constants_1.LINESEPARATOR).slice(2); // skip header lines
|
|
11
|
+
for (const line of lines) {
|
|
12
|
+
const parts = line.trim().split(/\s+/);
|
|
13
|
+
if (parts[0].toLowerCase() === packageId.toLowerCase()) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
function installTestReportTool() {
|
|
20
|
+
console.log(`${packageId} is not installed. Installing...`);
|
|
21
|
+
(0, runCommand_1.runCommand)(`dotnet tool install --global ${packageId}`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=reportTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportTool.js","sourceRoot":"","sources":["../../src/codeCoverage/reportTool.ts"],"names":[],"mappings":";;AAKA,gEAUC;AAED,sDAGC;AApBD,kDAAmD;AACnD,oDAAiD;AAEjD,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,SAAgB,0BAA0B;IACtC,MAAM,MAAM,GAAG,IAAA,uBAAU,EAAC,2BAA2B,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;IACxE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,qBAAqB;IACjC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,kCAAkC,CAAC,CAAC;IAC5D,IAAA,uBAAU,EAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { LINESEPARATOR } from '../types/constants';\r\nimport { runCommand } from '../utils/runCommand';\r\n\r\nconst packageId = 'dotnet-reportgenerator-globaltool';\r\n\r\nexport function checkTestReportToolInstall(): boolean {\r\n const output = runCommand('dotnet tool list --global');\r\n const lines = output.split(LINESEPARATOR).slice(2); // skip header lines\r\n for (const line of lines) {\r\n const parts = line.trim().split(/\\s+/);\r\n if (parts[0].toLowerCase() === packageId.toLowerCase()) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nexport function installTestReportTool() {\r\n console.log(`${packageId} is not installed. Installing...`);\r\n runCommand(`dotnet tool install --global ${packageId}`);\r\n}"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
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.removeZeroLineRateClassFromCoverageXml = removeZeroLineRateClassFromCoverageXml;
|
|
37
|
+
exports.simplifyCoverageXmlByFiles = simplifyCoverageXmlByFiles;
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
40
|
+
const fs_1 = require("fs");
|
|
41
|
+
function removeZeroLineRateClassFromCoverageXml(coverageXmlPath) {
|
|
42
|
+
const outputPath = coverageXmlPath.replace(/\.xml$/, '_refine.xml');
|
|
43
|
+
const xmlData = (0, fs_1.readFileSync)(coverageXmlPath, 'utf-8');
|
|
44
|
+
const parser = new fast_xml_parser_1.XMLParser({
|
|
45
|
+
ignoreAttributes: false,
|
|
46
|
+
attributeNamePrefix: '@_',
|
|
47
|
+
allowBooleanAttributes: true,
|
|
48
|
+
ignoreDeclaration: false
|
|
49
|
+
});
|
|
50
|
+
const json = parser.parse(xmlData);
|
|
51
|
+
const packages = json.coverage.packages.package;
|
|
52
|
+
const packagesArr = Array.isArray(packages) ? packages : [packages];
|
|
53
|
+
const refinedPackages = packagesArr
|
|
54
|
+
.map((pkg) => {
|
|
55
|
+
const filteredClasses = filterClasses(pkg.classes);
|
|
56
|
+
if (!filteredClasses)
|
|
57
|
+
return null;
|
|
58
|
+
return {
|
|
59
|
+
...pkg,
|
|
60
|
+
classes: filteredClasses
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
.filter(pkg => pkg !== null);
|
|
64
|
+
json.coverage.packages.package = refinedPackages;
|
|
65
|
+
const builder = new fast_xml_parser_1.XMLBuilder({
|
|
66
|
+
ignoreAttributes: false,
|
|
67
|
+
attributeNamePrefix: '@_',
|
|
68
|
+
format: true,
|
|
69
|
+
suppressEmptyNode: true
|
|
70
|
+
});
|
|
71
|
+
const outputXml = builder.build(json);
|
|
72
|
+
(0, fs_1.writeFileSync)(outputPath, outputXml, 'utf-8');
|
|
73
|
+
console.log(`generated Completed Path: ${outputPath}`);
|
|
74
|
+
}
|
|
75
|
+
function filterClasses(classesObj) {
|
|
76
|
+
const classes = Array.isArray(classesObj.class)
|
|
77
|
+
? classesObj.class
|
|
78
|
+
: [classesObj.class];
|
|
79
|
+
const filtered = classes.filter((cls) => parseFloat(cls['@_line-rate']) > 0);
|
|
80
|
+
return filtered.length > 0 ? { class: filtered } : null;
|
|
81
|
+
}
|
|
82
|
+
function simplifyCoverageXmlByFiles(coverageXmlPath, filePaths) {
|
|
83
|
+
if (!coverageXmlPath || !filePaths || filePaths.length === 0) {
|
|
84
|
+
console.error(`invalid parameters: coverageXmlPath and filePaths must be provided, coverageXmlPath: ${coverageXmlPath}, filePaths: ${filePaths}`);
|
|
85
|
+
return coverageXmlPath;
|
|
86
|
+
}
|
|
87
|
+
const parser = new fast_xml_parser_1.XMLParser({ ignoreAttributes: false });
|
|
88
|
+
const builder = new fast_xml_parser_1.XMLBuilder({ ignoreAttributes: false, format: true });
|
|
89
|
+
const xmlRaw = (0, fs_1.readFileSync)(coverageXmlPath, 'utf-8');
|
|
90
|
+
const xmlObj = parser.parse(xmlRaw);
|
|
91
|
+
// Cobertura root: <coverage><packages><package><classes><class>...
|
|
92
|
+
const packages = xmlObj.coverage?.packages?.package ?? [];
|
|
93
|
+
const normalizedCsFilePaths = filePaths.map(file => path.normalize(file));
|
|
94
|
+
for (const pkg of Array.isArray(packages) ? packages : [packages]) {
|
|
95
|
+
const classes = pkg.classes?.class;
|
|
96
|
+
if (!classes)
|
|
97
|
+
continue;
|
|
98
|
+
const filtered = (Array.isArray(classes) ? classes : [classes]).filter(cls => {
|
|
99
|
+
const filename = path.normalize(cls['@_filename'] || '');
|
|
100
|
+
return normalizedCsFilePaths.includes(filename);
|
|
101
|
+
});
|
|
102
|
+
pkg.classes.class = filtered;
|
|
103
|
+
}
|
|
104
|
+
const refinedXml = builder.build(xmlObj);
|
|
105
|
+
const outPath = coverageXmlPath.replace(/\.xml$/, '_simplified.xml');
|
|
106
|
+
(0, fs_1.writeFileSync)(outPath, refinedXml, 'utf-8');
|
|
107
|
+
console.log(`Refined coverage written to: ${outPath}`);
|
|
108
|
+
return outPath;
|
|
109
|
+
}
|
|
110
|
+
// removeZeroLineRateClassFromCoverageXml("D:\\atmp\\TestResults\\744711fc-6729-4298-bc08-31ba5ca088f1\\jixiongge_CPC-jixio-Z5J9N_2025-07-14.18_26_28.cobertura.xml");
|
|
111
|
+
// const filePaths = [
|
|
112
|
+
// "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\Conditions\\EplantRequestCategoryCondition.cs",
|
|
113
|
+
// "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\Conditions\\EplantRequestTypeCondition.cs",
|
|
114
|
+
// "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\Conditions\\EplantUserUpdateCondition.cs"
|
|
115
|
+
// ];
|
|
116
|
+
// simplifyCoverageXmlByFiles("D:\\atmp\\TestResults\\744711fc-6729-4298-bc08-31ba5ca088f1\\jixiongge_CPC-jixio-Z5J9N_2025-07-14.18_26_28.cobertura.xml", filePaths);
|
|
117
|
+
//# sourceMappingURL=simplifyCoverageXml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplifyCoverageXml.js","sourceRoot":"","sources":["../../src/codeCoverage/simplifyCoverageXml.ts"],"names":[],"mappings":"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","sourcesContent":["import * as path from 'path';\r\n\r\nimport { XMLBuilder, XMLParser } from 'fast-xml-parser';\r\nimport { readFileSync, writeFileSync } from 'fs';\r\n\r\nexport function removeZeroLineRateClassFromCoverageXml(coverageXmlPath: string) {\r\n const outputPath = coverageXmlPath.replace(/\\.xml$/, '_refine.xml');\r\n const xmlData = readFileSync(coverageXmlPath, 'utf-8');\r\n const parser = new XMLParser({\r\n ignoreAttributes: false,\r\n attributeNamePrefix: '@_',\r\n allowBooleanAttributes: true,\r\n ignoreDeclaration: false\r\n });\r\n const json = parser.parse(xmlData);\r\n\r\n const packages = json.coverage.packages.package;\r\n const packagesArr = Array.isArray(packages) ? packages : [packages];\r\n\r\n const refinedPackages = packagesArr\r\n .map((pkg: any) => {\r\n const filteredClasses = filterClasses(pkg.classes);\r\n if (!filteredClasses) return null;\r\n\r\n return {\r\n ...pkg,\r\n classes: filteredClasses\r\n };\r\n })\r\n .filter(pkg => pkg !== null);\r\n\r\n json.coverage.packages.package = refinedPackages;\r\n\r\n const builder = new XMLBuilder({\r\n ignoreAttributes: false,\r\n attributeNamePrefix: '@_',\r\n format: true,\r\n suppressEmptyNode: true\r\n });\r\n\r\n const outputXml = builder.build(json);\r\n writeFileSync(outputPath, outputXml, 'utf-8');\r\n\r\n console.log(`generated Completed Path: ${outputPath}`);\r\n}\r\n\r\nfunction filterClasses(classesObj: any) {\r\n const classes = Array.isArray(classesObj.class)\r\n ? classesObj.class\r\n : [classesObj.class];\r\n\r\n const filtered = classes.filter((cls: any) => parseFloat(cls['@_line-rate']) > 0);\r\n return filtered.length > 0 ? { class: filtered } : null;\r\n}\r\n\r\nexport function simplifyCoverageXmlByFiles(coverageXmlPath: string, filePaths: string[]) {\r\n if (!coverageXmlPath || !filePaths || filePaths.length === 0) {\r\n console.error(`invalid parameters: coverageXmlPath and filePaths must be provided, coverageXmlPath: ${coverageXmlPath}, filePaths: ${filePaths}`);\r\n return coverageXmlPath;\r\n }\r\n\r\n const parser = new XMLParser({ ignoreAttributes: false });\r\n const builder = new XMLBuilder({ ignoreAttributes: false, format: true });\r\n\r\n const xmlRaw = readFileSync(coverageXmlPath, 'utf-8');\r\n const xmlObj = parser.parse(xmlRaw);\r\n\r\n // Cobertura root: <coverage><packages><package><classes><class>...\r\n const packages = xmlObj.coverage?.packages?.package ?? [];\r\n\r\n const normalizedCsFilePaths = filePaths.map(file => path.normalize(file));\r\n for (const pkg of Array.isArray(packages) ? packages : [packages]) {\r\n const classes = pkg.classes?.class;\r\n if (!classes) continue;\r\n\r\n const filtered = (Array.isArray(classes) ? classes : [classes]).filter(cls => {\r\n const filename = path.normalize(cls['@_filename'] || '');\r\n return normalizedCsFilePaths.includes(filename);\r\n });\r\n\r\n pkg.classes.class = filtered;\r\n }\r\n\r\n const refinedXml = builder.build(xmlObj);\r\n const outPath = coverageXmlPath.replace(/\\.xml$/, '_simplified.xml');\r\n writeFileSync(outPath, refinedXml, 'utf-8');\r\n\r\n console.log(`Refined coverage written to: ${outPath}`);\r\n return outPath;\r\n}\r\n\r\n\r\n// removeZeroLineRateClassFromCoverageXml(\"D:\\\\atmp\\\\TestResults\\\\744711fc-6729-4298-bc08-31ba5ca088f1\\\\jixiongge_CPC-jixio-Z5J9N_2025-07-14.18_26_28.cobertura.xml\");\r\n\r\n// const filePaths = [\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\\\\Conditions\\\\EplantUserUpdateCondition.cs\"\r\n// ];\r\n\r\n// simplifyCoverageXmlByFiles(\"D:\\\\atmp\\\\TestResults\\\\744711fc-6729-4298-bc08-31ba5ca088f1\\\\jixiongge_CPC-jixio-Z5J9N_2025-07-14.18_26_28.cobertura.xml\", filePaths);"]}
|
|
@@ -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,18 @@
|
|
|
1
|
+
# General Unit Test Guidelines (For All C# Code)
|
|
2
|
+
- MUST use {{testFramework}} test framework to generate test code.
|
|
3
|
+
- **MUST NOT** contain any comments or explanations in test code.
|
|
4
|
+
- Ensure the test code MUST has no syntax errors.
|
|
5
|
+
- Test public methods of class in source code only.
|
|
6
|
+
- **MUST NOT** access private members (fields or methods) of the source class in test code.
|
|
7
|
+
- Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].
|
|
8
|
+
- Return the test code in the format: ```C#\n{Test code}\n```.
|
|
9
|
+
- Mock all dependent methods, classes, and values not included in the user input using the Moq library.
|
|
10
|
+
- MUST include Test code in a namespace declaration and place all `using` statements above the namespace declaration.
|
|
11
|
+
- MUST import source code in the test code.
|
|
12
|
+
- MUST import all required .Net namespaces if any .Net class or interface are used in the test code. Like:
|
|
13
|
+
- .NET built-in types (e.g., `List<T>`, `IEnumerable<T>`, `Task`, `Assert`, `Moq.Mock`, etc.).
|
|
14
|
+
- Any attribute classes (e.g., `[TestMethod]`, `[TestClass]`, etc.).
|
|
15
|
+
- Any LINQ or threading related classes (e.g., `System.Linq`, `System.Threading.Tasks`).
|
|
16
|
+
- **MUST NOT** assign null to var type value, like: var request = null, it's forbidden.
|
|
17
|
+
- All assignments and method arguments in test code MUST strictly match the declared types.
|
|
18
|
+
- **MUST NOT** pass a single object to a collection type, like **MUST NOT** pass **SampleObject** type to **IEnumerable<SampleObject>** type.
|
|
@@ -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 -%}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{%- if isXapTest -%}
|
|
2
|
+
{%- assign xapSuffix = " that is using the XAP framework" -%}
|
|
3
|
+
{%- else -%}
|
|
4
|
+
{%- assign xapSuffix = "" -%}
|
|
5
|
+
{%- endif -%}
|
|
6
|
+
|
|
7
|
+
You are a **highly skilled software engineer specializing in C# unit testing** and tasked with writing **unit tests** for the user-provided C# source code{{xapSuffix}}. Strictly obey the following guidelines.
|
|
8
|
+
|
|
9
|
+
{% if isXapTest %}
|
|
10
|
+
{% include 'xap/xapUtGuideline' %}
|
|
11
|
+
{%- endif -%}
|
|
12
|
+
|
|
13
|
+
{% include 'general/generalUtGuidelines' %}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Keep your answers short and impersonal.
|
|
2
|
+
Use Markdown formatting in your answers.
|
|
3
|
+
Make sure to include the programming language name at the start of the Markdown code blocks.
|
|
4
|
+
Avoid wrapping the whole response in triple backticks.
|
|
5
|
+
You can only give one reply for each conversation turn.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Before generating the unit test:
|
|
2
|
+
- **MUST** analyze the provided code and verify its logic by following these steps:
|
|
3
|
+
1. Describe the functionality of each public method, including its inputs, outputs, and key logic.
|
|
4
|
+
2. Identify all possible execution paths for public methods, including normal cases, edge cases, and error conditions.
|
|
5
|
+
3. Explain any conditional branches, loops, or exception handling for public methods in the code.
|
|
6
|
+
4. Based on this analysis, generate unit test cases that cover all identified execution paths, ensuring that mock data and assertions align with the code's logic.
|
|
7
|
+
- **MUST** remove all code analysis information in responsed test code.
|
|
8
|
+
- Absolutely forbidden to contains any other information in response except the test code.
|
|
9
|
+
- **MUST NOT** generate tests for the methods that are attributed with **[ExcludeFromCodeCoverage]**.
|
|
10
|
+
- **MUST NOT** generate tests for **private** methods.
|
|
11
|
+
|
|
12
|
+
Please generate C# unit tests using the following information:
|
|
13
|
+
|
|
14
|
+
# Target Namespace for the Unit Test Code
|
|
15
|
+
{{ namespace }}
|
|
16
|
+
|
|
17
|
+
# Source Code to generate tests
|
|
18
|
+
The following code defines the class and method(s) that need to be unit tested:
|
|
19
|
+
```C#
|
|
20
|
+
{{ sourceCode }}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
{% if dependency != "" %}
|
|
24
|
+
# Dependency Definitions
|
|
25
|
+
Any dependencies (e.g., types, classes, or interfaces) referenced in the source code above are defined here. Use these definitions to resolve any types or dependencies required for the unit tests.
|
|
26
|
+
{{ dependency }}
|
|
27
|
+
{% endif %}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Build Failure Fix Guideline:
|
|
2
|
+
- Case1: 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
|
+
- Case2: 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.] Adjust the method parameters to match the correct overload as per the source code.
|
|
6
|
+
- Case3
|
|
@@ -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}
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
## Xap source code and test code examples
|
|
2
|
+
D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Plugins\Workflows\Eplant\HttpRequestParser\EplantHttpRequestParser.cs
|
|
3
|
+
Example #1 ()
|
|
4
|
+
```C#
|
|
5
|
+
public class SampleBuilder : IPlugin
|
|
6
|
+
{
|
|
7
|
+
public PluginResult Execute(
|
|
8
|
+
PluginServices pluginServices,
|
|
9
|
+
PluginOutput<EplantUserResp> eplantUserResp,
|
|
10
|
+
[ConfigFile("EplantConfig.ini")]
|
|
11
|
+
EplantConfig eplantConfig,
|
|
12
|
+
IEnumerable<ObjectStoreResponse_2<EplantUserKey, EMPTY, EMPTY, EplantUser>> osResponses = null,
|
|
13
|
+
EplantRequest req = null)
|
|
14
|
+
{
|
|
15
|
+
..... // omit detail implementation
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Test Code snippet:
|
|
21
|
+
```C#
|
|
22
|
+
[TestClass]
|
|
23
|
+
public class SampleBuilderTest
|
|
24
|
+
{
|
|
25
|
+
[TestMethod]
|
|
26
|
+
public void Execute_InvalidRequestOrIntent_Failure()
|
|
27
|
+
{
|
|
28
|
+
var builder = ExecutionServices.CreateInstance<ISampleBuilder>();
|
|
29
|
+
request.type = EplantReqType.Me;
|
|
30
|
+
IEnumerable<ObjectStoreResponse_2<EplantUserKey, EMPTY, EMPTY, EplantUser>> osResponses = null;
|
|
31
|
+
|
|
32
|
+
var result = builder.Execute(Task.FromResult(osResponses), Task.FromResult(request)).Result;
|
|
33
|
+
|
|
34
|
+
Assert.IsFalse(result.Success);
|
|
35
|
+
Assert.IsNull(builder.eplantUserResp.Result);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|