private void ParseRange(PlatformAttribute attribute, string stackTrace)
        {
            Start = new SourceRange(attribute.StartLine, attribute.StartOffset);
            string assertLocation = ExtractLineAndColumnData(stackTrace);

            End = new SourceRange(ParseLineNumber(assertLocation), ParseColumnNumber(assertLocation));
        }
		public ArrowDescription(PlatformAttribute attribute,
			Method method,
			TestResult result,
			MessageLimiter textConditioner)
		{
			ParseRange(attribute, result.StackTrace);
			ParseMessage(result.Message, textConditioner);
			Test = method;
		}
 public ArrowDescription(PlatformAttribute attribute,
                         Method method,
                         TestResult result,
                         MessageLimiter textConditioner)
 {
     ParseRange(attribute, result.StackTrace);
     ParseMessage(result.Message, textConditioner);
     Test = method;
 }
示例#4
0
        private static AssignmentExpression GetTheArg(DevExpress.CodeRush.StructuralParser.Attribute AttributeFact)
        {
            AssignmentExpression TheArg        = null;
            ExpressionCollection factArguments = AttributeFact.Arguments;
            AssignmentExpression Arg           = factArguments[0] as AssignmentExpression;

            if (Arg.LeftSide.Name.ToLower() == "DisplayName".ToLower())
            {
                TheArg = Arg;
            }
            return(TheArg);
        }
示例#5
0
 private void CreateAttributeShadeAdornment(DecorateLanguageElementEventArgs args,
                                            DevExpress.CodeRush.StructuralParser.Attribute attribute,
                                            Method target,
                                            TestStatus status)
 {
     if (ShadeAttribute && status != TestStatus.Pending && status != TestStatus.PassedWithChanges && status != TestStatus.FailedWithChanges)
     {
         SourceRange shadedArea = new SourceRange(
             attribute.Parent.Range.Start,
             new SourcePoint(attribute.Range.End.Line, target.NameRange.End.Offset - 1));
         args.AddAdornment(new TestAttributeShaderAdornmentDocumentAdornment(shadedArea, status, AttributeColors));
     }
 }
示例#6
0
        public string GetAssociationName()
        {
            Attribute attribute = property.FindAttribute(typeof(AssociationAttribute));

            if (attribute.ArgumentCount > 0)
            {
                var expression = attribute.Arguments[0] as PrimitiveExpression;
                if (expression != null && expression.IsStringLiteral && expression.TestValue is string)
                {
                    return(expression.TestValue.ToString());
                }
            }
            return(null);
        }
示例#7
0
 private void CreateErrorArrowAdornment(DecorateLanguageElementEventArgs args,
                                        DevExpress.CodeRush.StructuralParser.Attribute attribute,
                                        Method target,
                                        TestMethod test)
 {
     if (test.Status == TestStatus.Failure && DrawArrowToAssert)
     {
         ArrowDescription visibleArrow = new ArrowDescription(
             attribute,
             target,
             test.TestResults[0],
             new MessageLimiter(ShortenLongStrings, MaxContextLength, ConvertEscapeCharacters));
         args.AddAdornment(
             new FailedTestInspectorDocumentAdornment(
                 new DocPoint(attribute.StartLine, attribute.StartOffset),
                 new DocPoint(visibleArrow.End.Start.Line, visibleArrow.End.Start.Offset),
                 this,
                 visibleArrow));
     }
 }
示例#8
0
        private void PlugIn1_DecorateLanguageElement(object sender, DecorateLanguageElementEventArgs args)
        {
            LanguageElement element = args.LanguageElement;

            if (element.ElementType == LanguageElementType.Attribute)
            {
                DevExpress.CodeRush.StructuralParser.Attribute attribute = (DevExpress.CodeRush.StructuralParser.Attribute)element;
                if (attribute.TargetNode.ElementType == LanguageElementType.Method)
                {
                    Method target = (Method)attribute.TargetNode;
                    TestMethodCollection tests = CodeRush.UnitTests.Tests;
                    foreach (TestMethod test in tests)
                    {
                        if (target.Location == test.FullName)
                        {
                            CreateErrorArrowAdornment(args, attribute, target, test);
                            CreateAttributeShadeAdornment(args, attribute, target, test.Status);
                            //OverlayErrorNextToAssert(ea, test);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Adds the linking attribute.
        /// </summary>
        /// <param name="contractClass">The contract class.</param>
        private void AddLinkingAttribute(Class contractClass)
        {
            Contract.Requires(contractClass != null, "contractClass must not be null.");

            var typeOfExp = new TypeOfExpression(new TypeReferenceExpression(this.InterfaceName));
            var attribute = new CustomAttribute()
            {
                Name = ContractClassFor
            };

            if (attribute.Arguments != null)
            {
                attribute.Arguments.Add(typeOfExp);
            }

            var section = new AttributeSection();

            if (section.AttributeCollection != null)
            {
                section.AttributeCollection.Add(attribute);
            }

            contractClass.AddAttributeSection(section);
        }
		private void ParseRange(PlatformAttribute attribute, string stackTrace)
		{
			Start = new SourceRange(attribute.StartLine, attribute.StartOffset);
			string assertLocation = ExtractLineAndColumnData(stackTrace);
			End = new SourceRange(ParseLineNumber(assertLocation), ParseColumnNumber(assertLocation));
		}
    /// <summary>
    /// Adds the linking attribute.
    /// </summary>
    /// <param name="contractClass">The contract class.</param>
    private void AddLinkingAttribute(Class contractClass)
    {
      Contract.Requires(contractClass != null, "contractClass must not be null.");

      var typeOfExp = new TypeOfExpression(new TypeReferenceExpression(this.InterfaceName));
      var attribute = new CustomAttribute() { Name = ContractClassFor };
      if (attribute.Arguments != null)
      {
        attribute.Arguments.Add(typeOfExp);
      }

      var section = new AttributeSection();
      if (section.AttributeCollection != null)
      {
        section.AttributeCollection.Add(attribute);
      }

      contractClass.AddAttributeSection(section);
    }