2
我試圖找回在羅斯林一類語法節點的類型,所以我可以用@slaks沿着以下獲得封閉命名空間檢索類型信息回答:Roslyn : How to get the Namespace of a DeclarationSyntax with Roslyn C#無法通過羅斯林
我有以下幾點:
static async Task MainAsync(string[] args)
{
string projectPath = @"C:\Projects\ertp\Ertp.Mobile.csproj";
var msWorkspace = MSBuildWorkspace.Create();
var project = msWorkspace.OpenProjectAsync(projectPath).Result;
foreach (var document in project.Documents)
{
Console.WriteLine(project.Name + "\t\t\t" + document.Name);
SemanticModel model = await document.GetSemanticModelAsync();
var classes = document.GetSyntaxRootAsync().Result.DescendantNodes().OfType<ClassDeclarationSyntax>();
foreach (var klass in classes)
{
var info = model.GetTypeInfo(klass);
var isNull = info.Type == null; //TRUE
}
}
如果我不能獲得類型我不能命名空間 - 任何想法如何檢索我需要的細節?