私は、ユーザーがダイアログに入力する一連のオプションと組み合わせたメソッドシグネチャを確認することにより、データアクセスコードを生成するVisualStudio2008アドインに取り組んでいます。
メソッドシグネチャを分析するために、Visual StudioのITypeResolutionServiceを使用して、現在のプロジェクト、参照されているプロジェクト、または参照されているアセンブリのいずれかに存在する型を検索します。
このために、次の機能を作成しました。
private ITypeResolutionService _typeResolutionService;
private ITypeDiscoveryService _typeDiscoveryService;
/// <summary>
/// Initializes a new instance of the TypeResolver class.
/// </summary>
public TypeResolver(VisualStudioServiceProvider serviceProvider, Project project)
{
IVsSolution solution = serviceProvider.GetService<IVsSolution>();
DynamicTypeService typeResolver = serviceProvider.GetService<DynamicTypeService>();
IVsHierarchy hierarchy = null;
solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy);
_typeResolutionService = typeResolver.GetTypeResolutionService(hierarchy);
_typeDiscoveryService = typeResolver.GetTypeDiscoveryService(hierarchy);
}
/// <summary>
/// Resolves a type in the current solution
/// </summary>
/// <param name="name">Name of the type to resolve</param>
/// <returns>Returns the resolved type; otherwise null</returns>
public Type Resolve(string name)
{
return _typeResolutionService.GetType(name, true);
}
非ジェネリック型は解決しますが、残念ながらジェネリック型では機能しません。上記のスニペットをジェネリック型でも機能させる方法について誰かが考えていますか?