Esempio n. 1
0
        private static bool CheckOrFixPragmas(string fileName, bool onlyCheck)
        {
            string        oldText = File.ReadAllText(fileName);
            StringBuilder sb      = new StringBuilder(oldText);

            PragmaFixing30.LooseComments(sb);
            Match match = PragmaFixing30.PragmaMatch(sb, "strict");

            if (!match.Success)
            {
                return(false);
            }
            bool success1 = PragmaFixing30.PragmaMatch(sb, "downcast").Success;
            bool success2 = PragmaFixing30.PragmaMatch(sb, "implicit").Success;

            if (success1 && success2)
            {
                return(false);
            }
            if (!onlyCheck)
            {
                PragmaFixing30.DoFixPragmasInFile(fileName, oldText, match.Index + match.Length, success1, success2);
            }
            return(true);
        }
Esempio n. 2
0
        private static bool CheckOrFixPragmas(string fileName, bool onlyCheck)
        {
            string        text = File.ReadAllText(fileName);
            StringBuilder sb   = new StringBuilder(text);

            PragmaFixing30.LooseComments(sb);
            Match match = PragmaFixing30.PragmaMatch(sb, "strict");
            bool  result;

            if (!match.Success)
            {
                result = false;
            }
            else
            {
                bool success  = PragmaFixing30.PragmaMatch(sb, "downcast").Success;
                bool success2 = PragmaFixing30.PragmaMatch(sb, "implicit").Success;
                if (success && success2)
                {
                    result = false;
                }
                else
                {
                    if (!onlyCheck)
                    {
                        PragmaFixing30.DoFixPragmasInFile(fileName, text, match.Index + match.Length, success, success2);
                    }
                    result = true;
                }
            }
            return(result);
        }