Exemplo n.º 1
0
        public void TypeSyntax_GenericNameSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = SyntaxFactory.ParseName("a<,>");
            var xElement = converter.Visit(node);

            Assert.AreEqual("<GenericName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"4\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"Identifier\">a</Token>" +
                            "<TypeArgumentList startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"4\" part=\"TypeArgumentList\">" +
                            "<Token kind=\"LessThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"2\" part=\"LessThanToken\">&lt;</Token>" +
                            "<SeparatedList_of_Type part=\"Arguments\">" +
                            "<OmittedTypeArgument>" +
                            "<Token kind=\"OmittedTypeArgumentToken\" part=\"OmittedTypeArgumentToken\"></Token>" +
                            "</OmittedTypeArgument>" +
                            "<OmittedTypeArgument>" +
                            "<Token kind=\"OmittedTypeArgumentToken\" part=\"OmittedTypeArgumentToken\"></Token>" +
                            "</OmittedTypeArgument>" +
                            "</SeparatedList_of_Type>" +
                            "<Token kind=\"GreaterThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"4\" part=\"GreaterThanToken\">&gt;</Token>" +
                            "</TypeArgumentList>" +
                            "</GenericName>", xElement.ToString(SaveOptions.DisableFormatting));

            node     = SyntaxFactory.ParseName("a<x,t>");
            xElement = converter.Visit(node);
            Assert.AreEqual("<GenericName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"6\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"Identifier\">a</Token>" +
                            "<TypeArgumentList startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"6\" part=\"TypeArgumentList\">" +
                            "<Token kind=\"LessThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"2\" part=\"LessThanToken\">&lt;</Token>" +
                            "<SeparatedList_of_Type part=\"Arguments\">" +
                            "<IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"3\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"3\" part=\"Identifier\">x</Token>" +
                            "</IdentifierName>" +
                            "<IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\" part=\"Identifier\">t</Token>" +
                            "</IdentifierName>" +
                            "</SeparatedList_of_Type>" +
                            "<Token kind=\"GreaterThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"GreaterThanToken\">&gt;</Token>" +
                            "</TypeArgumentList>" +
                            "</GenericName>", xElement.ToString(SaveOptions.DisableFormatting));

            node     = SyntaxFactory.ParseName("a<x,>");
            xElement = converter.Visit(node);
            Assert.AreEqual("<GenericName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"5\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"Identifier\">a</Token>" +
                            "<TypeArgumentList startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"5\" part=\"TypeArgumentList\">" +
                            "<Token kind=\"LessThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"2\" part=\"LessThanToken\">&lt;</Token>" +
                            "<SeparatedList_of_Type part=\"Arguments\">" +
                            "<IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"3\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"3\" part=\"Identifier\">x</Token>" +
                            "</IdentifierName>" +
                            "<IdentifierName Name=\"true\" TypeSyntax=\"true\">" +
                            "<Token kind=\"IdentifierToken\" part=\"Identifier\"></Token>" +
                            "</IdentifierName>" +
                            "</SeparatedList_of_Type>" +
                            "<Token kind=\"GreaterThanToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\" part=\"GreaterThanToken\">&gt;</Token>" +
                            "</TypeArgumentList>" +
                            "</GenericName>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 2
0
        public void DeclarationPatternSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = (SwitchStatementSyntax)SyntaxFactory.ParseStatement("switch(obj){ case Shape s: }");
            var xElement  = converter.Visit(((CasePatternSwitchLabelSyntax)node.Sections[0].Labels[0]).Pattern);

            Assert.AreEqual("<DeclarationPattern startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"25\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"23\" part=\"Type\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"23\" part=\"Identifier\">Shape</Token></IdentifierName><SingleVariableDesignation startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Designation\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Identifier\">s</Token></SingleVariableDesignation></DeclarationPattern>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 3
0
        public void ForEachVariableStatementSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseStatement("foreach(var (a,b) in x){}");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<ForEachVariableStatement startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"25\"><Token kind=\"ForEachKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"7\" part=\"ForEachKeyword\">foreach</Token><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"OpenParenToken\">(</Token><DeclarationExpression startLine=\"1\" startColumn=\"9\" endLine=\"1\" endColumn=\"17\" part=\"Variable\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"9\" endLine=\"1\" endColumn=\"11\" part=\"Type\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"9\" endLine=\"1\" endColumn=\"11\" part=\"Identifier\">var</Token></IdentifierName><ParenthesizedVariableDesignation startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"17\" part=\"Designation\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"13\" part=\"OpenParenToken\">(</Token><SeparatedList_of_VariableDesignation part=\"Variables\"><SingleVariableDesignation startLine=\"1\" startColumn=\"14\" endLine=\"1\" endColumn=\"14\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"14\" endLine=\"1\" endColumn=\"14\" part=\"Identifier\">a</Token></SingleVariableDesignation><SingleVariableDesignation startLine=\"1\" startColumn=\"16\" endLine=\"1\" endColumn=\"16\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"16\" endLine=\"1\" endColumn=\"16\" part=\"Identifier\">b</Token></SingleVariableDesignation></SeparatedList_of_VariableDesignation><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"17\" endLine=\"1\" endColumn=\"17\" part=\"CloseParenToken\">)</Token></ParenthesizedVariableDesignation></DeclarationExpression><Token kind=\"InKeyword\" Keyword=\"true\" TypeParameterVariance=\"true\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"20\" part=\"InKeyword\">in</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"22\" endLine=\"1\" endColumn=\"22\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"22\" endLine=\"1\" endColumn=\"22\" part=\"Identifier\">x</Token></IdentifierName><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"CloseParenToken\">)</Token><Block startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"25\" part=\"Statement\"><Token kind=\"OpenBraceToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"24\" part=\"OpenBraceToken\">{</Token><Token kind=\"CloseBraceToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"CloseBraceToken\">}</Token></Block></ForEachVariableStatement>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 4
0
        public void IsPatternExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseExpression("obj is A a");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<IsPatternExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"10\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"Identifier\">obj</Token></IdentifierName><Token kind=\"IsKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"6\" part=\"IsKeyword\">is</Token><DeclarationPattern startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"10\" part=\"Pattern\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Type\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Identifier\">A</Token></IdentifierName><SingleVariableDesignation startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"10\" part=\"Designation\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"10\" part=\"Identifier\">a</Token></SingleVariableDesignation></DeclarationPattern></IsPatternExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 5
0
        public void DeclarationExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = (TupleExpressionSyntax)SyntaxFactory.ParseExpression("(int a, int b)");
            var xElement  = converter.Visit(node.Arguments[0].Expression);

            Assert.AreEqual("<DeclarationExpression startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"6\"><PredefinedType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"4\" part=\"Type\"><Token kind=\"IntKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"4\" part=\"Keyword\">int</Token></PredefinedType><SingleVariableDesignation startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"Designation\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"Identifier\">a</Token></SingleVariableDesignation></DeclarationExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 6
0
        public void RefExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.RefExpression(SyntaxFactory.Token(SyntaxKind.RefKeyword), SyntaxFactory.ParseExpression("s + d"));
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<RefExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"8\"><Token kind=\"RefKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"RefKeyword\">ref</Token><BinaryExpression kind=\"AddExpression\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"8\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"4\" part=\"Left\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"4\" part=\"Identifier\">s</Token></IdentifierName><Token kind=\"PlusToken\" Operator=\"true\" startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"OperatorToken\">+</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Right\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Identifier\">d</Token></IdentifierName></BinaryExpression></RefExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void AttributeSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("[module: XAttribute(\"X\", Y: 3, Z= 4)]").AttributeLists[0].Attributes[0];
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<Attribute startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"36\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"19\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"19\" part=\"Identifier\">XAttribute</Token></IdentifierName><AttributeArgumentList startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"36\" part=\"ArgumentList\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"20\" part=\"OpenParenToken\">(</Token><SeparatedList_of_AttributeArgument part=\"Arguments\"><AttributeArgument startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\"><LiteralExpression kind=\"StringLiteralExpression\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"StringLiteralToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Token\">X</Token></LiteralExpression></AttributeArgument><AttributeArgument startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"29\"><NameColon startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"27\" part=\"NameColon\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"26\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"26\" part=\"Identifier\">Y</Token></IdentifierName><Token kind=\"ColonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"27\" part=\"ColonToken\">:</Token></NameColon><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"29\" endLine=\"1\" endColumn=\"29\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"29\" endLine=\"1\" endColumn=\"29\" part=\"Token\">3</Token></LiteralExpression></AttributeArgument><AttributeArgument startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"35\"><NameEquals startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"33\" part=\"NameEquals\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Identifier\">Z</Token></IdentifierName><Token kind=\"EqualsToken\" Operator=\"true\" startLine=\"1\" startColumn=\"33\" endLine=\"1\" endColumn=\"33\" part=\"EqualsToken\">=</Token></NameEquals><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"35\" endLine=\"1\" endColumn=\"35\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"35\" endLine=\"1\" endColumn=\"35\" part=\"Token\">4</Token></LiteralExpression></AttributeArgument></SeparatedList_of_AttributeArgument><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"36\" endLine=\"1\" endColumn=\"36\" part=\"CloseParenToken\">)</Token></AttributeArgumentList></Attribute>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void AttributeArgumentSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("[module: XAttribute(\"X\")]").AttributeLists[0].Attributes[0].ArgumentList.Arguments[0];
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<AttributeArgument startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\"><LiteralExpression kind=\"StringLiteralExpression\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"StringLiteralToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Token\">X</Token></LiteralExpression></AttributeArgument>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void AttributeTargetSpecifierSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("[module: XAttribute(\"X\"), YAttribute(\"Y\": 3), ZAttribute(\"Z\"= 4)]").AttributeLists[0];
            var xElement  = converter.Visit(node.Target);

            Assert.AreEqual("<AttributeTargetSpecifier startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"8\"><Token kind=\"ModuleKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"7\" part=\"Identifier\">module</Token><Token kind=\"ColonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"ColonToken\">:</Token></AttributeTargetSpecifier>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 10
0
        public void ConstantPatternSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = (SwitchStatementSyntax)SyntaxFactory.ParseStatement("switch(obj){ case 'a' when obj.Lenght > 0: }");
            var xElement  = converter.Visit(((CasePatternSwitchLabelSyntax)node.Sections[0].Labels[0]).Pattern);

            Assert.AreEqual("<ConstantPattern startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"21\"><LiteralExpression kind=\"CharacterLiteralExpression\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"21\" part=\"Expression\"><Token kind=\"CharacterLiteralToken\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"21\" part=\"Token\">a</Token></LiteralExpression></ConstantPattern>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 11
0
        public void TupleExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseExpression("(string, int)");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<TupleExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"13\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"OpenParenToken\">(</Token><SeparatedList_of_Argument part=\"Arguments\"><Argument startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"7\"><PredefinedType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"7\" part=\"Expression\"><Token kind=\"StringKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"7\" part=\"Keyword\">string</Token></PredefinedType></Argument><Argument startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"12\"><PredefinedType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"12\" part=\"Expression\"><Token kind=\"IntKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"12\" part=\"Keyword\">int</Token></PredefinedType></Argument></SeparatedList_of_Argument><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"13\" part=\"CloseParenToken\">)</Token></TupleExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExternAliasDirectiveSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("extern alias a;").Externs[0];
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<ExternAliasDirective startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"15\"><Token kind=\"ExternKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"6\" part=\"ExternKeyword\">extern</Token><Token kind=\"AliasKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"12\" part=\"AliasKeyword\">alias</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"14\" endLine=\"1\" endColumn=\"14\" part=\"Identifier\">a</Token><Token kind=\"SemicolonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"15\" part=\"SemicolonToken\">;</Token></ExternAliasDirective>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 13
0
        public void RefTypeSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.RefType(SyntaxFactory.Token(SyntaxKind.RefKeyword), SyntaxFactory.ParseTypeName("var"));
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<RefType startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"6\"><Token kind=\"RefKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"RefKeyword\">ref</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"6\" part=\"Type\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"6\" part=\"Identifier\">var</Token></IdentifierName></RefType>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_QueryExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseExpression("from f in s where f.A select f.R");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<QueryExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"32\"><FromClause startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"11\" part=\"FromClause\"><Token kind=\"FromKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"4\" part=\"FromKeyword\">from</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"Identifier\">f</Token><Token kind=\"InKeyword\" Keyword=\"true\" TypeParameterVariance=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"9\" part=\"InKeyword\">in</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"11\" endLine=\"1\" endColumn=\"11\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"11\" endLine=\"1\" endColumn=\"11\" part=\"Identifier\">s</Token></IdentifierName></FromClause><QueryBody startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"32\" part=\"Body\"><List_of_QueryClause part=\"Clauses\"><WhereClause startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"21\"><Token kind=\"WhereKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"17\" part=\"WhereKeyword\">where</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"21\" part=\"Condition\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"19\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"19\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"20\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"Identifier\">A</Token></IdentifierName></MemberAccessExpression></WhereClause></List_of_QueryClause><SelectClause startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"32\" part=\"SelectOrGroup\"><Token kind=\"SelectKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"28\" part=\"SelectKeyword\">select</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"32\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"31\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Identifier\">R</Token></IdentifierName></MemberAccessExpression></SelectClause></QueryBody></QueryExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 15
0
        public void SingleVariableDesignationSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("a"));
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<SingleVariableDesignation startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"Identifier\">a</Token></SingleVariableDesignation>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 16
0
        public void DiscardDesignationSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.DiscardDesignation(SyntaxFactory.Token(SyntaxKind.UnderscoreToken));
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<DiscardDesignation startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\"><Token kind=\"UnderscoreToken\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"UnderscoreToken\">_</Token></DiscardDesignation>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 17
0
        public void ThrowExpressionSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseExpression("throw e");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<ThrowExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"7\"><Token kind=\"ThrowKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"5\" part=\"ThrowKeyword\">throw</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"7\" endLine=\"1\" endColumn=\"7\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"7\" endLine=\"1\" endColumn=\"7\" part=\"Identifier\">e</Token></IdentifierName></ThrowExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void AttributeListSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("[module: XAttribute(\"X\"), YAttribute(Y: 3), ZAttribute(Z= 4)]").AttributeLists[0];
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<AttributeList startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"61\"><Token kind=\"OpenBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"1\" part=\"OpenBracketToken\">[</Token><AttributeTargetSpecifier startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"8\" part=\"Target\"><Token kind=\"ModuleKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"2\" endLine=\"1\" endColumn=\"7\" part=\"Identifier\">module</Token><Token kind=\"ColonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"ColonToken\">:</Token></AttributeTargetSpecifier><SeparatedList_of_Attribute part=\"Attributes\"><Attribute startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"24\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"19\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"10\" endLine=\"1\" endColumn=\"19\" part=\"Identifier\">XAttribute</Token></IdentifierName><AttributeArgumentList startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"24\" part=\"ArgumentList\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"20\" part=\"OpenParenToken\">(</Token><SeparatedList_of_AttributeArgument part=\"Arguments\"><AttributeArgument startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\"><LiteralExpression kind=\"StringLiteralExpression\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"StringLiteralToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"23\" part=\"Token\">X</Token></LiteralExpression></AttributeArgument></SeparatedList_of_AttributeArgument><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"24\" part=\"CloseParenToken\">)</Token></AttributeArgumentList></Attribute><Attribute startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"42\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"36\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"36\" part=\"Identifier\">YAttribute</Token></IdentifierName><AttributeArgumentList startLine=\"1\" startColumn=\"37\" endLine=\"1\" endColumn=\"42\" part=\"ArgumentList\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"37\" endLine=\"1\" endColumn=\"37\" part=\"OpenParenToken\">(</Token><SeparatedList_of_AttributeArgument part=\"Arguments\"><AttributeArgument startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"41\"><NameColon startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"39\" part=\"NameColon\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Identifier\">Y</Token></IdentifierName><Token kind=\"ColonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"39\" endLine=\"1\" endColumn=\"39\" part=\"ColonToken\">:</Token></NameColon><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Token\">3</Token></LiteralExpression></AttributeArgument></SeparatedList_of_AttributeArgument><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"42\" endLine=\"1\" endColumn=\"42\" part=\"CloseParenToken\">)</Token></AttributeArgumentList></Attribute><Attribute startLine=\"1\" startColumn=\"45\" endLine=\"1\" endColumn=\"60\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"45\" endLine=\"1\" endColumn=\"54\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"45\" endLine=\"1\" endColumn=\"54\" part=\"Identifier\">ZAttribute</Token></IdentifierName><AttributeArgumentList startLine=\"1\" startColumn=\"55\" endLine=\"1\" endColumn=\"60\" part=\"ArgumentList\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"55\" endLine=\"1\" endColumn=\"55\" part=\"OpenParenToken\">(</Token><SeparatedList_of_AttributeArgument part=\"Arguments\"><AttributeArgument startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"59\"><NameEquals startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"57\" part=\"NameEquals\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"56\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"56\" part=\"Identifier\">Z</Token></IdentifierName><Token kind=\"EqualsToken\" Operator=\"true\" startLine=\"1\" startColumn=\"57\" endLine=\"1\" endColumn=\"57\" part=\"EqualsToken\">=</Token></NameEquals><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"59\" endLine=\"1\" endColumn=\"59\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"59\" endLine=\"1\" endColumn=\"59\" part=\"Token\">4</Token></LiteralExpression></AttributeArgument></SeparatedList_of_AttributeArgument><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"60\" endLine=\"1\" endColumn=\"60\" part=\"CloseParenToken\">)</Token></AttributeArgumentList></Attribute></SeparatedList_of_Attribute><Token kind=\"CloseBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"61\" endLine=\"1\" endColumn=\"61\" part=\"CloseBracketToken\">]</Token></AttributeList>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 19
0
        public void WhenClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = (SwitchStatementSyntax)SyntaxFactory.ParseStatement("switch(obj){ case 'a' when obj.Lenght > 0: }");
            var xElement  = converter.Visit(((CasePatternSwitchLabelSyntax)node.Sections[0].Labels[0]).WhenClause);

            Assert.AreEqual("<WhenClause startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"41\"><Token kind=\"WhenKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"26\" part=\"WhenKeyword\">when</Token><BinaryExpression kind=\"GreaterThanExpression\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"41\" part=\"Condition\"><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"37\" part=\"Left\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"30\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"30\" part=\"Identifier\">obj</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"31\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"37\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"37\" part=\"Identifier\">Lenght</Token></IdentifierName></MemberAccessExpression><Token kind=\"GreaterThanToken\" startLine=\"1\" startColumn=\"39\" endLine=\"1\" endColumn=\"39\" part=\"OperatorToken\">&gt;</Token><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Right\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Token\">0</Token></LiteralExpression></BinaryExpression></WhenClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_JoinClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = (QueryExpressionSyntax)SyntaxFactory.ParseExpression("from f in s join T t in F on t.L equals s.R into y");
            var xElement = converter.Visit(node.Body.Clauses[0]);

            Assert.AreEqual("<JoinClause startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"50\"><Token kind=\"JoinKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"13\" endLine=\"1\" endColumn=\"16\" part=\"JoinKeyword\">join</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"18\" endLine=\"1\" endColumn=\"18\" part=\"Type\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"18\" endLine=\"1\" endColumn=\"18\" part=\"Identifier\">T</Token></IdentifierName><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"20\" endLine=\"1\" endColumn=\"20\" part=\"Identifier\">t</Token><Token kind=\"InKeyword\" Keyword=\"true\" TypeParameterVariance=\"true\" startLine=\"1\" startColumn=\"22\" endLine=\"1\" endColumn=\"23\" part=\"InKeyword\">in</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"InExpression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Identifier\">F</Token></IdentifierName><Token kind=\"OnKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"28\" part=\"OnKeyword\">on</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"32\" part=\"LeftExpression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Identifier\">t</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"31\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"32\" endLine=\"1\" endColumn=\"32\" part=\"Identifier\">L</Token></IdentifierName></MemberAccessExpression><Token kind=\"EqualsKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"34\" endLine=\"1\" endColumn=\"39\" part=\"EqualsKeyword\">equals</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"43\" part=\"RightExpression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"41\" endLine=\"1\" endColumn=\"41\" part=\"Identifier\">s</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"42\" endLine=\"1\" endColumn=\"42\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"43\" endLine=\"1\" endColumn=\"43\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"43\" endLine=\"1\" endColumn=\"43\" part=\"Identifier\">R</Token></IdentifierName></MemberAccessExpression><JoinIntoClause startLine=\"1\" startColumn=\"45\" endLine=\"1\" endColumn=\"50\" part=\"Into\"><Token kind=\"IntoKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"45\" endLine=\"1\" endColumn=\"48\" part=\"IntoKeyword\">into</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"50\" endLine=\"1\" endColumn=\"50\" part=\"Identifier\">y</Token></JoinIntoClause></JoinClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_LetClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = (QueryExpressionSyntax)SyntaxFactory.ParseExpression("from A f in s let y = 5");
            var xElement = converter.Visit(node.Body.Clauses[0]);

            Assert.AreEqual("<LetClause startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"23\"><Token kind=\"LetKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"17\" part=\"LetKeyword\">let</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"19\" endLine=\"1\" endColumn=\"19\" part=\"Identifier\">y</Token><Token kind=\"EqualsToken\" Operator=\"true\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"EqualsToken\">=</Token><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Token\">5</Token></LiteralExpression></LetClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_InterpolatedStringExpressionSyntaxAndInterpolatedStringTextSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = SyntaxFactory.ParseExpression("$\"Hello world\"");
            var xElement = converter.Visit(node);

            Assert.AreEqual("<InterpolatedStringExpression startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"14\"><Token kind=\"InterpolatedStringStartToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"2\" part=\"StringStartToken\">$\"</Token><List_of_InterpolatedStringContent part=\"Contents\"><InterpolatedStringText startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"13\"><Token kind=\"InterpolatedStringTextToken\" startLine=\"1\" startColumn=\"3\" endLine=\"1\" endColumn=\"13\" part=\"TextToken\">Hello world</Token></InterpolatedStringText></List_of_InterpolatedStringContent><Token kind=\"InterpolatedStringEndToken\" startLine=\"1\" startColumn=\"14\" endLine=\"1\" endColumn=\"14\" part=\"StringEndToken\">\"</Token></InterpolatedStringExpression>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_QueryContinuationSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = SyntaxFactory.ParseExpression("from A f in s select f into g select f.r");
            var xElement = converter.Visit(((QueryExpressionSyntax)node).Body.Continuation);

            Assert.AreEqual("<QueryContinuation startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"40\"><Token kind=\"IntoKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"27\" part=\"IntoKeyword\">into</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"29\" endLine=\"1\" endColumn=\"29\" part=\"Identifier\">g</Token><QueryBody startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"40\" part=\"Body\"><SelectClause startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"40\" part=\"SelectOrGroup\"><Token kind=\"SelectKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"36\" part=\"SelectKeyword\">select</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"40\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"39\" endLine=\"1\" endColumn=\"39\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"40\" endLine=\"1\" endColumn=\"40\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"40\" endLine=\"1\" endColumn=\"40\" part=\"Identifier\">r</Token></IdentifierName></MemberAccessExpression></SelectClause></QueryBody></QueryContinuation>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_GroupClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = SyntaxFactory.ParseExpression("from A f in s group g by f.r");
            var xElement = converter.Visit(((QueryExpressionSyntax)node).Body.SelectOrGroup);

            Assert.AreEqual("<GroupClause startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"28\"><Token kind=\"GroupKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"19\" part=\"GroupKeyword\">group</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"GroupExpression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"Identifier\">g</Token></IdentifierName><Token kind=\"ByKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"24\" part=\"ByKeyword\">by</Token><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"28\" part=\"ByExpression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"26\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"26\" endLine=\"1\" endColumn=\"26\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"27\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"28\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"28\" endLine=\"1\" endColumn=\"28\" part=\"Identifier\">r</Token></IdentifierName></MemberAccessExpression></GroupClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_WhereClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = (QueryExpressionSyntax)SyntaxFactory.ParseExpression("from A f in s where y = 5");
            var xElement = converter.Visit(node.Body.Clauses[0]);

            Assert.AreEqual("<WhereClause startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"25\"><Token kind=\"WhereKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"19\" part=\"WhereKeyword\">where</Token><AssignmentExpression kind=\"SimpleAssignmentExpression\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"25\" part=\"Condition\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"Left\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"21\" endLine=\"1\" endColumn=\"21\" part=\"Identifier\">y</Token></IdentifierName><Token kind=\"EqualsToken\" Operator=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"OperatorToken\">=</Token><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Right\"><Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Token\">5</Token></LiteralExpression></AssignmentExpression></WhereClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 26
0
        public void TypeSyntax_IdentifierNameSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseName("var");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\">" +
                            "<Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"Identifier\">var</Token>" +
                            "</IdentifierName>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void CompilationUnitSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = SyntaxFactory.ParseCompilationUnit("extern alias b; using static d; [assembly: XAttribute] namespace c{};");
            var xElement  = converter.Visit(node);

            Assert.AreEqual("<CompilationUnit startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"69\"><List_of_ExternAliasDirective part=\"Externs\"><ExternAliasDirective startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"15\"><Token kind=\"ExternKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"6\" part=\"ExternKeyword\">extern</Token><Token kind=\"AliasKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"12\" part=\"AliasKeyword\">alias</Token><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"14\" endLine=\"1\" endColumn=\"14\" part=\"Identifier\">b</Token><Token kind=\"SemicolonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"15\" part=\"SemicolonToken\">;</Token></ExternAliasDirective></List_of_ExternAliasDirective><List_of_UsingDirective part=\"Usings\"><UsingDirective startLine=\"1\" startColumn=\"17\" endLine=\"1\" endColumn=\"31\"><Token kind=\"UsingKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"17\" endLine=\"1\" endColumn=\"21\" part=\"UsingKeyword\">using</Token><Token kind=\"StaticKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"28\" part=\"StaticKeyword\">static</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"30\" endLine=\"1\" endColumn=\"30\" part=\"Identifier\">d</Token></IdentifierName><Token kind=\"SemicolonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"31\" endLine=\"1\" endColumn=\"31\" part=\"SemicolonToken\">;</Token></UsingDirective></List_of_UsingDirective><List_of_AttributeList part=\"AttributeLists\"><AttributeList startLine=\"1\" startColumn=\"33\" endLine=\"1\" endColumn=\"54\"><Token kind=\"OpenBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"33\" endLine=\"1\" endColumn=\"33\" part=\"OpenBracketToken\">[</Token><AttributeTargetSpecifier startLine=\"1\" startColumn=\"34\" endLine=\"1\" endColumn=\"42\" part=\"Target\"><Token kind=\"AssemblyKeyword\" Keyword=\"true\" Contextual=\"true\" startLine=\"1\" startColumn=\"34\" endLine=\"1\" endColumn=\"41\" part=\"Identifier\">assembly</Token><Token kind=\"ColonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"42\" endLine=\"1\" endColumn=\"42\" part=\"ColonToken\">:</Token></AttributeTargetSpecifier><SeparatedList_of_Attribute part=\"Attributes\"><Attribute startLine=\"1\" startColumn=\"44\" endLine=\"1\" endColumn=\"53\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"44\" endLine=\"1\" endColumn=\"53\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"44\" endLine=\"1\" endColumn=\"53\" part=\"Identifier\">XAttribute</Token></IdentifierName></Attribute></SeparatedList_of_Attribute><Token kind=\"CloseBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"54\" endLine=\"1\" endColumn=\"54\" part=\"CloseBracketToken\">]</Token></AttributeList></List_of_AttributeList><List_of_MemberDeclaration part=\"Members\"><NamespaceDeclaration startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"69\"><Token kind=\"NamespaceKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"56\" endLine=\"1\" endColumn=\"64\" part=\"NamespaceKeyword\">namespace</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"66\" endLine=\"1\" endColumn=\"66\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"66\" endLine=\"1\" endColumn=\"66\" part=\"Identifier\">c</Token></IdentifierName><Token kind=\"OpenBraceToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"67\" endLine=\"1\" endColumn=\"67\" part=\"OpenBraceToken\">{</Token><Token kind=\"CloseBraceToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"68\" endLine=\"1\" endColumn=\"68\" part=\"CloseBraceToken\">}</Token><Token kind=\"SemicolonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"69\" endLine=\"1\" endColumn=\"69\" part=\"SemicolonToken\">;</Token></NamespaceDeclaration></List_of_MemberDeclaration><Token kind=\"EndOfFileToken\" part=\"EndOfFileToken\"></Token></CompilationUnit>", xElement.ToString(SaveOptions.DisableFormatting));

            var gumtreefiedElement = converter.Gumtreefy(xElement);
        }
Exemplo n.º 28
0
        public void TypeSyntax_ArrayTypeSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = SyntaxFactory.ParseTypeName("int[1, 2]");
            var xElement = converter.Visit(node);

            Assert.AreEqual("<ArrayType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"9\">" +
                            "<PredefinedType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"ElementType\">" +
                            "<Token kind=\"IntKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"Keyword\">int</Token>" +
                            "</PredefinedType>" +
                            "<List_of_ArrayRankSpecifier part=\"RankSpecifiers\">" +
                            "<ArrayRankSpecifier startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"9\">" +
                            "<Token kind=\"OpenBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"4\" part=\"OpenBracketToken\">[</Token>" +
                            "<SeparatedList_of_Expression part=\"Sizes\">" +
                            "<LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\">" +
                            "<Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\" part=\"Token\">1</Token>" +
                            "</LiteralExpression>" +
                            "<LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\">" +
                            "<Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Token\">2</Token>" +
                            "</LiteralExpression>" +
                            "</SeparatedList_of_Expression>" +
                            "<Token kind=\"CloseBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"9\" endLine=\"1\" endColumn=\"9\" part=\"CloseBracketToken\">]</Token>" +
                            "</ArrayRankSpecifier>" +
                            "</List_of_ArrayRankSpecifier>" +
                            "</ArrayType>", xElement.ToString(SaveOptions.DisableFormatting));

            node     = SyntaxFactory.ParseTypeName("int[1][2]");
            xElement = converter.Visit(node);
            Assert.AreEqual("<ArrayType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"9\">" +
                            "<PredefinedType TypeSyntax=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"ElementType\">" +
                            "<Token kind=\"IntKeyword\" Keyword=\"true\" startLine=\"1\" startColumn=\"1\" endLine=\"1\" endColumn=\"3\" part=\"Keyword\">int</Token>" +
                            "</PredefinedType>" +
                            "<List_of_ArrayRankSpecifier part=\"RankSpecifiers\">" +
                            "<ArrayRankSpecifier startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"6\">" +
                            "<Token kind=\"OpenBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"4\" endLine=\"1\" endColumn=\"4\" part=\"OpenBracketToken\">[</Token>" +
                            "<SeparatedList_of_Expression part=\"Sizes\">" +
                            "<LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\">" +
                            "<Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"5\" endLine=\"1\" endColumn=\"5\" part=\"Token\">1</Token>" +
                            "</LiteralExpression>" +
                            "</SeparatedList_of_Expression>" +
                            "<Token kind=\"CloseBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"6\" endLine=\"1\" endColumn=\"6\" part=\"CloseBracketToken\">]</Token>" +
                            "</ArrayRankSpecifier>" +
                            "<ArrayRankSpecifier startLine=\"1\" startColumn=\"7\" endLine=\"1\" endColumn=\"9\">" +
                            "<Token kind=\"OpenBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"7\" endLine=\"1\" endColumn=\"7\" part=\"OpenBracketToken\">[</Token>" +
                            "<SeparatedList_of_Expression part=\"Sizes\">" +
                            "<LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\">" +
                            "<Token kind=\"NumericLiteralToken\" startLine=\"1\" startColumn=\"8\" endLine=\"1\" endColumn=\"8\" part=\"Token\">2</Token>" +
                            "</LiteralExpression>" +
                            "</SeparatedList_of_Expression>" +
                            "<Token kind=\"CloseBracketToken\" Punctuation=\"true\" Language=\"true\" startLine=\"1\" startColumn=\"9\" endLine=\"1\" endColumn=\"9\" part=\"CloseBracketToken\">]</Token>" +
                            "</ArrayRankSpecifier>" +
                            "</List_of_ArrayRankSpecifier>" +
                            "</ArrayType>", xElement.ToString(SaveOptions.DisableFormatting));
        }
Exemplo n.º 29
0
        public void LocalFunctionStatementSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();
            var node      = (MethodDeclarationSyntax)SyntaxFactory.ParseCompilationUnit(@"
            void m()
            {
                int local() => 0;
            }").Members[0];
            var xElement  = converter.Visit(node.Body.Statements[0]);

            Assert.AreEqual("<LocalFunctionStatement startLine=\"4\" startColumn=\"17\" endLine=\"4\" endColumn=\"33\"><PredefinedType TypeSyntax=\"true\" startLine=\"4\" startColumn=\"17\" endLine=\"4\" endColumn=\"19\" part=\"ReturnType\"><Token kind=\"IntKeyword\" Keyword=\"true\" startLine=\"4\" startColumn=\"17\" endLine=\"4\" endColumn=\"19\" part=\"Keyword\">int</Token></PredefinedType><Token kind=\"IdentifierToken\" startLine=\"4\" startColumn=\"21\" endLine=\"4\" endColumn=\"25\" part=\"Identifier\">local</Token><ParameterList startLine=\"4\" startColumn=\"26\" endLine=\"4\" endColumn=\"27\" part=\"ParameterList\"><Token kind=\"OpenParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"4\" startColumn=\"26\" endLine=\"4\" endColumn=\"26\" part=\"OpenParenToken\">(</Token><Token kind=\"CloseParenToken\" Punctuation=\"true\" Language=\"true\" startLine=\"4\" startColumn=\"27\" endLine=\"4\" endColumn=\"27\" part=\"CloseParenToken\">)</Token></ParameterList><ArrowExpressionClause startLine=\"4\" startColumn=\"29\" endLine=\"4\" endColumn=\"32\" part=\"ExpressionBody\"><Token kind=\"EqualsGreaterThanToken\" Operator=\"true\" startLine=\"4\" startColumn=\"29\" endLine=\"4\" endColumn=\"30\" part=\"ArrowToken\">=&gt;</Token><LiteralExpression kind=\"NumericLiteralExpression\" startLine=\"4\" startColumn=\"32\" endLine=\"4\" endColumn=\"32\" part=\"Expression\"><Token kind=\"NumericLiteralToken\" startLine=\"4\" startColumn=\"32\" endLine=\"4\" endColumn=\"32\" part=\"Token\">0</Token></LiteralExpression></ArrowExpressionClause><Token kind=\"SemicolonToken\" Punctuation=\"true\" Language=\"true\" startLine=\"4\" startColumn=\"33\" endLine=\"4\" endColumn=\"33\" part=\"SemicolonToken\">;</Token></LocalFunctionStatement>", xElement.ToString(SaveOptions.DisableFormatting));
        }
        public void ExpressionSyntax_OrderByClauseSyntax_RoslynMLFromRoslyn_OK()
        {
            var converter = new RoslynML();

            var node     = (QueryExpressionSyntax)SyntaxFactory.ParseExpression("from A f in s orderby f.y");
            var xElement = converter.Visit(node.Body.Clauses[0]);

            Assert.AreEqual("<OrderByClause startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"25\"><Token kind=\"OrderByKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"21\" part=\"OrderByKeyword\">orderby</Token><SeparatedList_of_Ordering part=\"Orderings\"><Ordering kind=\"AscendingOrdering\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"25\"><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"25\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"24\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Identifier\">y</Token></IdentifierName></MemberAccessExpression></Ordering></SeparatedList_of_Ordering></OrderByClause>", xElement.ToString(SaveOptions.DisableFormatting));

            node     = (QueryExpressionSyntax)SyntaxFactory.ParseExpression("from A f in s orderby f.y ascending, f.z descending");
            xElement = converter.Visit(node.Body.Clauses[0]);
            Assert.AreEqual("<OrderByClause startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"51\"><Token kind=\"OrderByKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"15\" endLine=\"1\" endColumn=\"21\" part=\"OrderByKeyword\">orderby</Token><SeparatedList_of_Ordering part=\"Orderings\"><Ordering kind=\"AscendingOrdering\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"35\"><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"25\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"23\" endLine=\"1\" endColumn=\"23\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"24\" endLine=\"1\" endColumn=\"24\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"25\" endLine=\"1\" endColumn=\"25\" part=\"Identifier\">y</Token></IdentifierName></MemberAccessExpression><Token kind=\"AscendingKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"27\" endLine=\"1\" endColumn=\"35\" part=\"AscendingOrDescendingKeyword\">ascending</Token></Ordering><Ordering kind=\"DescendingOrdering\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"51\"><MemberAccessExpression kind=\"SimpleMemberAccessExpression\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"40\" part=\"Expression\"><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Expression\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"38\" endLine=\"1\" endColumn=\"38\" part=\"Identifier\">f</Token></IdentifierName><Token kind=\"DotToken\" Operator=\"true\" startLine=\"1\" startColumn=\"39\" endLine=\"1\" endColumn=\"39\" part=\"OperatorToken\">.</Token><IdentifierName Name=\"true\" TypeSyntax=\"true\" startLine=\"1\" startColumn=\"40\" endLine=\"1\" endColumn=\"40\" part=\"Name\"><Token kind=\"IdentifierToken\" startLine=\"1\" startColumn=\"40\" endLine=\"1\" endColumn=\"40\" part=\"Identifier\">z</Token></IdentifierName></MemberAccessExpression><Token kind=\"DescendingKeyword\" Keyword=\"true\" Contextual=\"true\" Query=\"true\" startLine=\"1\" startColumn=\"42\" endLine=\"1\" endColumn=\"51\" part=\"AscendingOrDescendingKeyword\">descending</Token></Ordering></SeparatedList_of_Ordering></OrderByClause>", xElement.ToString(SaveOptions.DisableFormatting));
        }