Beispiel #1
0
        private void CheckOptions(string file, string[] options)
        {
            try {
                StreamReader reader = new StreamReader(file);

                String line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("/* CSharpCCOptions:"))
                    {
                        String currentOptions = Options.GetOptionsString(options);
                        if (line.IndexOf(currentOptions) == -1)
                        {
                            CSharpCCErrors.Warning(Path.GetFileName(file)
                                                   + ": Generated using incompatible options. Please rename or delete this file so"
                                                   + " that a new one can be generated for you.");
                        }
                        return;
                    }
                }
            } catch (FileNotFoundException e1) {
                // This should never happen
                CSharpCCErrors.SemanticError("Could not open file " + Path.GetFileName(file)
                                             + " for writing.");
                throw new InvalidOperationException();
            } catch (IOException e2) {
            }

            // Not found so cannot check
        }
Beispiel #2
0
        private void CheckVersion(string file, String versionId)
        {
            String firstLine = "/* " + CSharpCCGlobals.GetIdString(ToolName, Path.GetFileName(file)) + " Version ";

            try {
                StreamReader reader = new StreamReader(file);

                String line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith(firstLine))
                    {
                        String version = firstLine.Replace(".* Version ", "").Replace(" \\*/", "");
                        if (version != versionId)
                        {
                            CSharpCCErrors.Warning(Path.GetFileName(file)
                                                   + ": File is obsolete.  Please rename or delete this file so"
                                                   + " that a new one can be generated for you.");
                        }
                        return;
                    }
                }
                // If no version line is found, do not output the warning.
            } catch (FileNotFoundException) {
                // This should never happen
                CSharpCCErrors.SemanticError("Could not open file " + Path.GetFileName(file) + " for writing.");
                throw new InvalidOperationException();
            } catch (IOException) {
            }
        }