public void InactiveIf() { string program = @"namespace NS { #if SOMETHING class A {} #endif }"; NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal <NamespaceDeclaration>(program); Assert.AreEqual(0, ns.Members.Count); Assert.AreEqual(new Role[] { Roles.NamespaceKeyword, Roles.Identifier, Roles.LBrace, Roles.PreProcessorDirective, Roles.Comment, Roles.PreProcessorDirective, Roles.RBrace }, ns.Children.Select(c => c.Role).ToArray()); var pp = ns.GetChildrenByRole(Roles.PreProcessorDirective); Assert.AreEqual(PreProcessorDirectiveType.If, pp.First().Type); Assert.IsFalse(pp.First().Take); Assert.AreEqual("SOMETHING", pp.First().Argument); Assert.AreEqual(new TextLocation(2, 2), pp.First().StartLocation); Assert.AreEqual(new TextLocation(2, 15), pp.First().EndLocation); var comment = ns.GetChildByRole(Roles.Comment); Assert.AreEqual(CommentType.InactiveCode, comment.CommentType); Assert.AreEqual(new TextLocation(3, 1), comment.StartLocation); Assert.AreEqual(new TextLocation(4, 2), comment.EndLocation); Assert.AreEqual("\tclass A {}\n\t", comment.Content.Replace("\r", "")); Assert.AreEqual(PreProcessorDirectiveType.Endif, pp.Last().Type); Assert.AreEqual(string.Empty, pp.Last().Argument); Assert.AreEqual(new TextLocation(4, 2), pp.Last().StartLocation); Assert.AreEqual(new TextLocation(4, 8), pp.Last().EndLocation); }