protected void AddAtribute(IClass @class) { if (ExistsSerializableAttribute(@class)) return; ISolution solution = @class.GetManager().Solution; IDeclaration declaration = @class.GetDeclarations()[0]; IMetaInfoTargetDeclarationNode metaInfoTargetDeclarationNode = declaration.ToTreeNode() as IMetaInfoTargetDeclarationNode; Assert.CheckNotNull(metaInfoTargetDeclarationNode); CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(@class.GetManager().Solution); IAttribute serializableAttribute = elementFactory.CreateTypeMemberDeclaration("[Serializable]void Foo(){}").Attributes[0]; IAttribute added = metaInfoTargetDeclarationNode.AddAttributeAfter(serializableAttribute, null); ICSharpTypeAndNamespaceHolderDeclaration scope = declaration.GetContainingElement<ICSharpNamespaceDeclaration>(false); ICSharpFile fileScope = (ICSharpFile)declaration.GetContainingFile(); if (scope == null) scope = fileScope; if(!UsingUtil.CheckAlreadyImported(scope, PsiManager.GetInstance(solution).GetNamespace(SYSTEM))) { IUsingDirective directive = CSharpElementFactory.GetInstance(solution).CreateUsingDirective(SYSTEM, new object[0]); // add to header usings list UsingUtil.AddImportTo(fileScope, directive); } }