Why EnvDTE.ProjectItem.FileCodeModel is Null on Dynamics 365 in VS 2017 project

123 Views Asked by At

I am writing code to get the CodeElements from .xpp file in D365 project, but FileCodeModel value is always null

foreach (Project project in applicationObject.Solution.Projects)
 {
                        var projectItems = GetProjectItemsRecursively(project.ProjectItems);
                        foreach (ProjectItem item in projectItems)
                        {
                            if ((item.FileCodeModel != null))
                            {
                                
                                foreach (CodeElement elem in item.FileCodeModel.CodeElements)
                                {
                                    
                                }
                            }

                        }
                    }
1

There are 1 best solutions below

0
FH-Inway On

According to the documentation for ProjectItem.FileCodeModel, "A FileCodeModel object is returned only for project items that are code files and in projects that implement the Visual Studio code model."

Since is a very distant cousin of the .NET family, my guess would be that its files (.xml files that combine code and metadata) are not recognized as code files and/or the D365FO projects do not implement the VS code model.