public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
        {
            var literal = element as ILiteralExpression;

            if (literal != null && literal.ConstantValue.Value is string)
            {
                var agument   = literal.Parent as IVBArgument;
                var attribute = AttributeNavigator.GetByArgument(agument);
                if (attribute != null)
                {
                    var @class = attribute.AttributeType.Reference.Resolve().DeclaredElement as IClass;
                    if (@class != null && Equals(@class.GetClrName(), XunitTestProvider.PropertyDataAttribute))
                    {
                        var typeElement = (from a in attribute.Arguments
                                           where a is INamedArgument && a.ArgumentName == "PropertyType"
                                           select GetTypeof(a.Expression as IGetTypeExpression)).FirstOrDefault();

                        var member = GetAppliedToMethodDeclaration(attribute);
                        if (member != null && member.DeclaredElement != null && typeElement == null)
                        {
                            typeElement = member.DeclaredElement.GetContainingType();
                        }

                        if (typeElement == null)
                        {
                            return(EmptyArray <IReference> .Instance);
                        }

                        var reference = new PropertyDataReference(typeElement, literal);

                        return(oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
                                   ? oldReferences
                                   : new IReference[] { reference });
                    }
                }
            }

            return(EmptyArray <IReference> .Instance);
        }
Пример #2
0
        public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
        {
            var literal = element as ILiteralExpression;

            if (literal != null && literal.ConstantValue.Value is string)
            {
                var attribute = AttributeNavigator.GetByConstructorArgumentExpression(literal as ICSharpExpression);
                if (attribute != null)
                {
                    var @class = attribute.Name.Reference.Resolve().DeclaredElement as IClass;
                    if (@class != null && Equals(@class.GetClrName(), XunitTestProvider.PropertyDataAttribute))
                    {
                        var typeElement = (from a in attribute.PropertyAssignments
                                           where a.PropertyNameIdentifier.Name == "PropertyType"
                                           select GetTypeof(a.Source as ITypeofExpression)).FirstOrDefault();

                        var member = MethodDeclarationNavigator.GetByAttribute(attribute);
                        if (member != null && member.DeclaredElement != null && typeElement == null)
                        {
                            typeElement = member.DeclaredElement.GetContainingType();
                        }

                        if (typeElement == null)
                        {
                            return(EmptyArray <IReference> .Instance);
                        }

                        var reference = new PropertyDataReference(typeElement, literal);

                        return(oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
                                   ? oldReferences
                                   : new IReference[] { reference });
                    }
                }
            }

            return(EmptyArray <IReference> .Instance);
        }