Hi, i'm trying to add content to new file, but it doesn't works:
var file = AddNewItemUtil.AddFile(folder, fileName);
var psiFile = file.GetPrimaryPsiFile();
var elementFactory = CSharpElementFactory.GetInstance(psiFile.GetPsiModule());
elementFactory.CreateTypeMemberDeclaration("public void SomeMethod(){}");
also, I tried to use the return value from file.ToSourceFile() method as psiFile, and creating declaration inside transaction — psiFile.GetPsiServices().Transactions.
Please, tell me what am I doing wrong?
P.S. I have another question about better approach how to find class in projects:
var symbols = solution.GetPsiServices().Symbols.GetSymbolScope(LibrarySymbolScope.NONE, false);
return symbols.GetElementsByQualifiedName(className).ToArray();
my current solution seems wrong to me, though it works :-). Maybe there is better way to do it easier?
Thanks.