await TestAsyncWithOption()

in src/EditorFeatures/CSharpTest/QualifyMemberAccess/QualifyMemberAccessTests.cs [497:887]


            await TestAsyncWithOption(
@"class Class
{
    string M()
    {
        return [|M|]()?.ToString();
    }",
@"class Class
{
    string M()
    {
        return this.M()?.ToString();
    }",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7584"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyMethodAccess_EventSubscription1()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        e += [|Handler|];
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        e += this.Handler;
    }
}",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7584"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyMethodAccess_EventSubscription2()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        e += new EventHandler([|Handler|]);
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        e += new EventHandler(this.Handler);
    }
}",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7584"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyMethodAccess_OnBase()
        {
            await TestAsyncWithOption(
@"class Base
{
    protected void Method()
    {
    }
}

class Derived : Base
{
    void M()
    {
        [|Method|]();
    }
}",
@"class Base
{
    protected void Method()
    {
    }
}

class Derived : Base
{
    void M()
    {
        this.Method();
    }
}",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyMethodAccess_NotSuggestedOnInstance()
        {
            await TestMissingAsyncWithOption(
@"class Class
{
    void M(Class c)
    {
        c.[|M|]();
    }
}",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyMethodAccess_NotSuggestedOnStatic()
        {
            await TestMissingAsyncWithOption(
@"class C
{
    static void Method()
    {
    }

    void M()
    {
        [|Method|]();
    }
}",
CodeStyleOptions.QualifyMethodAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_EventSubscription()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        [|e|] += Handler;
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void Handler(object sender, EventArgs args)
    {
        this.e += Handler;
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccessAsProperty_EventSubscription()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e
    {
        add
        {
        }

        remove
        {
        }
    }

    void Handler(object sender, EventArgs args)
    {
        [|e|] += Handler;
    }
}",
@"using System;

class C
{
    event EventHandler e
    {
        add
        {
        }

        remove
        {
        }
    }

    void Handler(object sender, EventArgs args)
    {
        this.e += Handler;
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_InvokeEvent1()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        [|e|](this, new EventArgs());
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        this.e(this, new EventArgs());
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_InvokeEvent2()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        [|e|].Invoke(this, new EventArgs());
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        this.e.Invoke(this, new EventArgs());
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_InvokeEvent3()
        {
            await TestAsyncWithOption(
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        [|e|]?.Invoke(this, new EventArgs());
    }
}",
@"using System;

class C
{
    event EventHandler e;

    void OnSomeEvent()
    {
        this.e?.Invoke(this, new EventArgs());
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact(Skip = "https://github.com/dotnet/roslyn/issues/7587"), Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_OnBase()
        {
            await TestAsyncWithOption(
@"using System;

class Base
{
    protected event EventHandler e;
}

class Derived : Base
{
    void Handler(object sender, EventArgs args)
    {
        [|e|] += Handler;
    }
}",
@"using System;

class Base
{
    protected event EventHandler e;
}

class Derived : Base
{
    void Handler(object sender, EventArgs args)
    {
        this.e += Handler;
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_NotSuggestedOnInstance()
        {
            await TestMissingAsyncWithOption(
@"using System;

class Class
{
    event EventHandler e;

    void M(Class c)
    {
        c.[|e|] += Handler;
    }

    void Handler(object sender, EventArgs args)
    {
    }
}",
CodeStyleOptions.QualifyEventAccess);
        }

        [WorkItem(7065, "https://github.com/dotnet/roslyn/issues/7065")]
        [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsQualifyMemberAccess)]
        public async Task QualifyEventAccess_NotSuggestedOnStatic()
        {
            await TestMissingAsyncWithOption(
@"using System;

class C
{
    static event EventHandler e;
}

void Handler(object sender, EventArgs args)
{
    [|e|] += Handler;
} }",
CodeStyleOptions.QualifyEventAccess);
        }