Moles 是否会向附加到部分类的 Moletypes 添加 01、02 等?

发布于 2024-10-06 02:07:32 字数 269 浏览 0 评论 0原文

我用 Moles 来嘲笑。有一天,我构建了一个 Moles 程序集作为参考,其中包含许多部分类。生成的 Moles 程序集似乎有两个类,它们是从一个类构建出来的:

FileSendDataAccess

变成

MFileSendDataAccess  MFileSendDataAccess01

这是设计使然还是错误?这非常令人困惑,因为我现在有两个类可用于访问一个类。使用摩尔 0.93。

I'm using Moles for mocking. The other day I built a Moles assembly for a reference that has many partial classes in it. The generated Moles assembly seems to have two classes that are built out of the one class:

FileSendDataAccess

becomes

MFileSendDataAccess  MFileSendDataAccess01

Is this by design or a bug? It's very confusing since I now have two classes to use to access the one class. Using Moles 0.93.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻想少年梦 2024-10-13 02:07:32

根据 Peli 的说法,答案是:当引用中存在两个具有相同名称的类时,Moles 会将 01 等添加到类名中。

部分类是一种语法糖,
C# 生成它们的一种类型。
当名称之间存在冲突时,鼹鼠会在[原文如此]类型名称中添加数字
类型。
也许您的文件中有 2 个 FileSendDataAccess 类型
集会?您可以使用
反射器可以轻松找到。

但是:如果类具有相同的名称但不同的命名空间,它们仍然会得到 01 02 的内容。 这是一个错误,截至 0.94 版本仍然存在。

The answer, according to Peli: Moles will add 01 etc to a class name when there are two classes in your references that have the same name.

Partial classes are a syntatic sugar,
C# generates a type of them.
Moles adds numbers ot [sic] type names when there are name clashing between
types.
Maybe you have 2 FileSendDataAccess type in your
assembly? You can use
Reflector to easily find out.

However: if the classes have the same name but different namespaces they will still get the 01 02 stuff. This is a bug that is still happening as of 0.94.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文