⚠️ Unable to {Quarantine|Disable}【免费下载链接】aspireAspire is the tool for code-first, extensible, observable dev and deploy.项目地址: https://gitcode.com/GitHub_Trending/as/aspireTest MethodReasonTestMethodTest method not found in repository (QuarantineTools exit code: X)TestMethodBuild failed after adding attribute## 八、源码级原理QuarantineTools 如何实现安全修改 结合 [Quarantine.cs](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83) 源码文件头部注释即给出了整体流程说明见 [Quarantine.cs#L12-L38](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L12-L38)核心机制如下 ### 8.1 主流程 Main[Quarantine.cs#L45-L131](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L45-L131)基于 System.CommandLine 定义选项后进入 ExecuteAsync后者依次执行 1. **定位仓库根**FindRepoRoot 从当前目录向上查找含 .git 的目录[Quarantine.cs#L478-L490](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L478-L490)默认扫描根为 repo-root/tests可用 -r 覆盖 2. **枚举源文件**EnumerateCsFiles 遍历 .cs 文件按目录段精确跳过 bin、obj、.git、.github、artifacts、node_modules 等重目录[Quarantine.cs#L349-L402](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L349-L402) 3. **文本预过滤**为避免对每个文件都做 Roslyn 解析先构建两条预编译正则——方法名正则quarantine 模式要求目标方法名出现与属性正则unquarantine 模式要求目标属性出现不满足则直接跳过[Quarantine.cs#L199-L214](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L199-L214) 4. **并行 Roslyn 解析与匹配**Parallel.ForEachAsync 并发解析语法树对每个 MethodDeclarationSyntax 用 GetEnclosingNames 提取包围的 namespace含 file-scoped namespace与类型链class/struct/record/interface含嵌套与解析后的目标路径逐段 Ordinal 比较[Quarantine.cs#L515-L552](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L515-L552) 5. **添加/移除特性** - AddTargetAttribute 在已有特性列表后追加保留原缩进并通过 DetectNewLine 保持文件原有换行风格CRLF/LF若目标特性已存在则直接返回原节点保证**幂等**[Quarantine.cs#L670-L730](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L670-L730) - RemoveTargetAttribute 只移除匹配的特性保留列表中其他特性[Quarantine.cs#L637-L664](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L637-L664) 6. **using 指令管理**隔离时若属性使用短名且指定了命名空间EnsureUsingDirective 会补 using Aspire.TestUtilities;quarantine 模式或 using Xunit;activeissue 模式解除隔离后若文件内不再有任何目标属性RemoveUsingDirective 会连带清理 using[Quarantine.cs#L737-L815](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L737-L815) 7. **写回与汇总**仅当文本实际变化时写回磁盘并打印 Updated N file(s): 及相对仓库根的文件路径列表。 ### 8.2 属性名匹配细节 PrepareAttributeHandling[Quarantine.cs#L574-L631](https://link.gitcode.com/i/9d730d2ac96cb313ba650e17c8fa1c83#L574-L631)允许 -a 参数带或不带 Attribute 后缀、带或不带命名空间并将输入归一化为短名 需确保的 using 命名空间。匹配器同时接受限定名与短名形式QuarantinedTest 或 QuarantinedTestAttribute若指定了命名空间则要求限定部分的命名空间精确匹配。这解释了 README 中工具接受带或不带 Attribute 后缀的名字的行为来源。 ## 九、关键约束清单Important Constraints 操作过程中必须遵守 SKILL 文档列出的硬性约束 - **必须使用 QuarantineTools** 添加/移除特性绝不手动编辑条件参数的手动补充除外 - **每次工具调用只处理一个测试** - **绝不修改测试逻辑**——只增删特性 - 隔离/禁用操作**绝不关闭 issue**仅以 Addresses 引用解除隔离操作则用 Closes - **修改后必须构建并运行验证** - **Issue URL 强制必填**绝不无 URL 隔离/禁用 - **全限定名强制要求**Namespace.Type.Method - 条件特性需手动编辑补充工具只加基础属性 - 调度属性变更需**审计运行时 E2E 路由**可能增删常规 PR 消费者需同步 [test-trigger-map.yml](https://link.gitcode.com/i/2c4ad4439e015cff3e93e4c39056cfbf) - **禁止占位符值**——必须使用真实的 issue 编号与测试名。 ## 十、执行总结格式 任务完成后按以下模板输出执行摘要 markdown ## Test Management Agent - Execution Summary ### ✅ Successfully {Quarantined|Disabled|Unquarantined|Re-enabled} - **TestMethod1** in tests/Project.Tests/File.cs - Issue: https://github.com/microsoft/aspire/issues/XXXXX - Attribute: [{QuarantinedTest|ActiveIssue}] - Verification: Passed ✓ ### ❌ Failed to {Quarantine|Disable|Unquarantine|Re-enable} - **TestMethod2** - Reason: {ErrorReason} ### Pull Request - **Title:** {PRTitle} - **Branch:** {BranchName} ### Statistics - Total requested: {Total} - Successfully {quarantined|disabled|unquarantined|re-enabled}: {Success} - Failed: {Failed} - Test projects modified: {ProjectCount}【免费下载链接】aspireAspire is the tool for code-first, extensible, observable dev and deploy.项目地址: https://gitcode.com/GitHub_Trending/as/aspire创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考