I have the following class.
class Foo { public: Foo(); ~Foo(); void init(); };
I want to change the name of the class to "Bar". The below code does the job but it does not change the constructors and destructors because when I loop through the functions they will not be accessible in the cpp file only in the header file. How should one be able to change "Foo::Foo()" to "Bar::Bar()"?
codeModel = (VCCodeModel)project.CodeModel; foreach (VCCodeNamespace ns in codeModel.Namespaces) { if (ns.DisplayName == "X") { foreach (VCCodeClass c in ns.Classes) { string className = c.Name; c.Name = "Bar"; foreach (VCCodeFunction function in c.Functions) { string file = function.File; EditPoint endPoint = function.EndPoint.CreateEditPoint(); EditPoint startPoint = function.StartPoint.CreateEditPoint(); string text = startPoint.GetText(endPoint); text = text.Replace(className , "Bar"); startPoint.ReplaceText((object)endPoint, text, (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat); } } }
The below code does the job of changing the name of the class but in my cpp file the functions