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)
{
}
}
}
}
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 x++ 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.