コード例 #1
0
        public void ReorderParameters_Cascade_ToImplementingMethod()
        {
            var markup = @"
interface I
{
    $$void M(int x, string y);
}

class C : I
{
    public void M(int x, string y)
    { }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
interface I
{
    void M(string y, int x);
}

class C : I
{
    public void M(string y, int x)
    { }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #2
0
        public void ReorderParameters_Cascade_ToOverriddenMethod()
        {
            var markup = @"
class B
{
    public virtual void M(int x, string y)
    { }
}

class D : B
{
    $$public override void M(int x, string y)
    { }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class B
{
    public virtual void M(string y, int x)
    { }
}

class D : B
{
    public override void M(string y, int x)
    { }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #3
0
        public void TryGetPublicKeyFailsForInvalidKeyBlobs()
        {
            var invalidKeyBlobs = new[]
            {
                string.Empty,
                new string('0', 160 * 2), // 160 * 2 - the length of a public key, 2 - 2 chars per byte
                new string('0', 596 * 2), // 596 * 2 - the length of a key pair, 2 - 2 chars per byte
                "0702000000240000DEADBEEF" + new string('0', 584 * 2), // private key blob without magic private key
                "0602000000240000DEADBEEF" + new string('0', 136 * 2), // public key blob without magic public key
            };

            ImmutableArray<byte> pubKey;
            foreach (var key in invalidKeyBlobs)
            {
                Assert.False(CryptoBlobParser.TryGetPublicKey(HexToBin(key), out pubKey));
            }
        }
コード例 #4
0
        public void ReorderMethodParameters_InvokeAfterParameterList()
        {
            var markup = @"
using System;
class MyClass
{
    public void Foo(int x, string y)$$
    {
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
using System;
class MyClass
{
    public void Foo(string y, int x)
    {
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #5
0
        public void ReorderParameters_Cascade_ToMethods_WithDifferentParameterNames()
        {
            var markup = @"
public class B
{
    /// <param name=""x""></param>
    /// <param name=""y""></param>
    public virtual int M(int x, string y)
    {
        return 1;
    }
}

public class D : B
{
    /// <param name=""a""></param>
    /// <param name=""b""></param>
    public override int M(int a, string b)
    {
        return 1;
    }
}

public class D2 : D
{
    /// <param name=""y""></param>
    /// <param name=""x""></param>
    public override int $$M(int y, string x)
    {
        M(1, ""Two"");
        ((D)this).M(1, ""Two"");
        ((B)this).M(1, ""Two"");

        M(1, x: ""Two"");
        ((D)this).M(1, b: ""Two"");
        ((B)this).M(1, y: ""Two"");

        return 1;
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
public class B
{
    /// <param name=""y""></param>
    /// <param name=""x""></param>
    public virtual int M(string y, int x)
    {
        return 1;
    }
}

public class D : B
{
    /// <param name=""b""></param>
    /// <param name=""a""></param>
    public override int M(string b, int a)
    {
        return 1;
    }
}

public class D2 : D
{
    /// <param name=""x""></param>
    /// <param name=""y""></param>
    public override int M(string x, int y)
    {
        M(""Two"", 1);
        ((D)this).M(""Two"", 1);
        ((B)this).M(""Two"", 1);

        M(x: ""Two"", y: 1);
        ((D)this).M(b: ""Two"", a: 1);
        ((B)this).M(y: ""Two"", x: 1);

        return 1;
    }
}";
            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #6
0
        public void ReorderParameters_Cascade_ToMethods_Complex()
        {
            ////     B   I   I2
            ////      \ / \ /
            ////       D  (I3)
            ////      / \   \
            ////   $$D2  D3  C

            var markup = @"
class B { public virtual void M(int x, string y) { } }
class D : B, I { public override void M(int x, string y) { } }
class D2 : D { public override void $$M(int x, string y) { } }
class D3 : D { public override void M(int x, string y) { } }
interface I { void M(int x, string y); }
interface I2 { void M(int x, string y); }
interface I3 : I, I2 { }
class C : I3 { public void M(int x, string y) { } }";

            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class B { public virtual void M(string y, int x) { } }
class D : B, I { public override void M(string y, int x) { } }
class D2 : D { public override void M(string y, int x) { } }
class D3 : D { public override void M(string y, int x) { } }
interface I { void M(string y, int x); }
interface I2 { void M(string y, int x); }
interface I3 : I, I2 { }
class C : I3 { public void M(string y, int x) { } }";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #7
0
        public void ReorderIndexerParameters_InvokeOnReference_InArgumentList()
        {
            var markup = @"
class Program
{
    void M(Program p)
    {
        var t = p[5, ""test""$$];
    }

    int this[int x, string y]
    {
        get { return 5; }
        set { }
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class Program
{
    void M(Program p)
    {
        var t = p[""test"", 5];
    }

    int this[string y, int x]
    {
        get { return 5; }
        set { }
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #8
0
        public void ReorderMethodParameters_InvokeOnReference_CallToBaseConstructor()
        {
            var markup = @"
class B
{
    public B(int a, int b)
    {
    }
}

class D : B
{
    public D(int x, int y) : base(1, 2)$$
    {
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class B
{
    public B(int b, int a)
    {
    }
}

class D : B
{
    public D(int x, int y) : base(2, 1)
    {
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #9
0
        public void ReorderIndexerParameters_InvokeInAccessor()
        {
            var markup = @"
class Program
{
    int this[int x, string y]
    {
        get { return $$5; }
        set { }
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class Program
{
    int this[string y, int x]
    {
        get { return 5; }
        set { }
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #10
0
        public void ReorderMethodParameters_InvokeOnReference_CallToOtherConstructor()
        {
            var markup = @"
class Program
{
    public Program(int x, int y) : this(1, 2, 3)$$
    {
    }

    public Program(int x, int y, int z)
    {
    }
}";
            var permutation = new[] { 2, 1, 0 };
            var updatedCode = @"
class Program
{
    public Program(int x, int y) : this(3, 2, 1)
    {
    }

    public Program(int z, int y, int x)
    {
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #11
0
        public void ReorderMethodParameters_InvokeOnReference_OnlyHasCandidateSymbols()
        {
            var markup = @"
class Test
{
    void M(int x, string y) { }
    void M(int x, double y) { }
    void M2() { $$M(""s"", 1); }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
class Test
{
    void M(string y, int x) { }
    void M(int x, double y) { }
    void M2() { M(1, ""s""); }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #12
0
        public void ReorderMethodParameters_InvokeOnReference_Attribute()
        {
            var markup = @"
using System;

[$$My(1, 2)]
class MyAttribute : Attribute
{
    public MyAttribute(int x, int y)
    {
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
using System;

[My(2, 1)]
class MyAttribute : Attribute
{
    public MyAttribute(int y, int x)
    {
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #13
0
        public void ReorderMethodParameters_InvokeOnReference_NestedCalls3()
        {
            var markup = @"
using System;
class MyClass
{
    public void Foo(int x, string y)
    {
        Bar(Baz(x, y), $$y);
    }

    public void Bar(int x, string y)
    {
    }

    public int Baz(int x, string y)
    {
        return 1;
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
using System;
class MyClass
{
    public void Foo(int x, string y)
    {
        Bar(y, Baz(x, y));
    }

    public void Bar(string y, int x)
    {
    }

    public int Baz(int x, string y)
    {
        return 1;
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
コード例 #14
0
        public void ReorderMethodParameters_InvokeOnReference_ArgumentList()
        {
            var markup = @"
using System;
class MyClass
{
    public void Foo(int x, string y)
    {
        $$Bar(x, y);
    }

    public void Bar(int x, string y)
    {
    }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
using System;
class MyClass
{
    public void Foo(int x, string y)
    {
        Bar(y, x);
    }

    public void Bar(string y, int x)
    {
    }
}";

            TestReorderParameters(LanguageNames.CSharp, markup, permutation: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }