string sln = path;
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
Solution solution = workspace.OpenSolutionAsync(sln).Result;
foreach (Project pro in solution.Projects)
{
foreach (Document documents in pro.Documents)
{
SyntaxNode rootNode = documents.GetSyntaxRootAsync().Result;
SemanticModel semanticModel = documents.GetSemanticModelAsync().Result;
IEnumerable<ClassDeclarationSyntax> myClasses = rootNode.DescendantNodes().OfType<ClassDeclarationSyntax>();
string pfad = documents.FilePath; .....
What I want to do is load a solution and its projects and the documents inside those projects then I want to get the path of those files. First 2 work but there are no documents being loaded. When executing this code, the second foreach is just being skipped completely. Debugging shows that documents is null.
I've seen other projects use this type of code but it doesn't work and I have no reason why. The dots mean there is more code but that part does actually work so I just cut it out. If someone has a clue, can you please add on to my code? Much appreciated!