public static PreprocessingDirective VBToCSharp(PreprocessingDirective dir)
        {
            string cmd = dir.Cmd;
            string arg = dir.Arg;

            if (cmd.Equals("#End", StringComparison.InvariantCultureIgnoreCase))
            {
                if (arg.ToLowerInvariant().StartsWith("region"))
                {
                    cmd = "#endregion";
                    arg = "";
                }
                else if ("if".Equals(arg, StringComparison.InvariantCultureIgnoreCase))
                {
                    cmd = "#endif";
                    arg = "";
                }
            }
            else if (cmd.Equals("#Region", StringComparison.InvariantCultureIgnoreCase))
            {
                cmd = "#region";
            }
            else if (cmd.Equals("#If", StringComparison.InvariantCultureIgnoreCase))
            {
                cmd = "#if";
                if (arg.ToLowerInvariant().EndsWith(" then"))
                {
                    arg = arg.Substring(0, arg.Length - 5);
                }
            }
            else if (cmd.Equals("#Else", StringComparison.InvariantCultureIgnoreCase))
            {
                if (dir.Expression != null)
                {
                    cmd = "#elif";
                }
                else
                {
                    cmd = "#else";
                }
            }
            else if (cmd.Equals("#ElseIf", StringComparison.InvariantCultureIgnoreCase))
            {
                cmd = "#elif";
            }
            return(new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition)
            {
                Expression = dir.Expression
            });
        }
        public static PreprocessingDirective CSharpToVB(PreprocessingDirective dir)
        {
            string cmd = dir.Cmd;
            string arg = dir.Arg;

            switch (cmd)
            {
            case "#region":
                cmd = "#Region";
                if (!arg.StartsWith("\""))
                {
                    arg = "\"" + arg.Trim() + "\"";
                }
                break;

            case "#endregion":
                cmd = "#End";
                arg = "Region";
                break;

            case "#endif":
                cmd = "#End";
                arg = "If";
                break;

            case "#if":
                arg += " Then";
                break;
            }
            if (cmd.Length > 1)
            {
                cmd = cmd.Substring(0, 2).ToUpperInvariant() + cmd.Substring(2);
            }
            return(new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition)
            {
                Expression = dir.Expression
            });
        }