Ejemplo n.º 1
0
        public void DeleteRegionsUsingRewriterElastic()
        {
            var        tree    = SyntaxFactory.ParseSyntaxTree(@"
using System;
#region Program
class Program
{
    #region Main
    static void Main()
    {
    }
    #endregion
}
#endregion
#region Other
class C
{
}
#endregion");
            SyntaxNode oldRoot = tree.GetRoot();

            var expected = @"
using System;

class Program
{
    static void Main()
    {
    }
}

class C
{
}
";
            CSharpSyntaxRewriter rewriter = new RegionRemover1();
            SyntaxNode           newRoot  = rewriter.Visit(oldRoot);

            newRoot = Formatter.Format(newRoot, SyntaxAnnotation.ElasticAnnotation, new AdhocWorkspace());
            Assert.AreEqual(expected, newRoot.ToFullString());
        }
        public void DeleteRegionsUsingRewriterElastic()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
            using System;
            #region Program
            class Program
            {
            #region Main
            static void Main()
            {
            }
            #endregion
            }
            #endregion
            #region Other
            class C
            {
            }
            #endregion");
            SyntaxNode oldRoot = tree.GetRoot();

            var expected = @"
            using System;

            class Program
            {
            static void Main()
            {
            }
            }

            class C
            {
            }
            ";
            CSharpSyntaxRewriter rewriter = new RegionRemover1();
            SyntaxNode newRoot = rewriter.Visit(oldRoot);
            newRoot = Formatter.Format(newRoot, SyntaxAnnotation.ElasticAnnotation, new AdhocWorkspace());
            Assert.AreEqual(expected, newRoot.ToFullString());
        }
Ejemplo n.º 3
0
        public void DeleteRegionsUsingRewriter()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
using System;
#region Program
class Program
{
    static void Main()
    {
    }
}
#endregion
#region Other
class C
{
}
#endregion");
            SyntaxNode oldRoot = tree.GetRoot();

            var expected = @"
using System;
class Program
{
    static void Main()
    {
    }
}
class C
{
}
";
            CSharpSyntaxRewriter rewriter = new RegionRemover1();
            SyntaxNode newRoot = rewriter.Visit(oldRoot);
            Assert.Equal(expected, newRoot.ToFullString());

            rewriter = new RegionRemover2();
            newRoot = rewriter.Visit(oldRoot);
            Assert.Equal(expected, newRoot.ToFullString());
        }