public void SqaleSubCharacteristicAttribute() { var analyzers = new RuleFinder().GetAllAnalyzerTypes(); foreach (var analyzer in analyzers) { var noSqaleCount = analyzer.GetCustomAttributes<NoSqaleRemediationAttribute>().Count(); var subCharacteristicCount = analyzer.GetCustomAttributes<SqaleSubCharacteristicAttribute>().Count(); if (noSqaleCount > 0) { if (subCharacteristicCount > 0) { Assert.Fail( "SqaleSubCharacteristicAttribute can only be assigned to DiagnosticAnalyzers that have a SQALE " + "remediation function, '{0}' has NoSqaleRemediationAttribute", analyzer.Name); } } else { if (subCharacteristicCount != 1) { Assert.Fail( "Only one SqaleSubCharacteristicAttribute can be assigned to DiagnosticAnalyzers, '{0}' has {1}", analyzer.Name, subCharacteristicCount); } } } }
public void SingleSqaleRemediationAttribute() { var analyzers = new RuleFinder().GetAllAnalyzerTypes(); foreach (var analyzer in analyzers) { var count = analyzer.GetCustomAttributes<SqaleRemediationAttribute>().Count(); if (count != 1) { Assert.Fail("Only one SqaleRemediationAttribute can be assigned to DiagnosticAnalyzers, '{0}' has {1}", analyzer.Name, count); } } }