CS0411:使用 TeamCity 构建时无法从用法推断方法 X 的类型参数

发布于 2024-10-04 08:01:17 字数 721 浏览 0 评论 0原文

这是一个漫长的拍摄,但我已经没有自己的想法了。

最近,我的 TeamCity 构建开始向我抛出此错误:

File.cs(行,列):错误CS0411: 方法的类型参数 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' 无法从中推断 的用法。尝试指定类型 明确论证。

但我的代码(或项目配置)没有错误。

如果我使用 Visual Studio (2010) 本身或使用 MSBuild 就像构建代理那样进行编译,它编译得很好。 (即使在构建机器上。)

仅供参考,代码看起来像这样:

 public ISet<Task> Tasks {get; set;}

 public IEnumerable<GradedTask> FindGradedTasks(){  
    return Tasks.Select(GetResult).Where(t=>t.HasResult).ToList(); // error   
 }

 public GradedTask GetResult(Task task) {  
    return new GradedTask(this, task);  
 }

以前有人见过类似的东西吗? 什么可能导致这种行为?

This is a long shoot but I have run out of own ideas.

Recently my TeamCity builds have started to throw this error upon me:

File.cs(Row, Col): error CS0411:
The type arguments for method
'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable,
System.Func)' cannot be inferred from
the usage. Try specifying the type
arguments explicitly.

But there are no errors in my code (or project configuration).

It compiles just fine if I do it either from withing Visual Studio (2010) itself or using MSBuild just as the build agent would do. (Even on the build machine.)

Just for reference, the code looks something like this:

 public ISet<Task> Tasks {get; set;}

 public IEnumerable<GradedTask> FindGradedTasks(){  
    return Tasks.Select(GetResult).Where(t=>t.HasResult).ToList(); // error   
 }

 public GradedTask GetResult(Task task) {  
    return new GradedTask(this, task);  
 }

Anyone seen anything like this before?
What might be causing this behaviour?

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

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

发布评论

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

评论(1

黑色毁心梦 2024-10-11 08:01:17

似乎您正在使用 ISet 接口,但它仅在 .NET 中定义4.0

TeamCity 绝对正确。
这是VS的bug。
我们已经被这个打败了。 Reshaper 不小心引入了可选参数。
VS 编译得很好。
但 TeamCity 不是。

Seems like you are using ISet interface but it is defined only in .NET 4.0

TeamCity is absolutely right.
It is VS bug.
We are has been beaten by this. Accidentally Reshaper introduce Optional argument.
And VS compiles this just fine.
But TeamCity is not.

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