public void InvokeOnProperty()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int G$$oo { get; set;}
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Goo");
        }
Exemple #2
0
        public async Task InvokeOnProperty()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int F$$oo { get; set;}
    }
}";
            var testState = await CallHierarchyTestState.CreateAsync(text);

            var root = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo");
        }
Exemple #3
0
        public void InvokeOnEvent()
        {
            var text      = @"
using System;
namespace N
{
    class C
    {
        public event EventHandler Fo$$o;
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo");
        }
Exemple #4
0
        public void NoFindOverridesOnSealedMethod()
        {
            var text      = @"
namespace N
{
    class C
    {
        void F$$oo()
        {
        }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            Assert.DoesNotContain("Overrides", root.SupportedSearchCategories.Select(s => s.DisplayName));
        }
Exemple #5
0
        public void InvokeOnMethod()
        {
            var text      = @"
namespace N
{
    class C
    {
        void F$$oo()
        {
        }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo()");
        }
        public void FieldInitializers()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int foo = Foo();

        protected int Foo$$() { return 0; }
    }
}";
            var testState = new CallHierarchyTestState(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo()", new[] { "Calls To 'Foo'" });
            testState.VerifyResultName(root, "Calls To 'Foo'", new[] { "Initializers" });
        }
Exemple #7
0
        public void FieldInitializers()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int foo = Foo();

        protected int Foo$$() { return 0; }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo()", new[] { string.Format(EditorFeaturesResources.Calls_To_0, "Foo") });
            testState.VerifyResultName(root, string.Format(EditorFeaturesResources.Calls_To_0, "Foo"), new[] { EditorFeaturesResources.Initializers });
        }
Exemple #8
0
        public void FieldReferences()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int f$$oo = Foo();

        protected int Foo() { foo = 3; }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.foo", new[] { string.Format(EditorFeaturesResources.References_To_Field_0, "foo") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.References_To_Field_0, "foo"), new[] { "N.C.Foo()" });
        }
        public void FieldReferences()
        {
            var text      = @"
namespace N
{
    class C
    {
        public int f$$oo = Foo();

        protected int Foo() { foo = 3; }
    }
}";
            var testState = new CallHierarchyTestState(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.foo", new[] { "References To Field 'foo'" });
            testState.VerifyResult(root, "References To Field 'foo'", new[] { "N.C.Foo()" });
        }
        public void Method_FindCalls()
        {
            var text =
                @"
namespace N
{
    class C
    {
        void G$$oo()
        {
        }
    }

    class G
    {
        void Main()
        {
            var c = new C();
            c.Goo();
        }

        void Main2()
        {
            var c = new C();
            c.Goo();
        }
    }
}";

            using var testState = CallHierarchyTestState.Create(text);
            var root = testState.GetRoot();

            testState.VerifyRoot(
                root,
                "N.C.Goo()",
                new[] { string.Format(EditorFeaturesResources.Calls_To_0, "Goo") }
                );
            testState.VerifyResult(
                root,
                string.Format(EditorFeaturesResources.Calls_To_0, "Goo"),
                new[] { "N.G.Main()", "N.G.Main2()" }
                );
        }
        public void SearchAfterEditWorks()
        {
            var text      = @"
namespace N
{
    class C
    {
        void G$$oo()
        {
        }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.Workspace.Documents.Single().GetTextBuffer().Insert(0, "/* hello */");

            testState.VerifyRoot(root, "N.C.Goo()", new[] { string.Format(EditorFeaturesResources.Calls_To_0, "Goo"), });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.Calls_To_0, "Goo"), expectedCallers: new[] { "N.C.Goo()" });
        }
Exemple #12
0
        public void PropertySet()
        {
            var code = @"
namespace N
{
    class C
    {
        public int Property { get; s$$et; }
        void M()
        {
            Property = 2;
        }
    }
}";

            using var testState = CallHierarchyTestState.Create(code);
            var root = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Property.set", new[] { string.Format(EditorFeaturesResources.Calls_To_0, "set_Property") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.Calls_To_0, "set_Property"), new[] { "N.C.M()" });
        }
Exemple #13
0
        public void InterfaceImplementors()
        {
            var text = @"
namespace N
{
    interface I
    {
        void Go$$o();
    }

    class C : I
    {
        public void Goo()
        {
        }
    }

    class G
    {
        void Main()
        {
            I c = new C();
            c.Goo();
        }

        void Main2()
        {
            var c = new C();
            c.Goo();
        }
    }
}";

            using var testState = CallHierarchyTestState.Create(text);
            var root = testState.GetRoot();

            testState.VerifyRoot(root, "N.I.Goo()", new[] { string.Format(EditorFeaturesResources.Calls_To_0, "Goo"), string.Format(EditorFeaturesResources.Implements_0, "Goo") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.Calls_To_0, "Goo"), new[] { "N.G.Main()" });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.Implements_0, "Goo"), new[] { "N.C.Goo()" });
        }
Exemple #14
0
        public async Task InterfaceImplementors()
        {
            var text      = @"
namespace N
{
    interface I
    {
        void Fo$$o();
    }

    class C : I
    {
        public async Task Foo()
        {
        }
    }

    class G
    {
        void Main()
        {
            I c = new C();
            c.Foo();
        }

        void Main2()
        {
            var c = new C();
            c.Foo();
        }
    }
}";
            var testState = await CallHierarchyTestState.CreateAsync(text);

            var root = testState.GetRoot();

            testState.VerifyRoot(root, "N.I.Foo()", new[] { string.Format(EditorFeaturesResources.CallsTo, "Foo"), string.Format(EditorFeaturesResources.ImplementsArg, "Foo") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.CallsTo, "Foo"), new[] { "N.G.Main()" });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.ImplementsArg, "Foo"), new[] { "N.C.Foo()" });
        }
Exemple #15
0
        public void GenericExtensionMethods()
        {
            var text      = @"
using System.Collections.Generic;
using System.Linq;
namespace N
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> x = new List<int>();
            var z = x.Si$$ngle();
        }
    }
}";
            var testState = CallHierarchyTestState.Create(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "System.Linq.Enumerable.Single<TSource>(this System.Collections.Generic.IEnumerable<TSource>)", new[] { string.Format(EditorFeaturesResources.Calls_To_0, "Single") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.Calls_To_0, "Single"), new[] { "N.Program.Main(string[])" });
        }
        public void Method_InterfaceImplementation()
        {
            var text      = @"
namespace N
{
    interface I
    {
        void Foo();
    }

    class C : I
    {
        public void F$$oo()
        {
        }
    }

    class G
    {
        void Main()
        {
            I c = new C();
            c.Foo();
        }

        void Main2()
        {
            var c = new C();
            c.Foo();
        }
    }
}";
            var testState = new CallHierarchyTestState(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.C.Foo()", new[] { string.Format(EditorFeaturesResources.CallsTo, "Foo"), string.Format(EditorFeaturesResources.CallsToInterfaceImplementation, "N.I.Foo()") });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.CallsTo, "Foo"), new[] { "N.G.Main2()" });
            testState.VerifyResult(root, string.Format(EditorFeaturesResources.CallsToInterfaceImplementation, "N.I.Foo()"), new[] { "N.G.Main()" });
        }
        public void InterfaceImplementors()
        {
            var text      = @"
namespace N
{
    interface I
    {
        void Fo$$o();
    }

    class C : I
    {
        public void Foo()
        {
        }
    }

    class G
    {
        void Main()
        {
            I c = new C();
            c.Foo();
        }

        void Main2()
        {
            var c = new C();
            c.Foo();
        }
    }
}";
            var testState = new CallHierarchyTestState(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "N.I.Foo()", new[] { "Calls To 'Foo'", "Implements 'Foo'" });
            testState.VerifyResult(root, "Calls To 'Foo'", new[] { "N.G.Main()" });
            testState.VerifyResult(root, "Implements 'Foo'", new[] { "N.C.Foo()" });
        }
        public void ExtensionMethods()
        {
            var text =
                @"
namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ""string"";
            x.BarStr$$ing();
        }
    }
    
    public static class Extensions
    {
        public static string BarString(this string s)
        {
            return s;
        }
    }
}";

            using var testState = CallHierarchyTestState.Create(text);
            var root = testState.GetRoot();

            testState.VerifyRoot(
                root,
                "ConsoleApplication10.Extensions.BarString(this string)",
                new[] { string.Format(EditorFeaturesResources.Calls_To_0, "BarString") }
                );
            testState.VerifyResult(
                root,
                string.Format(EditorFeaturesResources.Calls_To_0, "BarString"),
                new[] { "ConsoleApplication10.Program.Main(string[])" }
                );
        }
        public void AbstractMethodInclusionToOverrides()
        {
            var text =
                @"
using System;

abstract class Base
{
    public abstract void $$M();
}
 
class Derived : Base
{
    public override void M()
    {
        throw new NotImplementedException();
    }
}";

            using var testState = CallHierarchyTestState.Create(text);
            var root = testState.GetRoot();

            testState.VerifyRoot(
                root,
                "Base.M()",
                new[]
            {
                string.Format(EditorFeaturesResources.Calls_To_0, "M"),
                EditorFeaturesResources.Overrides_,
                EditorFeaturesResources.Calls_To_Overrides
            }
                );
            testState.VerifyResult(
                root,
                EditorFeaturesResources.Overrides_,
                new[] { "Derived.M()" }
                );
        }
        public void AbstractMethodInclusionToOverrides()
        {
            var text      = @"
using System;

abstract class Base
{
    public abstract void $$M();
}
 
class Derived : Base
{
    public override void M()
    {
        throw new NotImplementedException();
    }
}";
            var testState = new CallHierarchyTestState(text);
            var root      = testState.GetRoot();

            testState.VerifyRoot(root, "Base.M()", new[] { "Calls To 'M'", "Overrides", "Calls To Overrides" });
            testState.VerifyResult(root, "Overrides", new[] { "Derived.M()" });
        }
        public void PropertyGet()
        {
            var text =
                @"
namespace N
{
    class C
    {
        public int val
        {
            g$$et
            {
                return 0;
            }
        }

        public int goo()
        {
            var x = this.val;
        }
    }
}";

            using var testState = CallHierarchyTestState.Create(text);
            var root = testState.GetRoot();

            testState.VerifyRoot(
                root,
                "N.C.val.get",
                new[] { string.Format(EditorFeaturesResources.Calls_To_0, "get_val") }
                );
            testState.VerifyResult(
                root,
                string.Format(EditorFeaturesResources.Calls_To_0, "get_val"),
                new[] { "N.C.goo()" }
                );
        }