Пример #1
0
 public override void VisitAnnotation(AnnotationSyntax node)
 {
     if (node.Parameters != null)
     {
         AppendIndentedLine("@{0}({1})", node.Identifier, node.Parameters);
     }
     else
     {
         AppendIndentedLine("@{0}", node.Identifier);
     }
 }
Пример #2
0
        public void ApexTestAnnotationsConvertedToNUnitAttributes()
        {
            var annotation = new AnnotationSyntax {
                Identifier = ApexKeywords.IsTest
            };
            var attribute = CSharpCodeGenerator.ConvertUnitTestAnnotation(annotation, new ClassDeclarationSyntax());

            Assert.AreEqual("TestFixture", attribute.Identifier);

            attribute = CSharpCodeGenerator.ConvertUnitTestAnnotation(annotation, new MethodDeclarationSyntax());
            Assert.AreEqual("Test", attribute.Identifier);
        }
Пример #3
0
        internal static AnnotationSyntax ConvertUnitTestAnnotation(AnnotationSyntax node, BaseSyntax parentNode)
        {
            // TODO: refactor this method out of CSharpCodeGenerator
            if (!node.IsTest)
            {
                return(node);
            }

            if (parentNode is ClassDeclarationSyntax)
            {
                // IsTest => TestFixture
                if (string.Equals(node.Identifier, ApexKeywords.IsTest, StringComparison.OrdinalIgnoreCase))
                {
                    return(new AnnotationSyntax
                    {
                        LeadingComments = node.LeadingComments,
                        Identifier = "TestFixture",
                        Parameters = node.Parameters,
                        TrailingComments = node.TrailingComments,
                    });
                }
            }
            else if (parentNode is MethodDeclarationSyntax)
            {
                // IsTest => Test
                if (string.Equals(node.Identifier, ApexKeywords.IsTest, StringComparison.OrdinalIgnoreCase))
                {
                    return(new AnnotationSyntax
                    {
                        LeadingComments = node.LeadingComments,
                        Identifier = "Test",
                        Parameters = node.Parameters,
                        TrailingComments = node.TrailingComments,
                    });
                }

                // TestSetup => SetUp
                else if (string.Equals(node.Identifier, ApexKeywords.TestSetup, StringComparison.OrdinalIgnoreCase))
                {
                    return(new AnnotationSyntax
                    {
                        LeadingComments = node.LeadingComments,
                        Identifier = "SetUp",
                        Parameters = node.Parameters,
                        TrailingComments = node.TrailingComments,
                    });
                }
            }

            return(node);
        }
Пример #4
0
        public override void VisitAnnotation(AnnotationSyntax node)
        {
            var attribute = ConvertUnitTestAnnotation(node, CurrentMember);

            if (string.IsNullOrWhiteSpace(attribute.Parameters))
            {
                AppendIndentedLine("[{0}]", attribute.Identifier);
            }
            else
            {
                // make sure parameters are comma-separated
                var parameters = GenericExpressionHelper.ConvertApexAnnotationParametersToCSharp(attribute.Parameters);
                parameters = parameters.Replace("\'", "\"");
                AppendIndentedLine("[{0}({1})]", attribute.Identifier, parameters);
            }
        }
 public virtual void VisitAnnotation(AnnotationSyntax node)
 {
     this.BeginProperty("Annotations");
     try
     {
         this.BeginDeclaration(typeof(Symbols.Annotation), node);
         try
         {
             this.Visit(node.AnnotationHead);
         }
         finally
         {
             this.EndDeclaration();
         }
     }
     finally
     {
         this.EndProperty();
     }
 }
Пример #6
0
 public virtual void VisitAnnotation(AnnotationSyntax node) => DefaultVisit(node);