Ejemplo n.º 1
0
 //
 // Summary:
 //     Visits the System.Linq.Expressions.LabelTarget.
 //
 // Parameters:
 //   node:
 //     The expression to visit.
 //
 // Returns:
 //     The modified expression, if it or any subexpression was modified; otherwise,
 //     returns the original expression.
 protected override LabelTarget VisitLabelTarget(LabelTarget node)
 {
     Console.WriteLine("VisitLabelTarget:");
     Console.WriteLine('\t' + node.GetType().ToString());
     Console.WriteLine('\t' + node.ToString());
     return(base.VisitLabelTarget(node));
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Loader.Load();
            Objects.LoadType(typeof(DynamicLinqTestObjects));

            var lines = new List <string>();

            foreach (var(key, filename) in rendererFileMapping.SelectKVP((k, v) => (k, v)))
            {
                var ordering = parseFileOrder(@$ "C:\Users\Spitz\source\repos\zspitz\ExpressionTreeToString\Tests\expectedResults\{filename}-testdata.txt");

                var language = key == VisualBasic ? Language.VisualBasic : Language.CSharp;
                //var language = key == CSharp ? Language.CSharp : Language.VisualBasic;

                const string dlinq   = nameof(DynamicLinqTestObjects);
                var          objects = Objects.Get()
                                       //.Where(x => key == DynamicLinq ? x.source == dlinq : x.source != dlinq)
                                       .Where(x => key == DynamicLinq)
                                       .Where(x => !ordering.ContainsKey($"{x.source}.{x.name}"));

                DynamicLinqWriterVisitor.CustomAccessibleTypes.Add(typeof(Console));
                DynamicLinqWriterVisitor.CustomAccessibleTypes.Add(typeof(Dummy));

                //var objects = Objects.Get()
                //    .Where(x => key == DynamicLinq ? x.source == dlinq : x.source != dlinq)
                //    .Where(x => key == DynamicLinq)
                //    .OrderBy(x => ordering.TryGetValue($"{x.source}.{x.name}", out var order) ? order : -1);

                foreach (var(category, source, name, o) in objects)
                {
                    var toWrite = o switch
                    {
                        Expression expr => expr.ToString(key, out var pathSpans, language),
                        MemberBinding mbind => mbind.ToString(key, out var pathSpans, language),
                        ElementInit init => init.ToString(key, out var pathSpans, language),
                        SwitchCase switchCase => switchCase.ToString(key, out var pathSpans, language),
                        CatchBlock catchBlock => catchBlock.ToString(key, out var pathSpans, language),
                        LabelTarget labelTarget => labelTarget.ToString(key, out var pathSpans, language),
                        _ => throw new NotImplementedException(),
                    };
                    lines.Add($"---- {source}.{name}");
                    if (key == FactoryMethods)
                    {
                        var toReplace =
                            language == Language.CSharp ?
                            @"// using static System.Linq.Expressions.Expression

" :
                            @"' Imports System.Linq.Expressions.Expression

";
                        toWrite = toWrite.Replace(toReplace, "");
                    }
                    lines.Add(toWrite);
                }

                lines.Add("------");
            }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Loader.Load();

            var lines = new List <string>();

            foreach (var(key, filename) in rendererFileMapping)
            {
                var ordering = parseFileOrder(@$ "C:\Users\Spitz\source\repos\zspitz\ExpressionTreeToString\Tests\expectedResults\{filename}-testdata.txt");

                var language = key == VisualBasic ? Language.VisualBasic : Language.CSharp;

                //foreach (var (category, source, name, o) in Objects.Get().OrderBy(x => ordering[$"{x.source}.{x.name}"])) {
                foreach (var(category, source, name, o) in Objects.Get().Where(x => !ordering.ContainsKey($"{x.source}.{x.name}")))
                {
                    lines.Add($"---- {source}.{name}");
                    var toWrite = o switch
                    {
                        Expression expr => expr.ToString(key, out var pathSpans, language),
                        MemberBinding mbind => mbind.ToString(key, out var pathSpans, language),
                        ElementInit init => init.ToString(key, out var pathSpans, language),
                        SwitchCase switchCase => switchCase.ToString(key, out var pathSpans, language),
                        CatchBlock catchBlock => catchBlock.ToString(key, out var pathSpans, language),
                        LabelTarget labelTarget => labelTarget.ToString(key, out var pathSpans, language),
                        _ => throw new NotImplementedException(),
                    };
                    if (key == FactoryMethods)
                    {
                        toWrite = toWrite.Replace(@"// using static System.Linq.Expressions.Expression

", "");
                    }
                    lines.Add(toWrite);
                }

                lines.Add("------");
            }
Ejemplo n.º 4
0
 /// <summary>访问当前内容 <see cref="T:System.Linq.Expressions.LabelTarget"></see>.</summary>
 /// <param name="node">被访问的表达式</param>
 /// <returns>The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.</returns>
 protected override LabelTarget VisitLabelTarget(LabelTarget node)
 {
     Log(node.ToString());
     throw new NotImplementedException();
 }
 /// <summary>
 /// Visits the <see cref="System.Linq.Expressions.LabelTarget"/>.
 /// </summary>
 /// <param name="node">The expression to visit.</param>
 /// <returns>The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.</returns>
 protected override LabelTarget VisitLabelTarget(LabelTarget node)
 {
     InvalidExpression(node.ToString());
     return(null);
 }