private static IEnumerable <IFieldSymbol> GetFieldsWithAttribute() { return(RoslynHelper.GetSyntaxNodes <FieldDeclarationSyntax>() .SelectMany(fds => fds.Declaration.Variables) .Select(vds => (IFieldSymbol)vds.GetDeclaredSymbol()) .Where(field => field.HasAttribute(nameof(ReadWriteForEfficiencyAttribute)))); }
public void NoAssignmentsOutsideConstructors() { var badAssignments = from aes in RoslynHelper.GetSyntaxNodes <AssignmentExpressionSyntax>() let target = aes.Left.GetSymbol() where target.HasAttribute(nameof(ReadWriteForEfficiencyAttribute)) where (aes.GetEnclosingSymbol() as IMethodSymbol).MethodKind != MethodKind.Constructor select aes; Assert.IsEmpty(badAssignments.ToList()); }