protected override bool ShallAnalyze(IFieldSymbol symbol) { if (symbol.Type.IsDependencyProperty() is false) { return(false); } // ignore attached properties var attachedProperties = symbol.GetAssignmentsVia(Constants.Invocations.DependencyProperty.RegisterAttached).Any(); if (attachedProperties) { return(false); } // ignore "Key.DependencyProperty" assignments var keys = symbol.ContainingType.GetMembers().OfType <IFieldSymbol>().Where(_ => _.Type.IsDependencyPropertyKey()).Select(_ => _.Name + ".DependencyProperty").ToHashSet(); foreach (var key in keys) { if (symbol.GetAssignmentsVia(key).Any()) { return(false); } } return(true); }
protected override bool ShallAnalyze(IFieldSymbol symbol) => symbol.Type.IsDependencyPropertyKey() && symbol.GetAssignmentsVia(Constants.Invocations.DependencyProperty.RegisterAttachedReadOnly).None();
internal static SeparatedSyntaxList <ArgumentSyntax> GetInvocationArgumentsFrom(this IFieldSymbol value, string invocation) => value.GetAssignmentsVia(invocation) .Select(_ => _.GetEnclosing <InvocationExpressionSyntax>()) .Select(_ => _.ArgumentList) .Where(_ => _ != null) .Select(_ => _.Arguments) .FirstOrDefault(_ => _.Count > 0);