private void Execute(object sender, EventArgs e) { ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // TODO 遅延で取らないとnullになる if ((this.DteObject = (await package.GetServiceAsync(typeof(DTE))) as DTE2) == null) { return; } // ソリューションの情報を引っ張る SolutionNode node = SolutionNode.Create(this.DteObject); var project = node.FindProjectByName(TargetProjectName); if (project == null) { Instance.OutputPane.OutputString($"ProjectName'{ TargetProjectName }' not found\n"); return; } var baseComponentName = "Egliss::Reflection::Reflectable"; var vcClasses = project.RootNode .FindAllOf <ClassNode>(); var baseComponent = vcClasses.Where(m => m.FullName == "global::" + baseComponentName).FirstOrDefault(); if (baseComponent == null) { Instance.OutputPane.OutputString($"the class({baseComponentName}) not found\n"); return; } var components = vcClasses .Where(m => m.VCClass.IsDerivedFrom[baseComponentName]) .ToList(); if (components.Count == 0) { Instance.OutputPane.OutputString($"{baseComponentName}'s child class not found\n"); return; } var tree = TypeDeriverTree.MakeTree(components, baseComponent); var description = TypeDescription .CreateDescription(tree) .Select(m => m.Value) .OrderBy(m => m.Id) .ToList(); var directory = Path.GetDirectoryName(project.Project.FileName); ClassExporter.OutputCppFile(description, $"{directory}\\Sources\\Reflection\\DynamicType.cpp"); ClassExporter.OutputInlineFile(description, $"{directory}\\Sources\\Reflection\\StaticType.inl"); Instance.OutputPane.OutputString($"class export succeed.\n"); }); }