我从ReSharper收到了这条信息。在检查代码后,ReSharper没有提出我认为适当的更改建议。因此,我担心问题可能是我没有理解正在发生的事情,而不是ReSharper不能像它本可以一样有帮助。
public interface IFrobable { }
public class DataClass
{
public List<IFrobable> Frobables {get; set;}
//...
}
public class WorkerClass
{
//...
void Frobinate(List<IFrobable> frobables)
{
//Frobs the input
}
void DoSomething(List<IFrobable> input>)
{
//Original code with Resharper on OfType<IActivity>
Frobinate(input.OfType<IFrobable>().ToList());
//Suggested change from ReSharper - Is this a generic refactor
//instead of issue specific?
Frobinate(Enumerable.OfType<IFrobable>(input).ToList());
//What I think should be safe to do - compiles and appears to work
Frobinate(input);
}
}
有没有什么原因导致我的修改可能不安全。
public interface IFrobableEx:IFrobable
),而其中一位开发人员热衷于显式转换。 - Dan Is Fiddling By Firelight