Ejemplo n.º 1
0
        /// <summary>Annotates the specified tree node.</summary>
        /// <param name="treeNode">The tree node.</param>
        /// <param name="attribute">The attribute.</param>
        public static void Annotate(this ITreeNode treeNode, CodeAnnotationAttribute attribute)
        {
            var owner = treeNode as IAttributesOwnerDeclaration;

            if (owner == null)
            {
                return;
            }

            string attributeName;

            switch (attribute)
            {
            case CodeAnnotationAttribute.NotNull:
                attributeName = CodeAnnotationsCache.NotNullAttributeShortName;
                break;

            case CodeAnnotationAttribute.CanBeNull:
                attributeName = CodeAnnotationsCache.CanBeNullAttributeShortName;
                break;

            default:
                return;
            }

            AttributesHelper.SetAttribute(owner, attributeName);
        }
Ejemplo n.º 2
0
 /// <summary>Initializes a new instance of the <see cref="ParameterDescriptor"/> class.</summary>
 /// <param name="expectedAttribute">The expected attribute.</param>
 /// <param name="appliedAttribute">The applied attribute.</param>
 /// <param name="expectsAssertion">if set to <c>true</c> [expects assertion].</param>
 /// <param name="assertionCode">The assertion code.</param>
 public ParameterDescriptor(CodeAnnotationAttribute expectedAttribute, CodeAnnotationAttribute appliedAttribute, bool expectsAssertion, [NotNull] string assertionCode)
 {
     this.ExpectedAttribute = expectedAttribute;
     this.AppliedAttribute  = appliedAttribute;
     this.ExpectsAssertion  = expectsAssertion;
     this.Code = assertionCode;
 }
 /// <summary>Initializes a new instance of the <see cref="ParameterDescriptor"/> class.</summary>
 /// <param name="expectedAttribute">The expected attribute.</param>
 /// <param name="appliedAttribute">The applied attribute.</param>
 /// <param name="expectsAssertion">if set to <c>true</c> [expects assertion].</param>
 /// <param name="assertionCode">The assertion code.</param>
 public ParameterDescriptor(CodeAnnotationAttribute expectedAttribute, CodeAnnotationAttribute appliedAttribute, bool expectsAssertion, [NotNull] string assertionCode)
 {
   this.ExpectedAttribute = expectedAttribute;
   this.AppliedAttribute = appliedAttribute;
   this.ExpectsAssertion = expectsAssertion;
   this.Code = assertionCode;
 }
Ejemplo n.º 4
0
        /// <summary>Initializes a new instance of the <see cref="ParameterDescriptor"/> class.</summary>
        /// <param name="parameter">The parameter.</param>
        /// <param name="expectedAttribute">The expected attribute.</param>
        /// <param name="appliedAttribute">The applied attribute.</param>
        /// <param name="expectsAssertion">if set to <c>true</c> [expects assertion].</param>
        /// <param name="assertionCode">The assertion code.</param>
        public ParameterDescriptor([NotNull] IParameterDeclaration parameter, CodeAnnotationAttribute expectedAttribute, CodeAnnotationAttribute appliedAttribute, bool expectsAssertion, [NotNull] string assertionCode)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            this.Parameter         = parameter;
            this.ExpectedAttribute = expectedAttribute;
            this.AppliedAttribute  = appliedAttribute;
            this.ExpectsAssertion  = expectsAssertion;
            this.Code = assertionCode;
        }
    /// <summary>Initializes a new instance of the <see cref="ParameterDescriptor"/> class.</summary>
    /// <param name="parameter">The parameter.</param>
    /// <param name="expectedAttribute">The expected attribute.</param>
    /// <param name="appliedAttribute">The applied attribute.</param>
    /// <param name="expectsAssertion">if set to <c>true</c> [expects assertion].</param>
    /// <param name="assertionCode">The assertion code.</param>
    public ParameterDescriptor([NotNull] IParameterDeclaration parameter, CodeAnnotationAttribute expectedAttribute, CodeAnnotationAttribute appliedAttribute, bool expectsAssertion, [NotNull] string assertionCode)
    {
      if (parameter == null)
      {
        throw new ArgumentNullException("parameter");
      }

      this.Parameter = parameter;
      this.ExpectedAttribute = expectedAttribute;
      this.AppliedAttribute = appliedAttribute;
      this.ExpectsAssertion = expectsAssertion;
      this.Code = assertionCode;
    }
    /// <summary>Annotates the specified tree node.</summary>
    /// <param name="treeNode">The tree node.</param>
    /// <param name="attribute">The attribute.</param>
    public static void Annotate(this ITreeNode treeNode, CodeAnnotationAttribute attribute)
    {
      var owner = treeNode as IAttributesOwnerDeclaration;
      if (owner == null)
      {
        return;
      }

      string attributeName;
      switch (attribute)
      {
        case CodeAnnotationAttribute.NotNull:
          attributeName = CodeAnnotationsCache.NotNullAttributeShortName;
          break;
        case CodeAnnotationAttribute.CanBeNull:
          attributeName = CodeAnnotationsCache.CanBeNullAttributeShortName;
          break;
        default:
          return;
      }

      AttributesHelper.SetAttribute(owner, attributeName);
    }