Skip to content

refactor(core): 移除废弃的同步命令查询扩展方法并简化类型引用#81

Merged
GeWuYou merged 1 commit into
mainfrom
refactor/remove-deprecated-sync-methods
Mar 5, 2026
Merged

refactor(core): 移除废弃的同步命令查询扩展方法并简化类型引用#81
GeWuYou merged 1 commit into
mainfrom
refactor/remove-deprecated-sync-methods

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Mar 5, 2026

Copy link
Copy Markdown
Owner
  • 移除了 ContextAwareCommandExtensions 中废弃的 SendCommand 同步方法
  • 移除了 ContextAwareQueryExtensions 中废弃的 SendQuery 同步方法
  • 简化了 ICommand 和 IQuery 的类型引用,移除冗长的命名空间前缀
  • 保持了异步命令和查询方法的功能完整性

Summary by Sourcery

移除已弃用的、支持上下文的 Mediator 同步命令/查询辅助方法,并简化命令/查询类型的使用。

增强内容:

  • 从支持上下文的扩展中移除基于 Mediator 的传统同步扩展方法 SendCommandSendQuery
  • 在支持上下文的扩展中,通过直接使用接口类型而非完整限定命名空间,简化对 ICommandIQuery 的引用。
Original summary in English

Summary by Sourcery

Remove deprecated context-aware Mediator sync command/query helpers and simplify command/query type usage.

Enhancements:

  • Remove legacy synchronous Mediator-based SendCommand and SendQuery extension methods from context-aware extensions.
  • Simplify ICommand and IQuery references in context-aware extensions by using direct interface types instead of fully qualified namespaces.

- 移除了 ContextAwareCommandExtensions 中废弃的 SendCommand 同步方法
- 移除了 ContextAwareQueryExtensions 中废弃的 SendQuery 同步方法
- 简化了 ICommand 和 IQuery 的类型引用,移除冗长的命名空间前缀
- 保持了异步命令和查询方法的功能完整性
@sourcery-ai

sourcery-ai Bot commented Mar 5, 2026

Copy link
Copy Markdown
审查者指南(在小型 PR 中折叠显示)

审查者指南

此 PR 删除了已弃用的、基于 Mediator 的同步命令/查询扩展方法,并简化了命令/查询抽象中类型引用的写法,同时保留了现有的异步 API 和未弃用的同步 API。

重构前:支持上下文感知命令/查询扩展的类图

classDiagram
    class IContextAware {
        +GetContext() IContext
    }

    class IContext {
        +SendCommand_TResponse(command Mediator_ICommand_TResponse) TResponse
        +SendCommand_TResult(command Abstractions_command_ICommand_TResult) TResult
        +SendCommand(command Abstractions_command_ICommand) void
        +SendQuery_TResponse(query Mediator_IQuery_TResponse) TResponse
        +SendQuery_TResult(query Abstractions_query_IQuery_TResult) TResult
    }

    class Mediator_ICommand_TResponse {
        <<interface>>
    }

    class Mediator_IQuery_TResponse {
        <<interface>>
    }

    class Abstractions_command_ICommand_TResult {
        <<interface>>
    }

    class Abstractions_command_ICommand {
        <<interface>>
    }

    class Abstractions_query_IQuery_TResult {
        <<interface>>
    }

    class ContextAwareCommandExtensions {
        +SendCommand_TResponse(contextAware IContextAware, command Mediator_ICommand_TResponse) TResponse
        +SendCommand_TResult(contextAware IContextAware, command Abstractions_command_ICommand_TResult) TResult
        +SendCommand(contextAware IContextAware, command Abstractions_command_ICommand) void
    }

    class ContextAwareQueryExtensions {
        +SendQuery_TResponse(contextAware IContextAware, query Mediator_IQuery_TResponse) TResponse
        +SendQuery_TResult(contextAware IContextAware, query Abstractions_query_IQuery_TResult) TResult
    }

    IContextAware --> IContext
    ContextAwareCommandExtensions ..> IContextAware
    ContextAwareCommandExtensions ..> Mediator_ICommand_TResponse
    ContextAwareCommandExtensions ..> Abstractions_command_ICommand_TResult
    ContextAwareCommandExtensions ..> Abstractions_command_ICommand
    ContextAwareQueryExtensions ..> IContextAware
    ContextAwareQueryExtensions ..> Mediator_IQuery_TResponse
    ContextAwareQueryExtensions ..> Abstractions_query_IQuery_TResult
    IContext ..> Mediator_ICommand_TResponse
    IContext ..> Abstractions_command_ICommand_TResult
    IContext ..> Abstractions_command_ICommand
    IContext ..> Mediator_IQuery_TResponse
    IContext ..> Abstractions_query_IQuery_TResult
Loading

重构后:支持上下文感知命令/查询扩展的更新类图

classDiagram
    class IContextAware {
        +GetContext() IContext
    }

    class IContext {
        +SendCommand_TResult(command ICommand_TResult) TResult
        +SendCommand(command ICommand) void
        +SendQuery_TResult(query IQuery_TResult) TResult
    }

    class ICommand_TResult {
        <<interface>>
    }

    class ICommand {
        <<interface>>
    }

    class IQuery_TResult {
        <<interface>>
    }

    class ContextAwareCommandExtensions {
        +SendCommand_TResult(contextAware IContextAware, command ICommand_TResult) TResult
        +SendCommand(contextAware IContextAware, command ICommand) void
    }

    class ContextAwareQueryExtensions {
        +SendQuery_TResult(contextAware IContextAware, query IQuery_TResult) TResult
    }

    IContextAware --> IContext
    ContextAwareCommandExtensions ..> IContextAware
    ContextAwareCommandExtensions ..> ICommand_TResult
    ContextAwareCommandExtensions ..> ICommand
    ContextAwareQueryExtensions ..> IContextAware
    ContextAwareQueryExtensions ..> IQuery_TResult
    IContext ..> ICommand_TResult
    IContext ..> ICommand
    IContext ..> IQuery_TResult
Loading

文件级变更

变更 详细说明 文件
移除仅为兼容性而保留的、已弃用的基于 Mediator 的同步 SendCommand 和 SendQuery 扩展方法。
  • 删除旧版的 ContextAwareCommandExtensions.SendCommand(IContextAware, Mediator.ICommand) 重载(该方法仅转发到 context.SendCommand)
  • 删除旧版的 ContextAwareQueryExtensions.SendQuery(IContextAware, Mediator.IQuery) 重载(该方法仅转发到 context.SendQuery)
GFramework.Core/extensions/ContextAwareCommandExtensions.cs
GFramework.Core/extensions/ContextAwareQueryExtensions.cs
简化 ICommand/IQuery 类型引用,使用直接的接口名而不是完整命名空间。
  • 将 ContextAwareCommandExtensions.SendCommand 的参数类型从 Abstractions.command.ICommand 更新为 ICommand
  • 将 ContextAwareCommandExtensions.SendCommand 的参数类型从 Abstractions.command.ICommand 更新为 ICommand
  • 将 ContextAwareQueryExtensions.SendQuery 的参数类型从 Abstractions.query.IQuery 更新为 IQuery
GFramework.Core/extensions/ContextAwareCommandExtensions.cs
GFramework.Core/extensions/ContextAwareQueryExtensions.cs

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在某条审查评论下回复,要求 Sourcery 基于该评论创建一个 Issue。你也可以直接回复 @sourcery-ai issue 来从该评论创建 Issue。
  • 生成 Pull Request 标题: 在 PR 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 PR 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 PR 正文任意位置写上 @sourcery-ai summary,即可在对应位置生成 PR 摘要。你也可以在 PR 中评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可在任意时间(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。当你已经处理完所有评论且不想再看到它们时,这会很有用。
  • 忽略所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。尤其适用于你希望从一个全新的审查开始的场景——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的使用体验

打开你的 控制台/仪表盘 来:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 Pull Request 摘要、审查者指南等。
  • 修改审查使用的语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes deprecated synchronous Mediator-based command/query extension methods and simplifies type references for command/query abstractions while preserving the existing async and non-deprecated sync APIs.

Class diagram for context-aware command/query extensions before refactor

classDiagram
    class IContextAware {
        +GetContext() IContext
    }

    class IContext {
        +SendCommand_TResponse(command Mediator_ICommand_TResponse) TResponse
        +SendCommand_TResult(command Abstractions_command_ICommand_TResult) TResult
        +SendCommand(command Abstractions_command_ICommand) void
        +SendQuery_TResponse(query Mediator_IQuery_TResponse) TResponse
        +SendQuery_TResult(query Abstractions_query_IQuery_TResult) TResult
    }

    class Mediator_ICommand_TResponse {
        <<interface>>
    }

    class Mediator_IQuery_TResponse {
        <<interface>>
    }

    class Abstractions_command_ICommand_TResult {
        <<interface>>
    }

    class Abstractions_command_ICommand {
        <<interface>>
    }

    class Abstractions_query_IQuery_TResult {
        <<interface>>
    }

    class ContextAwareCommandExtensions {
        +SendCommand_TResponse(contextAware IContextAware, command Mediator_ICommand_TResponse) TResponse
        +SendCommand_TResult(contextAware IContextAware, command Abstractions_command_ICommand_TResult) TResult
        +SendCommand(contextAware IContextAware, command Abstractions_command_ICommand) void
    }

    class ContextAwareQueryExtensions {
        +SendQuery_TResponse(contextAware IContextAware, query Mediator_IQuery_TResponse) TResponse
        +SendQuery_TResult(contextAware IContextAware, query Abstractions_query_IQuery_TResult) TResult
    }

    IContextAware --> IContext
    ContextAwareCommandExtensions ..> IContextAware
    ContextAwareCommandExtensions ..> Mediator_ICommand_TResponse
    ContextAwareCommandExtensions ..> Abstractions_command_ICommand_TResult
    ContextAwareCommandExtensions ..> Abstractions_command_ICommand
    ContextAwareQueryExtensions ..> IContextAware
    ContextAwareQueryExtensions ..> Mediator_IQuery_TResponse
    ContextAwareQueryExtensions ..> Abstractions_query_IQuery_TResult
    IContext ..> Mediator_ICommand_TResponse
    IContext ..> Abstractions_command_ICommand_TResult
    IContext ..> Abstractions_command_ICommand
    IContext ..> Mediator_IQuery_TResponse
    IContext ..> Abstractions_query_IQuery_TResult
Loading

Updated class diagram for context-aware command/query extensions after refactor

classDiagram
    class IContextAware {
        +GetContext() IContext
    }

    class IContext {
        +SendCommand_TResult(command ICommand_TResult) TResult
        +SendCommand(command ICommand) void
        +SendQuery_TResult(query IQuery_TResult) TResult
    }

    class ICommand_TResult {
        <<interface>>
    }

    class ICommand {
        <<interface>>
    }

    class IQuery_TResult {
        <<interface>>
    }

    class ContextAwareCommandExtensions {
        +SendCommand_TResult(contextAware IContextAware, command ICommand_TResult) TResult
        +SendCommand(contextAware IContextAware, command ICommand) void
    }

    class ContextAwareQueryExtensions {
        +SendQuery_TResult(contextAware IContextAware, query IQuery_TResult) TResult
    }

    IContextAware --> IContext
    ContextAwareCommandExtensions ..> IContextAware
    ContextAwareCommandExtensions ..> ICommand_TResult
    ContextAwareCommandExtensions ..> ICommand
    ContextAwareQueryExtensions ..> IContextAware
    ContextAwareQueryExtensions ..> IQuery_TResult
    IContext ..> ICommand_TResult
    IContext ..> ICommand
    IContext ..> IQuery_TResult
Loading

File-Level Changes

Change Details Files
Remove deprecated synchronous Mediator-based SendCommand and SendQuery extension methods that were kept only for compatibility.
  • Delete the legacy ContextAwareCommandExtensions.SendCommand(IContextAware, Mediator.ICommand) overload that forwarded to context.SendCommand
  • Delete the legacy ContextAwareQueryExtensions.SendQuery(IContextAware, Mediator.IQuery) overload that forwarded to context.SendQuery
GFramework.Core/extensions/ContextAwareCommandExtensions.cs
GFramework.Core/extensions/ContextAwareQueryExtensions.cs
Simplify ICommand/IQuery type references to use direct interface names instead of fully qualified namespaces.
  • Update ContextAwareCommandExtensions.SendCommand to accept ICommand instead of Abstractions.command.ICommand
  • Update ContextAwareCommandExtensions.SendCommand to accept ICommand instead of Abstractions.command.ICommand
  • Update ContextAwareQueryExtensions.SendQuery to accept IQuery instead of Abstractions.query.IQuery
GFramework.Core/extensions/ContextAwareCommandExtensions.cs
GFramework.Core/extensions/ContextAwareQueryExtensions.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿,我已经审查了你的更改,看起来非常棒!


Sourcery 对开源项目是免费的——如果你喜欢我们的评审,请考虑帮忙分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续评审。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepsource-io

deepsource-io Bot commented Mar 5, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 71b5831...bb0e072 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Mar 5, 2026 2:47p.m. Review ↗
Secrets Mar 5, 2026 2:47p.m. Review ↗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant