public void InitializedElementStyleDictionaryIndexer(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    using System.Collections.Generic;

    internal class Foo
    {
        internal Foo()
        {
            var ints = new Dictionary<int, int> 
            { 
                [1] = 1,
                [2] = 2,
            };
            var temp1 = ints[0];
            ints[3] = 3;
            var temp2 = ints[0];
        }
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code)
                                    .Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void InitializedListOfIntIndexerAfterAddItem(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    using System.Collections.Generic;

    internal class Foo
    {
        internal Foo()
        {
            var ints = new List<int> { 1, 2 };
            var temp1 = ints[0];
            ints.Add(3);
            var temp2 = ints[0];
        }
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code)
                                    .Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void LocalAssignedWithRefParameter(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    internal Foo()
    {
        int value;
        var temp1 = value;
        Assign(ref value);
        var temp2 = value;
    }

    internal void Assign(ref int value)
    {
        value = 1;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void FieldInitializedlWithLiteralAndAssignedInCtor(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    private readonly int value = 1;
    private readonly int temp1 = this.value;

    internal Foo()
    {
        var temp1 = this.value;
        var temp2 = this.temp1;
        this.value = 2;
        var temp3 = this.value;
        var temp4 = this.temp1;
    }

    internal void Bar()
    {
        var temp5 = this.value;
        var temp6 = this.temp1;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
        public void BackingFieldPrivateSetSimple()
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    public sealed class Foo
    {
        private int bar;

        public int Bar
        {
            get { return this.bar; }
            private set { this.bar = value; }
        }

        public void Meh()
        {
            var temp = this.bar;
        }
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);
            var value         = syntaxTree.EqualsValueClause("var temp = this.bar").Value;

            using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
            {
                var actual = string.Join(", ", pooled.Item);
                Assert.AreEqual(string.Empty, actual);
            }
        }
Exemplo n.º 6
0
            public void InitializedWithConstant(string code)
            {
                var testCode = @"
namespace RoslynSandbox
{
    internal class Foo
    {
        private const int Value = 2;

        internal Foo()
        {
            var value = 1;
            var temp = value;
        }
    }
}";

                testCode = testCode.AssertReplace("1", code);
                var syntaxTree    = CSharpSyntaxTree.ParseText(testCode);
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause("var temp = value;").Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(code, actual);
                }
            }
            public void LocalAssignedWithOutParameterGeneric()
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo<T>
{
    internal Foo()
    {
        T value;
        Assign(out value);
        var temp = value;
    }

    internal void Assign(out T outValue)
    {
        outValue = default(T);
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause("var temp = value;").Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
#pragma warning disable GU0006 // Use nameof.
                    Assert.AreEqual("value", actual);
#pragma warning restore GU0006 // Use nameof.
                }
            }
            public void FieldPublicCtorFactory(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    public int value = 1;

    public Foo(int ctorArg)
    {
        var temp1 = this.value;
        this.value = ctorArg;
        var temp2 = this.value;
    }

    internal static Foo Create()
    {
        return new Foo(2);
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
        public void AutoPropertyGetOnlyAssignedInCtor(string code, string expected)
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
public sealed class Foo
{
    public Foo()
    {
        var temp1 = this.Bar;
        this.Bar = 2;
        var temp2 = this.Bar;
    }

    public int Bar { get; } = 1;

    public void Meh()
    {
        var temp3 = this.Bar;
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);
            var value         = syntaxTree.EqualsValueClause(code).Value;

            using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
            {
                var actual = string.Join(", ", pooled.Item);
                Assert.AreEqual(expected, actual);
            }
        }
            public void FieldCtorArgThenIdMethod(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    private readonly int value;

    internal Foo(int arg)
    {
        var temp1 = this.value;
        this.value = Id(arg);
        var temp2 = this.value;
    }

    internal void Bar(int arg)
    {
        var temp3 = this.value;
    }

    private static T Id(T genericArg) => genericArg;
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void InitializedInChainedWithLiteralGeneric(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo<T>
{
    internal Foo()
    {
        this.Value = 2;
    }

    internal Foo(string text)
        : this()
    {
        this.Value = 3;
        var temp1 = this.Value;
        this.Value = 4;
    }

    public int Value { get; set; } = 1;

    internal void Bar()
    {
        var temp2 = this.Value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
        public void BackingFieldPublicSetInitializedAndPropertyAssignedInCtorWeirdSetter(string code, string expected)
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    public sealed class Foo
    {
        private int bar = 1;

        public Foo()
        {
            var temp1 = this.bar;
            var temp2 = this.Bar;
            this.Bar = 2;
            var temp3 = this.bar;
            var temp4 = this.Bar;
        }

        public int Bar
        {
            get { return this.bar; }
            set
            {
                if (true)
                {
                    this.bar = value;
                }
                else
                {
                    this.bar = value;
                }

                this.bar = value / 2;
                this.bar = 3;
            }
        }

        public void Meh()
        {
            var temp5 = this.bar;
            var temp6 = this.Bar;
        }
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);
            var value         = syntaxTree.EqualsValueClause(code).Value;

            using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
            {
                var actual = string.Join(", ", pooled.Item);
                Assert.AreEqual(expected, actual);
            }
        }
            public void AutoPropertyChainedCtor(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    internal Foo()
    {
        var temp1 = this.Value;
        this.Value = 2;
        var temp2 = this.Value;
        this.Bar(3);
        var temp3 = this.Value;
    }

    internal Foo(string text)
        : this()
    {
        var temp4 = this.Value;
        this.Value = 4;
        var temp5 = this.Value;
        this.Value = 5;
        var temp6 = this.Value;
        this.Bar(6);
        var temp7 = this.Value;
        this.Bar(7);
        var temp8 = this.Value;
    }

    public int Value { get; set; } = 1;

    internal void Bar(int arg)
    {
        var temp9 = this.Value;
        this.Value = 8;
        var temp10 = this.Value;
        this.Value = arg;
        var temp11 = this.Value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
Exemplo n.º 14
0
            public void AssignedInLock()
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    using System;

    public class Foo : IDisposable
    {
        private readonly object gate;

        public IDisposable disposable;
        private bool disposed;

        public void Dispose()
        {
            if (this.disposed)
            {
                return;
            }

            var toDispose = (IDisposable)null;
            lock (this.gate)
            {
                if (this.disposed)
                {
                    return;
                }

                this.disposed = true;
                toDispose = this.disposable;
                this.disposable = null;
            }

            var temp = toDispose;
        }
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause("var temp = toDispose;").Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual("(IDisposable)null, this.disposable", actual);
                }
            }
            public void FieldImplicitBaseWhenSubclassHasCtor(string code, object expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class FooBase
{
    protected readonly int value = 1;

    internal FooBase()
    {
        var temp1 = this.value;
        this.value = 2;
        var temp2 = this.value;
    }
}

internal class Foo : FooBase
{
    internal Foo()
    {
        var temp3 = this.value;
        this.value = 3;
        var temp4 = this.value;
        this.value = 4;
        var temp5 = this.value;
    }

    internal void Bar(int arg)
    {
        var temp6 = this.value;
        this.value = 5;
        var temp7 = this.value;
        this.value = arg;
        var temp8 = this.value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void FieldCtorCallingProtectedInitializeMethod(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    public int value = 1;

    internal Foo()
    {
        var temp1 = this.value;
        this.Initialize(2);
        var temp4 = this.value;
        this.value = 3;
        var temp5 = this.value;
        this.Initialize(4);
        var temp6 = this.value;
    }

    internal void Bar(int arg)
    {
        var temp7 = this.value;
        this.value = 5;
        var temp8 = this.value;
        this.value = arg;
        var temp9 = this.value;
    }

    protected void Initialize(int initArg)
    {
        var temp2 = this.value;
        this.value = initArg;
        var temp3 = this.value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void InitializedInExplicitBaseCtorWithLiteral(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class FooBase
{
    protected readonly int value = 1;
    
    public FooBase()
    {
        this.value = -1;
    }

    public FooBase(int value)
    {
        this.value = value;
    }
}

internal class Foo : FooBase
{
    internal Foo()
        :base(2)
    {
        this.value = 3;
        var temp1 = this.value;
        this.value = 4;
    }

    internal void Bar()
    {
        var temp2 = this.value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
Exemplo n.º 18
0
            public void FieldChainedCtorGenericClass(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo<T>
{
    public int value = 1;

    internal Foo()
    {
        var temp1 = this.value;
        this.value = 2;
        var temp2 = this.value;
    }

    internal Foo(string text)
        : this()
    {
        var temp3 = this.value;
        this.value = 3;
        var temp4 = this.value;
        this.value = 4;
        var temp5 = this.value;
    }

    internal void Bar(int arg)
    {
        var temp6 = this.value;
        this.value = 5;
        var temp7 = this.value;
        this.value = arg;
        var temp8 = this.value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
Exemplo n.º 19
0
            public void AssignedWithArg()
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    internal Foo(int meh)
    {
        var temp = meh;
        var value = temp;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause("var value = temp").Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual("meh", actual);
                }
            }
Exemplo n.º 20
0
            public void InitializedWithDefaultGeneric()
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo<T>
{
    internal Foo()
    {
        var value = default(T);
        var temp = value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause("var temp = value;").Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual("default(T)", actual);
                }
            }
Exemplo n.º 21
0
            public void InitializedInBaseCtorWithDefaultGenericGeneric(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class FooBase<T>
{
    protected readonly T value;
    
    internal FooBase()
    {
        this.value = default(T);
    }

    internal FooBase(T value)
    {
        this.value = value;
    }
}

internal class Foo<T> : FooBase<T>
{
    internal Foo()
    {
        var temp1 = this.value;
    }

    internal void Bar()
    {
        var temp2 = this.value;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void FieldAssignedWithRefParameterArgument(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    internal class Foo
    {
        private int value = 1;

        public Foo()
        {
            var temp1 = this.value;
            this.Assign(ref this.value, 2);
            var temp2 = this.value;
        }

        internal void Bar()
        {
            var temp3 = this.value;
            this.Assign(ref this.value, 3);
            var temp4 = this.value;
        }

        private void Assign(ref int refValue, int arg)
        {
            refValue = arg;
        }
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
        public void BackingFieldPrivateSetInitializedAndAssignedInCtor(string code1, string expected)
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
public sealed class Foo
{
    private int bar = 1;

    public Foo()
    {
        var temp1 = this.bar;
        var temp2 = this.Bar;
        this.bar = 2;
        var temp3 = this.bar;
        var temp4 = this.Bar;
    }

    public int Bar
    {
        get { return this.bar; }
        private set { this.bar = value; }
    }

    public void Meh()
    {
        var temp5 = this.bar;
        var temp6 = this.Bar;
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
            var semanticModel = compilation.GetSemanticModel(syntaxTree);
            var value         = syntaxTree.EqualsValueClause(code1).Value;

            using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
            {
                var actual = string.Join(", ", pooled.Item);
                Assert.AreEqual(expected, actual);
            }
        }
            public void MethodInjectedWithOptionalAssigningOptional(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    private string text;

    internal Foo()
    {
        var temp1 = this.text;
        this.Update(1);
        var temp2 = this.text;
        this.Update(2, ""abc"");
        var temp3 = this.text;
    }

    internal void Bar()
    {
        var temp4 = this.text;
    }

    internal void Update(int arg, string textArg = null)
    {
        this.text = textArg;
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
            public void InitializedTypedArrayIndexer(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
internal class Foo
{
    internal Foo()
    {
        int[] ints = { 1, 2 };
        var temp1 = ints[0];
        ints[0] = 3;
        var temp2 = ints[0];
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code)
                                    .Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }
        public void RecursiveGetAndSet(string code, string expected)
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    public sealed class Foo
    {
        public Foo()
        {
            var temp1 = this.Bar;
            this.Bar = 2;
            var temp2 = this.Bar;
        }

        public int Bar
        {
            get { return this.Bar; }
            set { this.Bar = value; }
        }

        public void Meh()
        {
            var temp3 = this.Bar;
        }
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.All);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);
            var value         = syntaxTree.EqualsValueClause(code).Value;

            using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
            {
                var actual = string.Join(", ", pooled.Item);
                Assert.AreEqual(expected, actual);
            }
        }
            public void LocalAssignedWithChainedOutParameter(string code, string expected)
            {
                var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    internal class Foo
    {
        internal Foo()
        {
            int value;
            var temp1 = value;
            Assign1(out value, 1);
            var temp2 = value;
        }

        internal void Assign1(out int value1, int arg1)
        {
            Assign2(out value1, arg1);
        }

        internal void Assign2(out int value2, int arg2)
        {
            value2 = arg2;
        }
    }
}");
                var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
                var semanticModel = compilation.GetSemanticModel(syntaxTree);
                var value         = syntaxTree.EqualsValueClause(code).Value;

                using (var pooled = AssignedValueWalker.Create(value, semanticModel, CancellationToken.None))
                {
                    var actual = string.Join(", ", pooled.Item);
                    Assert.AreEqual(expected, actual);
                }
            }