如何知道 <T> 类? Intellisense 有没有办法自动完成 <T>?

问题描述

我一直在使用名为 NEZ 的 2d 引擎。它们使用附加到实体的称为“组件”的类对象列表。 Component一个可以继承的公共类。

比如说:

public class Ninja : Component

这是代码

/// <summary>
/// Adds a Component to the components list. Returns the Component.
/// </summary>
/// <returns>Scene.</returns>
/// <param name="component">Component.</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public T AddComponent<T>(T component) where T : Component
{
    component.Entity = this;
    Components.Add(component);
    component.Initialize();
    return component;
}

/// <summary>
/// Adds a Component to the components list. Returns the Component.
/// </summary>
/// <returns>Scene.</returns>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public T AddComponent<T>() where T : Component,new()
{
    var component = new T();
    component.Entity = this;
    Components.Add(component);
    component.Initialize();
    return component;
}

所以令人讨厌的是 Visual Studio 没有给我一个包含 Component 的类对象列表。

那么,我怎么知道 _animator = Entity.AddComponent<SpriteAnimator>();Component

除了我必须查看每个 .CS 文件并查看它们是否继承 Component 类的显而易见的答案。

问题是:<T> 中的对象不会自动完成,或者甚至没有给我一个可能的项目来填补空白。

IntelliSense 是否可以搜索每个继承类 Component 的对象?

如果没有,您是否知道其他 IDE 或智能工具(如 Resharper)是否可以完成这项工作?

我正在使用带有 Roslynator Refactorings 插件的 Visual Studio 2019 以及来自 Tomatoes Software 的 Visual Assistance。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...