@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,36 @@
|
|
|
1
|
+
# Xap Unit Test Guidelines (**ONLY apply when the source code is a Xap class. Ignore all these rules for non-Xap classes.**):
|
|
2
|
+
- Xap class is a class that inherits one of these interfaces: IPlugin, IConditionPlugin, Workflow, IExperiment, IPluginDataStore, IAsyncPlugin and implements an Execute() method.
|
|
3
|
+
- MUST use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance, where the interface name is the class name prefixed with "I".
|
|
4
|
+
Example: For Xap class SampleWorkflow, create instance MUST be like: **var sampleWorkflow = ExecutionServices.CreateInstance<ISampleWorkflow>();**
|
|
5
|
+
- The parameters of **Execute** method with types: **PluginServices**, **PluginOutput<T>**, or attributed with **[ConfigFile("{configFileName}")]** MUST be deleted when using Xap class instance to call the Execute method.
|
|
6
|
+
- Xap freamwork will take care these deleted parameters, NEVER try to mock or create these deleted types, it's invalid and forbidden.
|
|
7
|
+
- **MUST NOT** mock these deleted types' object, even if its methods or properties are used in the source code.
|
|
8
|
+
- For Remaining parameters,
|
|
9
|
+
- MUST pass in exact type as declared in source code.
|
|
10
|
+
- MUST keep original parameter order.
|
|
11
|
+
- MUST wrap each parameter with Task.FromResult(value).
|
|
12
|
+
Example:
|
|
13
|
+
The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
|
|
14
|
+
Base on above declared deleted types, **MUST delete** these three parameters: PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig,
|
|
15
|
+
call the Execute using Xap class instance MUST be like: **var pluginResult = sampleWorkflow.Execute(Task.FromResult(osResp), Task.FromResult(req)).Result;**
|
|
16
|
+
- The Execute method parameters with type PluginOutput<T> MUST be treated as method output, **T** is the type output value.
|
|
17
|
+
- MUST using the parameter name to access the output by the Xap instance
|
|
18
|
+
- MUST using **Result** property to access the output of type **T** in **PluginOutput<T>**.
|
|
19
|
+
- MUST assert PluginOutput<T> parameters' values if there's parameter with **PluginOutput<T>** type.
|
|
20
|
+
Example:
|
|
21
|
+
The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
|
|
22
|
+
Get the output value using Xap class instance MUST be like: **sampleWorkflow.resp**.
|
|
23
|
+
Assume there's one field named **Key** in **Resp** type, get **Key** MUST be like: **sampleWorkflow.pluginResp.Result.Key**.
|
|
24
|
+
Assert the PluginOutput<T> value in test code MUST be like: Assert.NotNull(sampleWorkflow.pluginResult.Result.Id); Assert.AreEqual(sampleWorkflow.pluginResult.Result.Id, "id");
|
|
25
|
+
- The Bond structures MUST be treated as regular C# class in test code:
|
|
26
|
+
- **MUST** import **Bond namespace** before using the Bond structure in test code
|
|
27
|
+
Example: The namespace in bond structure is like: **namespace SharedSegments.Weather.OneService**, to use this bond structure, **MUST** add: **using SharedSegments.Weather.OneService** in test code.
|
|
28
|
+
- MUST use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instances.
|
|
29
|
+
Example: For a Bond structure named **SampleBondStructure<T>**, create bond instance **MUST** be like: ** var subResponse = ExecutionServices.CreateInstance<SampleBondStructure<SampleObject>>();
|
|
30
|
+
- MUST not access the fields that are not defined in bond structure, it's invalid and forbidden.
|
|
31
|
+
- MUST treated the fields as **required** if they **are not** decorated with **optional** in bond structure
|
|
32
|
+
- **MUST** assign a valid, non-null value to **required field** that are **NOT decorated** with **optional** explicitly.
|
|
33
|
+
- MUST assign a valid value to the fields that are used in source code explicitly.
|
|
34
|
+
- MUST correctly handle the null checks for required fields in source code.
|
|
35
|
+
Example: the source code contains **if (sampleRequest?.Category == null)**, the **Category** is require field in sampleRequest bond structure and **MUST be non-null**, just test the case when sampleRequest is null.
|
|
36
|
+
- MUST use AsEnumerable() to convert IList to IEnumerable, e.g. IEnumerable osResponses = osResponseList.AsEnumerable()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Xap Unit Test Guidelines (**ONLY apply when the source code is a Xap class. Ignore all these rules for non-Xap classes.**):
|
|
2
|
+
- Xap class is a class that inherits one of these interfaces: IPlugin, IConditionPlugin, Workflow, IExperiment, IPluginDataStore, IAsyncPlugin and implements an Execute() method.
|
|
3
|
+
- MUST use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance, where the interface name is the class name prefixed with "I".
|
|
4
|
+
Example: For Xap class SampleWorkflow, create instance MUST be like: **var sampleWorkflow = ExecutionServices.CreateInstance<ISampleWorkflow>();**
|
|
5
|
+
- The parameters of **Execute** method with types: **PluginServices**, **PluginOutput<T>**, or attributed with **[ConfigFile("{configFileName}")]** MUST be deleted when using Xap class instance to call the Execute method.
|
|
6
|
+
- Xap freamwork will take care these deleted parameters, NEVER try to mock or create these deleted types, it's invalid and forbidden.
|
|
7
|
+
- **MUST NOT** mock these deleted types' object, even if its methods or properties are used in the source code.
|
|
8
|
+
- For Remaining parameters,
|
|
9
|
+
- MUST pass in exact type as declared in source code.
|
|
10
|
+
- MUST keep original parameter order.
|
|
11
|
+
- MUST wrap each parameter with Task.FromResult(value).
|
|
12
|
+
Example:
|
|
13
|
+
The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
|
|
14
|
+
Base on above declared deleted types, **MUST delete** these three parameters: PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig,
|
|
15
|
+
call the Execute using Xap class instance MUST be like: **var pluginResult = sampleWorkflow.Execute(Task.FromResult(osResp), Task.FromResult(req)).Result;**
|
|
16
|
+
- The Execute method parameters with type PluginOutput<T> MUST be treated as method output, **T** is the type output value.
|
|
17
|
+
- MUST using the parameter name to access the output by the Xap instance
|
|
18
|
+
- MUST using **Result** property to access the output of type **T** in **PluginOutput<T>**.
|
|
19
|
+
- MUST assert PluginOutput<T> parameters' values if there's parameter with **PluginOutput<T>** type.
|
|
20
|
+
Example:
|
|
21
|
+
The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
|
|
22
|
+
Get the output value using Xap class instance MUST be like: **sampleWorkflow.resp**.
|
|
23
|
+
Assume there's one field named **Key** in **Resp** type, get **Key** MUST be like: **sampleWorkflow.pluginResp.Result.Key**.
|
|
24
|
+
Assert the PluginOutput<T> value in test code MUST be like: Assert.NotNull(sampleWorkflow.pluginResult.Result.Id); Assert.AreEqual(sampleWorkflow.pluginResult.Result.Id, "id");
|
|
25
|
+
- The Bond structures MUST be treated as regular C# class in test code:
|
|
26
|
+
- **MUST** import **Bond namespace** before using the Bond structure in test code
|
|
27
|
+
Example: The namespace in bond structure is like: **namespace SharedSegments.Weather.OneService**, to use this bond structure, **MUST** add: **using SharedSegments.Weather.OneService** in test code.
|
|
28
|
+
- MUST use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instances.
|
|
29
|
+
Example: For a Bond structure named **SampleBondStructure<T>**, create bond instance **MUST** be like: ** var subResponse = ExecutionServices.CreateInstance<SampleBondStructure<SampleObject>>();
|
|
30
|
+
- MUST not access the fields that are not defined in bond structure, it's invalid and forbidden.
|
|
31
|
+
- MUST treated the fields as **required** if they **are not** decorated with **optional** in bond structure
|
|
32
|
+
- **MUST** assign a valid, non-null value to **required field** that are **NOT decorated** with **optional** explicitly.
|
|
33
|
+
- MUST assign a valid value to the fields that are used in source code explicitly.
|
|
34
|
+
- MUST correctly handle the null checks for required fields in source code.
|
|
35
|
+
Example: the source code contains **if (sampleRequest?.Category == null)**, the **Category** is require field in sampleRequest bond structure and **MUST be non-null**, just test the case when sampleRequest is null.
|
|
36
|
+
- MUST use AsEnumerable() to convert IList to IEnumerable, e.g. IEnumerable osResponses = osResponseList.AsEnumerable()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { exec } from "child_process";
|
|
3
|
+
// import treeKill from "tree-kill";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// export const childProcessSet = new Set<number>();
|
|
6
|
+
// function isProcessAlive(pid: number): boolean {
|
|
7
|
+
// try {
|
|
8
|
+
// process.kill(pid, 0);
|
|
9
|
+
// return true;
|
|
10
|
+
// } catch {
|
|
11
|
+
// return false;
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
14
|
+
// function killPidAsync(pid: number): Promise<void> {
|
|
15
|
+
// return new Promise(async (resolve) => {
|
|
16
|
+
// if (!isProcessAlive(pid)) {
|
|
17
|
+
// console.log(`PID ${pid} already exited`);
|
|
18
|
+
// return resolve();
|
|
19
|
+
// }
|
|
20
|
+
// console.log(`Killing child process with PID: ${pid}`);
|
|
21
|
+
// treeKill(pid, "SIGKILL", (err) => {
|
|
22
|
+
// if (err) {
|
|
23
|
+
// console.error(`Failed to kill pid=${pid}:`, err.message);
|
|
24
|
+
// } else {
|
|
25
|
+
// console.log(`Killed pid=${pid}`);
|
|
26
|
+
// }
|
|
27
|
+
// resolve();
|
|
28
|
+
// });
|
|
29
|
+
// });
|
|
30
|
+
// }
|
|
31
|
+
// export async function killAllChildProcesses(): Promise<void> {
|
|
32
|
+
// const pids = Array.from(childProcessSet);
|
|
33
|
+
// console.log('Killing all child processes: ' + pids.join(', '));
|
|
34
|
+
// await Promise.all(pids.map((pid) => killPidAsync(pid)));
|
|
35
|
+
// console.log('All child processes have been killed.');
|
|
36
|
+
// childProcessSet.clear();
|
|
37
|
+
// }
|
|
38
|
+
// async function killVBCSCompiler() {
|
|
39
|
+
// try {
|
|
40
|
+
// exec('taskkill /IM VBCSCompiler.exe /F');
|
|
41
|
+
// console.log('Successfully terminated all VBCSCompiler.exe processes');
|
|
42
|
+
// } catch (err) {
|
|
43
|
+
// if (err.message.includes('not found')) {
|
|
44
|
+
// console.log('No VBCSCompiler.exe processes found');
|
|
45
|
+
// } else {
|
|
46
|
+
// console.error(`Failed to terminate VBCSCompiler.exe: ${err.message}`);
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
// }
|
|
50
|
+
//# sourceMappingURL=childProcessManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childProcessManager.js","sourceRoot":"","sources":["../../src/codebk/childProcessManager.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,oCAAoC;;AAEpC,oDAAoD;AAEpD,kDAAkD;AAClD,YAAY;AACZ,gCAAgC;AAChC,uBAAuB;AACvB,gBAAgB;AAChB,wBAAwB;AACxB,QAAQ;AACR,IAAI;AAEJ,sDAAsD;AACtD,8CAA8C;AAC9C,sCAAsC;AACtC,wDAAwD;AACxD,gCAAgC;AAChC,YAAY;AAEZ,iEAAiE;AACjE,8CAA8C;AAC9C,yBAAyB;AACzB,4EAA4E;AAC5E,uBAAuB;AACvB,oDAAoD;AACpD,gBAAgB;AAChB,yBAAyB;AACzB,cAAc;AACd,UAAU;AACV,IAAI;AAEJ,iEAAiE;AACjE,gDAAgD;AAChD,sEAAsE;AACtE,+DAA+D;AAC/D,4DAA4D;AAC5D,+BAA+B;AAC/B,IAAI;AAGJ,sCAAsC;AACtC,YAAY;AACZ,oDAAoD;AACpD,iFAAiF;AACjF,sBAAsB;AACtB,mDAAmD;AACnD,kEAAkE;AAClE,mBAAmB;AACnB,qFAAqF;AACrF,YAAY;AACZ,QAAQ;AACR,IAAI","sourcesContent":["// import { exec } from \"child_process\";\r\n// import treeKill from \"tree-kill\";\r\n\r\n// export const childProcessSet = new Set<number>();\r\n\r\n// function isProcessAlive(pid: number): boolean {\r\n// try {\r\n// process.kill(pid, 0);\r\n// return true;\r\n// } catch {\r\n// return false;\r\n// }\r\n// }\r\n\r\n// function killPidAsync(pid: number): Promise<void> {\r\n// return new Promise(async (resolve) => {\r\n// if (!isProcessAlive(pid)) {\r\n// console.log(`PID ${pid} already exited`);\r\n// return resolve();\r\n// }\r\n \r\n// console.log(`Killing child process with PID: ${pid}`);\r\n// treeKill(pid, \"SIGKILL\", (err) => {\r\n// if (err) {\r\n// console.error(`Failed to kill pid=${pid}:`, err.message);\r\n// } else {\r\n// console.log(`Killed pid=${pid}`);\r\n// }\r\n// resolve();\r\n// });\r\n// });\r\n// }\r\n\r\n// export async function killAllChildProcesses(): Promise<void> {\r\n// const pids = Array.from(childProcessSet);\r\n// console.log('Killing all child processes: ' + pids.join(', '));\r\n// await Promise.all(pids.map((pid) => killPidAsync(pid)));\r\n// console.log('All child processes have been killed.');\r\n// childProcessSet.clear();\r\n// }\r\n\r\n\r\n// async function killVBCSCompiler() {\r\n// try {\r\n// exec('taskkill /IM VBCSCompiler.exe /F');\r\n// console.log('Successfully terminated all VBCSCompiler.exe processes');\r\n// } catch (err) {\r\n// if (err.message.includes('not found')) {\r\n// console.log('No VBCSCompiler.exe processes found');\r\n// } else {\r\n// console.error(`Failed to terminate VBCSCompiler.exe: ${err.message}`);\r\n// }\r\n// }\r\n// }"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
function runMsBuild() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const vsDevCmdPath = `"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"`;
|
|
7
|
+
// const solutionPath = path.resolve(__dirname, 'YourProject.sln'); // 或 .csproj 文件
|
|
8
|
+
const projectPath = "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj";
|
|
9
|
+
const msbuildCommand = `MSBuild "${projectPath}" /p:Configuration=debug`;
|
|
10
|
+
// 使用 cmd /c call 确保环境变量被正确加载
|
|
11
|
+
const child = (0, child_process_1.spawn)('cmd.exe', [
|
|
12
|
+
'/c',
|
|
13
|
+
`call ${vsDevCmdPath} && ${msbuildCommand}`
|
|
14
|
+
], {
|
|
15
|
+
cwd: __dirname,
|
|
16
|
+
shell: true,
|
|
17
|
+
stdio: ['ignore', 'pipe', 'pipe'], // pipe:允许收集日志
|
|
18
|
+
});
|
|
19
|
+
// 缓冲日志,适配大体积输出
|
|
20
|
+
let stdout = '';
|
|
21
|
+
let stderr = '';
|
|
22
|
+
child.stdout.on('data', (chunk) => {
|
|
23
|
+
stdout += chunk.toString();
|
|
24
|
+
});
|
|
25
|
+
child.stderr.on('data', (chunk) => {
|
|
26
|
+
stderr += chunk.toString();
|
|
27
|
+
});
|
|
28
|
+
child.on('error', (err) => {
|
|
29
|
+
reject(err);
|
|
30
|
+
});
|
|
31
|
+
child.on('close', (code) => {
|
|
32
|
+
resolve({ stdout, stderr, code });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function testMsBuild() {
|
|
37
|
+
try {
|
|
38
|
+
const { stdout, stderr, code } = await runMsBuild();
|
|
39
|
+
console.log('===== 构建完成,准备分析输出 =====');
|
|
40
|
+
if (code === 0) {
|
|
41
|
+
console.log('✅ 构建成功');
|
|
42
|
+
if (stdout.includes('Build succeeded')) {
|
|
43
|
+
console.log('🎯 日志中确认构建成功');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.error(`❌ 构建失败,退出码: ${code}`);
|
|
48
|
+
console.error(stderr.slice(0, 1000)); // 如日志过大,可限制显示前几百字
|
|
49
|
+
}
|
|
50
|
+
// 你可以把 stdout 写入文件做后续分析
|
|
51
|
+
// fs.writeFileSync('build.log', stdout);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.error('命令执行异常:', err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// testMsBuild();
|
|
58
|
+
//# sourceMappingURL=msBuidSpawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msBuidSpawn.js","sourceRoot":"","sources":["../../src/codebk/msBuidSpawn.ts"],"names":[],"mappings":";;AAAA,iDAAsC;AAQtC,SAAS,UAAU;IACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,YAAY,GAAG,8FAA8F,CAAC;QAExH,qFAAqF;QACnF,MAAM,WAAW,GAAG,qHAAqH,CAAC;QAC1I,MAAM,cAAc,GAAG,YAAY,WAAW,0BAA0B,CAAC;QAEvE,6BAA6B;QAC7B,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,SAAS,EAAE;YAC7B,IAAI;YACJ,QAAQ,YAAY,OAAO,cAAc,EAAE;SAC5C,EAAE;YACD,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;SAClD,CAAC,CAAC;QAEH,eAAe;QACf,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QAEvC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,IAAI,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;YACrC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB;QAC1D,CAAC;QAED,wBAAwB;QACxB,yCAAyC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,iBAAiB","sourcesContent":["import { spawn } from 'child_process';\r\n\r\ninterface CommandResult {\r\n stdout: string;\r\n stderr: string;\r\n code: number | null;\r\n}\r\n\r\nfunction runMsBuild(): Promise<CommandResult> {\r\n return new Promise((resolve, reject) => {\r\n const vsDevCmdPath = `\"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Enterprise\\\\Common7\\\\Tools\\\\VsDevCmd.bat\"`;\r\n\r\n// const solutionPath = path.resolve(__dirname, 'YourProject.sln'); // 或 .csproj 文件\r\n const projectPath = \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\";\r\n const msbuildCommand = `MSBuild \"${projectPath}\" /p:Configuration=debug`;\r\n\r\n // 使用 cmd /c call 确保环境变量被正确加载\r\n const child = spawn('cmd.exe', [\r\n '/c',\r\n `call ${vsDevCmdPath} && ${msbuildCommand}`\r\n ], {\r\n cwd: __dirname,\r\n shell: true,\r\n stdio: ['ignore', 'pipe', 'pipe'], // pipe:允许收集日志\r\n });\r\n\r\n // 缓冲日志,适配大体积输出\r\n let stdout = '';\r\n let stderr = '';\r\n\r\n child.stdout.on('data', (chunk: Buffer) => {\r\n stdout += chunk.toString();\r\n });\r\n\r\n child.stderr.on('data', (chunk: Buffer) => {\r\n stderr += chunk.toString();\r\n });\r\n\r\n child.on('error', (err) => {\r\n reject(err);\r\n });\r\n\r\n child.on('close', (code) => {\r\n resolve({ stdout, stderr, code });\r\n });\r\n });\r\n}\r\n\r\nasync function testMsBuild() {\r\n try {\r\n const { stdout, stderr, code } = await runMsBuild();\r\n\r\n console.log('===== 构建完成,准备分析输出 =====');\r\n\r\n if (code === 0) {\r\n console.log('✅ 构建成功');\r\n if (stdout.includes('Build succeeded')) {\r\n console.log('🎯 日志中确认构建成功');\r\n }\r\n } else {\r\n console.error(`❌ 构建失败,退出码: ${code}`);\r\n console.error(stderr.slice(0, 1000)); // 如日志过大,可限制显示前几百字\r\n }\r\n\r\n // 你可以把 stdout 写入文件做后续分析\r\n // fs.writeFileSync('build.log', stdout);\r\n } catch (err) {\r\n console.error('命令执行异常:', err);\r\n }\r\n}\r\n\r\n// testMsBuild();"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as path from 'path';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
// import { exec, spawn } from 'child_process';
|
|
5
|
+
// import { formatMsbuildResultToMarkdown, parseMsbuildErrors } from '../utils/parseBuildResult';
|
|
6
|
+
// import { msBuildPath } from './vsTools';
|
|
7
|
+
// // import { vsDevCmdPath } from './vsTools';
|
|
8
|
+
// export function runMsBuild(projectPath: string): Promise<any> {
|
|
9
|
+
// return new Promise((resolve) => {
|
|
10
|
+
// // in vsdevcmd env, MSBuild.exe is available
|
|
11
|
+
// const msbuildCommand = `"${msBuildPath}" "${projectPath}" /t:Build /m /nr:true /v:minimal`; // /p:Configuration=debug`;
|
|
12
|
+
// // const msbuildCommand = `"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe" "${projectPath}" /t:Build /m /nr:true /v:minimal`; // /p:Configuration=debug`;
|
|
13
|
+
// // const fullCommand = `cmd /c "call "${vsDevCmdPath}" && ${msbuildCommand}"`;
|
|
14
|
+
// const workDir = path.join(__dirname, '../tools');
|
|
15
|
+
// console.log(`📦 Running MSBuild... \n ${msbuildCommand}`);
|
|
16
|
+
// const startTime = Date.now();
|
|
17
|
+
// exec(msbuildCommand, { cwd: workDir, maxBuffer: 1024 * 1024 * 50 }, (error, stdout, stderr) => {
|
|
18
|
+
// console.log(`Build time: ${(Date.now() - startTime) / 1000} seconds`);
|
|
19
|
+
// if (error) {
|
|
20
|
+
// console.error(`❌ Build failed: ${error.message}`);
|
|
21
|
+
// const buildErrors = parseMsbuildErrors(stdout);
|
|
22
|
+
// const formattedBuildErrors = formatMsbuildResultToMarkdown(buildErrors);
|
|
23
|
+
// resolve({ success: false, message: formattedBuildErrors, buildErrors: buildErrors });
|
|
24
|
+
// return;
|
|
25
|
+
// }
|
|
26
|
+
// if (stderr) {
|
|
27
|
+
// console.warn(`⚠️ Warnings/Errors:\n${stdout}`);
|
|
28
|
+
// resolve({ success: false, message: stdout, buildErrors: null });
|
|
29
|
+
// return;
|
|
30
|
+
// }
|
|
31
|
+
// console.log(`✅ Build succeeded`);
|
|
32
|
+
// resolve({ success: true, message: stdout, buildErrors: null });
|
|
33
|
+
// });
|
|
34
|
+
// });
|
|
35
|
+
// }
|
|
36
|
+
// export function runMsBuildWithDevenv(projectPath: string): Promise<{ success: boolean; message: string }> {
|
|
37
|
+
// return new Promise((resolve) => {
|
|
38
|
+
// // in vsdevcmd env, MSBuild.exe is available
|
|
39
|
+
// const msbuildCommand = `devenvexe.cmd "${projectPath}" /build`; // /p:Configuration=debug`;
|
|
40
|
+
// // const fullCommand = `cmd /c "call "${vsDevCmdPath}" && ${msbuildCommand}"`;
|
|
41
|
+
// const workDir = path.join(__dirname, '../tools');
|
|
42
|
+
// console.log('📦 Running MSBuild...');
|
|
43
|
+
// exec(msbuildCommand, { cwd: workDir, maxBuffer: 1024 * 1024 * 50 }, (error, stdout, stderr) => {
|
|
44
|
+
// if (error) {
|
|
45
|
+
// console.error(`❌ Build failed: ${error.message}`);
|
|
46
|
+
// resolve({ success: false, message: error.message });
|
|
47
|
+
// return;
|
|
48
|
+
// }
|
|
49
|
+
// if (stderr) {
|
|
50
|
+
// console.warn(`⚠️ Warnings/Errors:\n${stderr}`);
|
|
51
|
+
// resolve({ success: false, message: stderr });
|
|
52
|
+
// return;
|
|
53
|
+
// }
|
|
54
|
+
// console.log(`✅ Build succeeded:\n${stdout}`);
|
|
55
|
+
// resolve({ success: true, message: stdout });
|
|
56
|
+
// });
|
|
57
|
+
// });
|
|
58
|
+
// }
|
|
59
|
+
// export function runMsBuild3(projectPath: string): Promise<{ success: boolean; message: string }> {
|
|
60
|
+
// return new Promise((resolve) => {
|
|
61
|
+
// // const vsDevCmdPath = process.env.VSDEVCMD_PATH || 'path_to_vsdevcmd'; // Ensure vsDevCmdPath is defined
|
|
62
|
+
// const fullCommand = `devenvexe.cmd "${projectPath}" /build Debug`;
|
|
63
|
+
// // const fullCommand = `call "${vsDevCmdPath}" && ${msbuildCommand}`;
|
|
64
|
+
// console.log('📦 Running MSBuild...');
|
|
65
|
+
// const workDir = path.join(__dirname, '../tools'); // Define a working directory for the build
|
|
66
|
+
// // Spawn cmd.exe with /c to execute the command
|
|
67
|
+
// const child = spawn('cmd', ['/c', fullCommand], {
|
|
68
|
+
// cwd: workDir,
|
|
69
|
+
// // stdio: ['inherit', 'inherit', 'inherit'], // Pipe stdout and stderr
|
|
70
|
+
// stdio: ['inherit', 'pipe', 'pipe'], // Pipe stdout and stderr
|
|
71
|
+
// shell: true
|
|
72
|
+
// });
|
|
73
|
+
// let stdout = '';
|
|
74
|
+
// let stderr = '';
|
|
75
|
+
// // Collect stdout
|
|
76
|
+
// child.stdout.on('data', (data) => {
|
|
77
|
+
// const output = data.toString();
|
|
78
|
+
// stdout += output;
|
|
79
|
+
// console.log(output);
|
|
80
|
+
// });
|
|
81
|
+
// // Collect stderr
|
|
82
|
+
// child.stderr.on('data', (data) => {
|
|
83
|
+
// const errorOutput = data.toString();
|
|
84
|
+
// stderr += errorOutput;
|
|
85
|
+
// console.warn(errorOutput);
|
|
86
|
+
// });
|
|
87
|
+
// // Handle process exit
|
|
88
|
+
// child.on('close', (code) => {
|
|
89
|
+
// if (code !== 0) {
|
|
90
|
+
// console.error(`❌ Build failed with exit code ${code}`);
|
|
91
|
+
// resolve({ success: false, message: stderr || `Build failed with exit code ${code}` });
|
|
92
|
+
// return;
|
|
93
|
+
// }
|
|
94
|
+
// if (stderr) {
|
|
95
|
+
// console.warn(`⚠️ Warnings/Errors:\n${stderr}`);
|
|
96
|
+
// resolve({ success: false, message: stderr });
|
|
97
|
+
// return;
|
|
98
|
+
// }
|
|
99
|
+
// console.log(`✅ Build succeeded`);
|
|
100
|
+
// resolve({ success: true, message: stdout });
|
|
101
|
+
// });
|
|
102
|
+
// // Handle spawn error
|
|
103
|
+
// child.on('error', (error) => {
|
|
104
|
+
// console.error(`❌ Spawn error: ${error.message}`);
|
|
105
|
+
// resolve({ success: false, message: error.message });
|
|
106
|
+
// });
|
|
107
|
+
// });
|
|
108
|
+
// }
|
|
109
|
+
// // runMsBuild('D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj');
|
|
110
|
+
// // runMsBuild3('D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj');
|
|
111
|
+
// // devenv "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /build Debug // incremental compile
|
|
112
|
+
// // devenv.com "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /build Debug // incremental compile
|
|
113
|
+
// // devenv.com "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /build Debug // incremental compile
|
|
114
|
+
// // devenv.com "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments.sln" /build Debug // incremental compile
|
|
115
|
+
// // msbuild "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /t:Build /p:Configuration=Debug /m /v:minimal
|
|
116
|
+
// // msbuild "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /t:Build /p:Configuration=Debug /m /v:minimal
|
|
117
|
+
// // msbuild "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /t:Build /p:Configuration=Debug /m /v:minimal /nr:true
|
|
118
|
+
// // devenv.com "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments.sln" /project "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj" /build Debug
|
|
119
|
+
// // devenvexe.cmd "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments.sln" /build Debug /project "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj"
|
|
120
|
+
// // devenvcom.cmd "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments.sln" /build Debug /project "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\SharedSegments.Tests.csproj"
|
|
121
|
+
// // msbuildexe.cmd \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /t:Build /m /nr:true /v:minimal
|
|
122
|
+
// // runMsBuild('D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj');
|
|
123
|
+
//# sourceMappingURL=msBuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msBuild.js","sourceRoot":"","sources":["../../src/codebk/msBuild.ts"],"names":[],"mappings":";AAAA,gCAAgC;;AAEhC,+CAA+C;AAC/C,iGAAiG;AAEjG,2CAA2C;AAE3C,+CAA+C;AAE/C,kEAAkE;AAClE,qCAAqC;AACrC,iDAAiD;AACjD,4HAA4H;AAC5H,wNAAwN;AAExN,mFAAmF;AAEnF,4DAA4D;AAC5D,+DAA+D;AAC/D,wCAAwC;AACxC,qGAAqG;AACrG,qFAAqF;AACrF,kBAAkB;AAClB,yDAAyD;AACzD,kEAAkE;AAClE,2FAA2F;AAC3F,4FAA4F;AAC5F,cAAc;AACd,OAAO;AAEP,mBAAmB;AACnB,sDAAsD;AACtD,uEAAuE;AACvE,cAAc;AACd,OAAO;AAEP,uCAAuC;AACvC,sEAAsE;AACtE,QAAQ;AACR,OAAO;AACP,IAAI;AAGJ,8GAA8G;AAC9G,qCAAqC;AACrC,iDAAiD;AACjD,gGAAgG;AAEhG,mFAAmF;AACnF,4DAA4D;AAC5D,0CAA0C;AAC1C,qGAAqG;AACrG,kBAAkB;AAClB,yDAAyD;AACzD,2DAA2D;AAC3D,cAAc;AACd,OAAO;AAEP,mBAAmB;AACnB,sDAAsD;AACtD,oDAAoD;AACpD,cAAc;AACd,OAAO;AAEP,mDAAmD;AACnD,kDAAkD;AAClD,QAAQ;AACR,OAAO;AACP,IAAI;AAEJ,qGAAqG;AACrG,wCAAwC;AACxC,qHAAqH;AACrH,6EAA6E;AAC7E,gFAAgF;AAEhF,gDAAgD;AAChD,kGAAkG;AAClG,0DAA0D;AAC1D,4DAA4D;AAC5D,4BAA4B;AAC5B,qFAAqF;AACrF,4EAA4E;AAC5E,0BAA0B;AAC1B,cAAc;AAEd,2BAA2B;AAC3B,2BAA2B;AAE3B,4BAA4B;AAC5B,8CAA8C;AAC9C,8CAA8C;AAC9C,gCAAgC;AAChC,mCAAmC;AACnC,cAAc;AAEd,4BAA4B;AAC5B,8CAA8C;AAC9C,mDAAmD;AACnD,qCAAqC;AACrC,yCAAyC;AACzC,cAAc;AAEd,iCAAiC;AACjC,wCAAwC;AACxC,gCAAgC;AAChC,0EAA0E;AAC1E,yGAAyG;AACzG,0BAA0B;AAC1B,gBAAgB;AAEhB,4BAA4B;AAC5B,kEAAkE;AAClE,gEAAgE;AAChE,0BAA0B;AAC1B,gBAAgB;AAEhB,gDAAgD;AAChD,2DAA2D;AAC3D,cAAc;AAEd,gCAAgC;AAChC,yCAAyC;AACzC,gEAAgE;AAChE,mEAAmE;AACnE,cAAc;AACd,UAAU;AACV,IAAI;AAEJ,wIAAwI;AACxI,yIAAyI;AAEzI,kKAAkK;AAClK,sKAAsK;AACtK,sKAAsK;AACtK,yHAAyH;AACzH,2KAA2K;AAC3K,2KAA2K;AAC3K,oLAAoL;AAEpL,yNAAyN;AAEzN,4NAA4N;AAC5N,4NAA4N;AAE5N,4KAA4K;AAC5K,wIAAwI","sourcesContent":["// import * as path from 'path';\r\n\r\n// import { exec, spawn } from 'child_process';\r\n// import { formatMsbuildResultToMarkdown, parseMsbuildErrors } from '../utils/parseBuildResult';\r\n\r\n// import { msBuildPath } from './vsTools';\r\n\r\n// // import { vsDevCmdPath } from './vsTools';\r\n\r\n// export function runMsBuild(projectPath: string): Promise<any> {\r\n// \treturn new Promise((resolve) => {\r\n// \t\t// in vsdevcmd env, MSBuild.exe is available\r\n// \t\tconst msbuildCommand = `\"${msBuildPath}\" \"${projectPath}\" /t:Build /m /nr:true /v:minimal`; // /p:Configuration=debug`;\r\n// \t\t// const msbuildCommand = `\"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Enterprise\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\MSBuild.exe\" \"${projectPath}\" /t:Build /m /nr:true /v:minimal`; // /p:Configuration=debug`;\r\n\r\n// \t\t// const fullCommand = `cmd /c \"call \"${vsDevCmdPath}\" && ${msbuildCommand}\"`;\r\n\r\n// const workDir = path.join(__dirname, '../tools');\r\n// \t\tconsole.log(`📦 Running MSBuild... \\n ${msbuildCommand}`);\r\n// const startTime = Date.now();\r\n// \t\texec(msbuildCommand, { cwd: workDir, maxBuffer: 1024 * 1024 * 50 }, (error, stdout, stderr) => {\r\n// console.log(`Build time: ${(Date.now() - startTime) / 1000} seconds`);\r\n// \t\t\tif (error) {\r\n// \t\t\t\tconsole.error(`❌ Build failed: ${error.message}`);\r\n// const buildErrors = parseMsbuildErrors(stdout);\r\n// const formattedBuildErrors = formatMsbuildResultToMarkdown(buildErrors);\r\n// \t\t\t\tresolve({ success: false, message: formattedBuildErrors, buildErrors: buildErrors });\r\n// \t\t\t\treturn;\r\n// \t\t\t}\r\n\r\n// \t\t\tif (stderr) {\r\n// \t\t\t\tconsole.warn(`⚠️ Warnings/Errors:\\n${stdout}`);\r\n// \t\t\t\tresolve({ success: false, message: stdout, buildErrors: null });\r\n// \t\t\t\treturn;\r\n// \t\t\t}\r\n\r\n// \t\t\tconsole.log(`✅ Build succeeded`);\r\n// \t\t\tresolve({ success: true, message: stdout, buildErrors: null });\r\n// \t\t});\r\n// \t});\r\n// }\r\n\r\n\r\n// export function runMsBuildWithDevenv(projectPath: string): Promise<{ success: boolean; message: string }> {\r\n// \treturn new Promise((resolve) => {\r\n// \t\t// in vsdevcmd env, MSBuild.exe is available\r\n// \t\tconst msbuildCommand = `devenvexe.cmd \"${projectPath}\" /build`; // /p:Configuration=debug`;\r\n\r\n// \t\t// const fullCommand = `cmd /c \"call \"${vsDevCmdPath}\" && ${msbuildCommand}\"`;\r\n// const workDir = path.join(__dirname, '../tools');\r\n// \t\tconsole.log('📦 Running MSBuild...');\r\n// \t\texec(msbuildCommand, { cwd: workDir, maxBuffer: 1024 * 1024 * 50 }, (error, stdout, stderr) => {\r\n// \t\t\tif (error) {\r\n// \t\t\t\tconsole.error(`❌ Build failed: ${error.message}`);\r\n// \t\t\t\tresolve({ success: false, message: error.message });\r\n// \t\t\t\treturn;\r\n// \t\t\t}\r\n\r\n// \t\t\tif (stderr) {\r\n// \t\t\t\tconsole.warn(`⚠️ Warnings/Errors:\\n${stderr}`);\r\n// \t\t\t\tresolve({ success: false, message: stderr });\r\n// \t\t\t\treturn;\r\n// \t\t\t}\r\n\r\n// \t\t\tconsole.log(`✅ Build succeeded:\\n${stdout}`);\r\n// \t\t\tresolve({ success: true, message: stdout });\r\n// \t\t});\r\n// \t});\r\n// }\r\n\r\n// export function runMsBuild3(projectPath: string): Promise<{ success: boolean; message: string }> {\r\n// return new Promise((resolve) => {\r\n// // const vsDevCmdPath = process.env.VSDEVCMD_PATH || 'path_to_vsdevcmd'; // Ensure vsDevCmdPath is defined\r\n// const fullCommand = `devenvexe.cmd \"${projectPath}\" /build Debug`;\r\n// // const fullCommand = `call \"${vsDevCmdPath}\" && ${msbuildCommand}`;\r\n\r\n// console.log('📦 Running MSBuild...');\r\n// \t\tconst workDir = path.join(__dirname, '../tools'); // Define a working directory for the build\r\n// // Spawn cmd.exe with /c to execute the command\r\n// const child = spawn('cmd', ['/c', fullCommand], {\r\n// cwd: workDir,\r\n// // stdio: ['inherit', 'inherit', 'inherit'], // Pipe stdout and stderr\r\n// stdio: ['inherit', 'pipe', 'pipe'], // Pipe stdout and stderr\r\n// shell: true\r\n// });\r\n\r\n// let stdout = '';\r\n// let stderr = '';\r\n\r\n// // Collect stdout\r\n// child.stdout.on('data', (data) => {\r\n// const output = data.toString();\r\n// stdout += output;\r\n// console.log(output);\r\n// });\r\n\r\n// // Collect stderr\r\n// child.stderr.on('data', (data) => {\r\n// const errorOutput = data.toString();\r\n// stderr += errorOutput;\r\n// console.warn(errorOutput);\r\n// });\r\n\r\n// // Handle process exit\r\n// child.on('close', (code) => {\r\n// if (code !== 0) {\r\n// console.error(`❌ Build failed with exit code ${code}`);\r\n// resolve({ success: false, message: stderr || `Build failed with exit code ${code}` });\r\n// return;\r\n// }\r\n\r\n// if (stderr) {\r\n// console.warn(`⚠️ Warnings/Errors:\\n${stderr}`);\r\n// resolve({ success: false, message: stderr });\r\n// return;\r\n// }\r\n\r\n// console.log(`✅ Build succeeded`);\r\n// resolve({ success: true, message: stdout });\r\n// });\r\n\r\n// // Handle spawn error\r\n// child.on('error', (error) => {\r\n// console.error(`❌ Spawn error: ${error.message}`);\r\n// resolve({ success: false, message: error.message });\r\n// });\r\n// });\r\n// }\r\n\r\n// // runMsBuild('D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj');\r\n// // runMsBuild3('D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj');\r\n\r\n// // devenv \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /build Debug // incremental compile\r\n// // devenv.com \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /build Debug // incremental compile\r\n// // devenv.com \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /build Debug // incremental compile\r\n// // devenv.com \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments.sln\" /build Debug // incremental compile\r\n// // msbuild \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /t:Build /p:Configuration=Debug /m /v:minimal\r\n// // msbuild \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /t:Build /p:Configuration=Debug /m /v:minimal\r\n// // msbuild \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /t:Build /p:Configuration=Debug /m /v:minimal /nr:true\r\n\r\n// // devenv.com \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments.sln\" /project \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\" /build Debug\r\n\r\n// // devenvexe.cmd \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments.sln\" /build Debug /project \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\"\r\n// // devenvcom.cmd \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments.sln\" /build Debug /project \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj\"\r\n\r\n// // msbuildexe.cmd \\\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\\\" /t:Build /m /nr:true /v:minimal\r\n// // runMsBuild('D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj');"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{%- if isBuildFailure -%}
|
|
2
|
+
{%- assign failedStage = "MSBuild" -%}
|
|
3
|
+
{%- assign failedTitle = "MSBuild failed information:" -%}
|
|
4
|
+
{%- else -%}
|
|
5
|
+
{%- assign failedStage = "vstest" -%}
|
|
6
|
+
{%- assign failedTitle = "vstest failed test methods:" -%}
|
|
7
|
+
{%- endif -%}
|
|
8
|
+
|
|
9
|
+
The unit test code provided in the assistant response failed with {{failedStage}}. Fix the test code based on {{failedStage}} failure information.
|
|
10
|
+
|
|
11
|
+
### {{failedTitle}}
|
|
12
|
+
%s
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{%- if isXapTest -%}
|
|
2
|
+
{%- assign xapSuffix = " with the XAP framework" -%}
|
|
3
|
+
{%- else -%}
|
|
4
|
+
{%- assign xapSuffix = "" -%}
|
|
5
|
+
{%- endif -%}
|
|
6
|
+
|
|
7
|
+
You are a **highly skilled software engineer specializing in C# unit testing**.
|
|
8
|
+
|
|
9
|
+
Write **unit tests** for the user-provided C# source code, strictly following the guidelines below.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
### ✅ Unit Test Guidelines
|
|
14
|
+
|
|
15
|
+
* **Framework**:
|
|
16
|
+
✅ Use **MSTest** for all test code.
|
|
17
|
+
|
|
18
|
+
* **Output Format**:
|
|
19
|
+
✅ Return the test code **only**, wrapped like this:
|
|
20
|
+
|
|
21
|
+
```C#
|
|
22
|
+
<Test Code>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
* **Comments / Explanations**:
|
|
26
|
+
❌ Do **not** include **any comments, descriptions, or explanations** in the output.
|
|
27
|
+
|
|
28
|
+
* **Syntax Validity**:
|
|
29
|
+
✅ Ensure **no syntax errors**.
|
|
30
|
+
✅ The generated code **must compile and run under Visual Studio `vstest`**.
|
|
31
|
+
|
|
32
|
+
* **Mocking Rules**:
|
|
33
|
+
|
|
34
|
+
✅ **Mock all external dependencies** (any class, method, or value not included in the user input) using **Moq**.
|
|
35
|
+
❌ **Do not** mock any class, function, or value that exists inside the source code.
|
|
36
|
+
✅ **Do not** attempt to access private members of the source class. Only use **public methods and properties**.
|
|
37
|
+
|
|
38
|
+
* **Namespace & Usings**:
|
|
39
|
+
|
|
40
|
+
✅ Always include a **namespace** block for the test code.
|
|
41
|
+
✅ Place **all using statements above** the namespace.
|
|
42
|
+
✅ **Import the namespace of the source code** in the test code.
|
|
43
|
+
✅ **Import all required .NET namespaces** needed for compilation.
|
|
44
|
+
|
|
45
|
+
* **Test Method Naming**:
|
|
46
|
+
|
|
47
|
+
✅ Follow the naming pattern:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
[MethodName]_[Scenario]_[ExpectedResult]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
* **Test Coverage Requirements**:
|
|
54
|
+
|
|
55
|
+
✅ Write **valid and meaningful test cases** covering:
|
|
56
|
+
|
|
57
|
+
| Coverage Area | Requirement |
|
|
58
|
+
| ------------------- | ---------------------------------------------------- |
|
|
59
|
+
| Main Logic Paths | Cover normal/happy paths |
|
|
60
|
+
| Edge Cases | Cover nulls, boundary values |
|
|
61
|
+
| Exception Handling | If source code throws exceptions, test that |
|
|
62
|
+
| Boundary Conditions | Check for inputs like 0, negative, empty lists, etc. |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
{% if isXapTest %}
|
|
67
|
+
{%- include 'xap/xapGuideline' -%}
|
|
68
|
+
{%- endif -%}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{%- if isXapTest -%}
|
|
2
|
+
{%- assign xapSuffix = " with the XAP framework" -%}
|
|
3
|
+
{%- else -%}
|
|
4
|
+
{%- assign xapSuffix = "" -%}
|
|
5
|
+
{%- endif -%}
|
|
6
|
+
|
|
7
|
+
You are a highly skilled software engineer specializing in C# unit testing{{xapSuffix}}. Write unit tests for user-provided C# code, must obey the following guidelines:
|
|
8
|
+
### Unit Test Guidelines
|
|
9
|
+
- Use MSTest framework for all test code.
|
|
10
|
+
- MUST NOT add any comments or explanations in the test code.
|
|
11
|
+
- Ensure the test code has no syntax errors.
|
|
12
|
+
- Mock all dependencies not included in the user-provided inputs using Moq.
|
|
13
|
+
- Must not access private members (fields or methods) of the source class in test code, use public methods only.
|
|
14
|
+
- Must include a namespace in the test code, and put using statement above namespace.
|
|
15
|
+
- Must import source code namespace in the test code.
|
|
16
|
+
- Must import required .Net namespaces if using .Net class or interface in the test code.
|
|
17
|
+
- Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].
|
|
18
|
+
- Return the test code in the format: ```C#\n<Test code>\n```.
|
|
19
|
+
- Write valid test cases that cover:
|
|
20
|
+
- Main logic paths (e.g., happy path, edge cases).
|
|
21
|
+
- Exception handling if applicable.
|
|
22
|
+
- Boundary conditions (e.g., zero, negative, or null inputs).
|
|
23
|
+
- Ensure the generated test code can pass the test of vstest in visual studio.
|
|
24
|
+
- NOTE: It is critical to pass the vstest. If some test cases are not covered by the source code and cause the vstest test to fail, please remove these test cases.
|
|
25
|
+
|
|
26
|
+
{% if isXapTest %}
|
|
27
|
+
{%- include 'xap/xapGuideline' -%}
|
|
28
|
+
{%- endif -%}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# ✅ XAP Code Unit Test Guidelines
|
|
2
|
+
|
|
3
|
+
**⚠️ These rules only apply when the code under test is a XAP class.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
## 1. What is a XAP Class?
|
|
7
|
+
|
|
8
|
+
A class is considered a **XAP class** if it meets **both** of the following conditions:
|
|
9
|
+
* **It inherits from one or more of the following interfaces:**
|
|
10
|
+
* `IPlugin`
|
|
11
|
+
* `IConditionPlugin`
|
|
12
|
+
* `Workflow`
|
|
13
|
+
* `IExperiment`
|
|
14
|
+
* `IPluginDataStore`
|
|
15
|
+
* `IAsyncPlugin`
|
|
16
|
+
* **It implements an `Execute` method**
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. XAP Class Instantiation Rule
|
|
21
|
+
* **Always create XAP class instances using:**
|
|
22
|
+
```csharp
|
|
23
|
+
ExecutionServices.CreateInstance<I{ClassName}>()
|
|
24
|
+
```
|
|
25
|
+
Where `{ClassName}` is the original class name prefixed with "I".
|
|
26
|
+
|
|
27
|
+
**Example:**
|
|
28
|
+
|
|
29
|
+
For a class named `SampleWorkflow`:
|
|
30
|
+
```csharp
|
|
31
|
+
var sampleWorkflow = ExecutionServices.CreateInstance<ISampleWorkflow>();
|
|
32
|
+
```
|
|
33
|
+
❌ **Never use `new {Xap class name}` to create instance for XAP classes.**
|
|
34
|
+
❌ **Never use `ExecutionServices.CreateInstance` for non-XAP classes.**
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Special Rules for `Execute` Method Parameters (XAP Classes Only)
|
|
39
|
+
### 3.1 Parameter Differences Between Source Code and Test Code
|
|
40
|
+
When calling `Execute` on a XAP class instance in test code:
|
|
41
|
+
* The following parameter types **are automatically removed**:
|
|
42
|
+
* `PluginServices`
|
|
43
|
+
* Any `PluginOutput<T>`
|
|
44
|
+
* Any parameter decorated with `[ConfigFile("{ConfigFileName}")]`
|
|
45
|
+
|
|
46
|
+
❌ **You MUST NOT try to mock or pass these removed parameters manually in test code.**
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### 3.2 How to Call `Execute` in Test Code
|
|
51
|
+
For each **remaining parameter** (after removal):
|
|
52
|
+
* ✅ **Keep the original parameter order**
|
|
53
|
+
* ✅ **Match the parameter types exactly**
|
|
54
|
+
* ✅ **Wrap each argument with `Task.FromResult({value})`**
|
|
55
|
+
|
|
56
|
+
**Example:**
|
|
57
|
+
|
|
58
|
+
Given this source method signature:
|
|
59
|
+
```csharp
|
|
60
|
+
PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)
|
|
61
|
+
```
|
|
62
|
+
✅ The correct test call is:
|
|
63
|
+
```csharp
|
|
64
|
+
sampleWorkflow.Execute(Task.FromResult(osResp), Task.FromResult(req)).Result;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 4. Handling `PluginOutput<T>` Parameters (Outputs)
|
|
70
|
+
For each `PluginOutput<T>` parameter in the XAP class `Execute` method:
|
|
71
|
+
* ✅ Treat it as a **method output**
|
|
72
|
+
* ✅ Access it via the **XAP class instance** using the **original parameter name**
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
|
|
76
|
+
If the instance is `sampleWorkflow`, and the parameter is `pluginResult`, access:
|
|
77
|
+
```csharp
|
|
78
|
+
sampleWorkflow.pluginResult
|
|
79
|
+
```
|
|
80
|
+
To access fields inside the pluginResult, must use `.Result` first, assume pluginResult has a field named Key, access:
|
|
81
|
+
```csharp
|
|
82
|
+
sampleWorkflow.pluginResult.Result.Key
|
|
83
|
+
```
|
|
84
|
+
**Assertion Example:**
|
|
85
|
+
```csharp
|
|
86
|
+
Assert.NotNull(sampleWorkflow.pluginResult.Result.Key);
|
|
87
|
+
Assert.AreEqual("key", sampleWorkflow.pluginResult.Result.Key);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 5. Working with Bond Structures in Test Code
|
|
93
|
+
### 5.1 Treat Bond Structures Like Regular C# Classes
|
|
94
|
+
* ✅ **Import Bond namespaces by used Bond structures**
|
|
95
|
+
* ✅ **Use full type names to get nested Bond types definitions from user input**
|
|
96
|
+
* ✅ Create Bond structure instances with:
|
|
97
|
+
```csharp
|
|
98
|
+
ExecutionServices.CreateInstance<{BondStructName}>()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### 5.2 Required Fields Rule (No Optional Modifier)
|
|
104
|
+
|
|
105
|
+
For each Bond structure field **without the `optional` modifier**:
|
|
106
|
+
|
|
107
|
+
* ✅ You **MUST assign a valid, non-null value** in test code.
|
|
108
|
+
|
|
109
|
+
**Example Bond Structure:**
|
|
110
|
+
|
|
111
|
+
```csharp
|
|
112
|
+
struct EplantUser
|
|
113
|
+
{
|
|
114
|
+
1: uint64 Score;
|
|
115
|
+
2: int64 Created;
|
|
116
|
+
3: string Market;
|
|
117
|
+
4: vector<string> Trees;
|
|
118
|
+
5: EplantUserWeatherContent WeatherContent;
|
|
119
|
+
6: bool MergeNotifyWeather;
|
|
120
|
+
7: optional EplantUserWalletContent WalletContent;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
✅ In test code:
|
|
124
|
+
|
|
125
|
+
You **must** assign values for all fields except `WalletContent`.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### 5.3 Special Case: Source Code Null Checks for Required Fields
|
|
130
|
+
|
|
131
|
+
If the source code contains null checks on required fields (e.g., `if (sampleRequest?.Category == null)`):
|
|
132
|
+
|
|
133
|
+
* ✅ You can generate a test case where the entire Bond object (e.g., `sampleRequest`) is null.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 6. Type Conversion Rules
|
|
138
|
+
|
|
139
|
+
For scenarios where `IList<T>` needs to be converted to `IEnumerable<T>`:
|
|
140
|
+
|
|
141
|
+
* ✅ Use `.AsEnumerable()`
|
|
142
|
+
|
|
143
|
+
**Example:**
|
|
144
|
+
|
|
145
|
+
```csharp
|
|
146
|
+
IEnumerable osResponses = osResponseList.AsEnumerable();
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|