예제 #1
0
        protected override IEnumerable <Diagnostic> Analyze(IFieldSymbol symbol)
        {
            var invocation = symbol.Name + ".DependencyProperty";

            // get fields in same class that are of Type "DependencyProperty" and find out if any gets assigned to the "DependencyProperty" of the "DependencyPropertyKey"
            // hint: names should match
            var owingType = symbol.FindContainingType();

            var dependencyProperties = owingType.GetMembers().OfType <IFieldSymbol>().Where(_ => _.Type.IsDependencyProperty());

            return(dependencyProperties.Any(_ => _.GetAssignmentsVia(invocation).Any())
                       ? Enumerable.Empty <Diagnostic>()
                       : new[] { ReportIssue(symbol) });
        }