Example #1
0
        internal string Dump()
        {
            return(TreeDumper.DumpCompact(Dump(this)));

            TreeDumperNode Dump(Conversion self)
            {
                var sub = new System.Collections.Generic.List <TreeDumperNode>();

                if ((object)self.Method != null)
                {
                    sub.Add(new TreeDumperNode("method", self.Method.ToDisplayString(), null));
                }

                if ((object)self.DeconstructionInfo != null)
                {
                    sub.Add(new TreeDumperNode("deconstructionInfo", null,
                                               new[] { BoundTreeDumperNodeProducer.MakeTree(self.DeconstructionInfo.Invocation) }));
                }

                var underlyingConversions = self.UnderlyingConversions;

                if (!underlyingConversions.IsDefaultOrEmpty)
                {
                    sub.Add(new TreeDumperNode($"underlyingConversions[{underlyingConversions.Length}]", null,
                                               underlyingConversions.SelectAsArray(c => Dump(c))));
                }

                return(new TreeDumperNode("conversion", self.Kind, sub));
            }
        }
Example #2
0
        internal void TestOverloadResolutionWithDiff(string source, MetadataReference[] additionalRefs = null)
        {
            // The mechanism of this test is: we build the bound tree for the code passed in and then extract
            // from it the nodes that describe the method symbols. We then compare the description of
            // the symbols given to the comment that follows the call.

            var mscorlibRef = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.NetFX.v4_0_30316_17626.mscorlib).GetReference(display: "mscorlib");
            var references = new[] { mscorlibRef }.Concat(additionalRefs ?? SpecializedCollections.EmptyArray <MetadataReference>());

            var compilation = CreateCompilation(source, references, TestOptions.ReleaseDll);

            var method      = (SourceMethodSymbol)compilation.GlobalNamespace.GetTypeMembers("C").Single().GetMembers("M").Single();
            var diagnostics = new DiagnosticBag();
            var block       = MethodCompiler.BindMethodBody(method, new TypeCompilationState(method.ContainingType, compilation, null), diagnostics);
            var tree        = BoundTreeDumperNodeProducer.MakeTree(block);
            var results     = string.Join("\n", tree.PreorderTraversal().Select(edge => edge.Value)
                                          .Where(x => x.Text == "method" && x.Value != null)
                                          .Select(x => x.Value)
                                          .ToArray());

            // var r = string.Join("\n", tree.PreorderTraversal().Select(edge => edge.Value).ToArray();

            var expected = string.Join("\n", source
                                       .Split(new[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries)
                                       .Where(x => x.Contains("//-"))
                                       .Select(x => x.Substring(x.IndexOf("//-") + 3))
                                       .ToArray());

            AssertEx.Equal(expected, results);
        }
Example #3
0
            internal override string Dump()
            {
                var node = new TreeDumperNode("boundSpillSequenceBuilder", null, new TreeDumperNode[]
                {
                    new TreeDumperNode("locals", this.GetLocals(), null),
                    new TreeDumperNode("statements", null, from x in this.GetStatements() select BoundTreeDumperNodeProducer.MakeTree(x)),
                    new TreeDumperNode("value", null, new TreeDumperNode[] { BoundTreeDumperNodeProducer.MakeTree(this.Value) }),
                    new TreeDumperNode("type", this.Type, null)
                });

                return(TreeDumper.DumpCompact(node));
            }
Example #4
0
 internal virtual string Dump()
 {
     return(MyTreeDumper.DumpCompact(BoundTreeDumperNodeProducer.MakeTree(this)));
 }