private void AddExcludeFromCodeCoverageAttributeIfNeeded(IClassDeclaration contractClass) { if (ShouldUseExcludeFromCodeCoverageAttribute()) { var attribute = CreateExcludeFromCodeCoverageAttribute(); contractClass.AddAttributeAfter(attribute, null); } }
public IAttribute AddAttributeAfter(IAttribute param, IAttribute anchor) { return(_classDeclaration.AddAttributeAfter(param, anchor)); }
private void AddContractClassForAttributeTo(IClassDeclaration contractClass) { var attribute = CreateContractClassForAttribute(_addContractForAvailability.TypeDeclaration); contractClass.AddAttributeAfter(attribute, null); }
/// <summary> /// Adds the attribute. /// </summary> /// <param name="solution"> /// The solution. /// </param> /// <param name="classDeclaration"> /// The class declaration. /// </param> /// <param name="factory"> /// The factory. /// </param> private static void AddAttribute(ISolution solution, IClassDeclaration classDeclaration, CSharpElementFactory factory) { var typeName = new CLRTypeName("System.SerializableAttribute"); var scope = DeclarationsScopeFactory.SolutionScope(solution, true); var cache = PsiManager.GetInstance(solution).GetDeclarationsCache(scope, true); var typeElement = cache.GetTypeElementByCLRName(typeName); if (typeElement == null) { return; } var attribute = factory.CreateAttribute(typeElement); classDeclaration.AddAttributeAfter(attribute, null); }