Ejemplo n.º 1
0
        /// <summary>
        /// Updates the assembly info file with the new information passed, i.e. a new version number
        /// and a new comment.
        /// </summary>
        /// <param name="projectFolder">Pathname of the folder containing the project <c>.sln</c> file</param>
        /// <param name="version">Version to be inserted in the file.</param>
        /// <param name="comment">Comment about the current compilation.</param>
        public static void UpdateAssemblyInfo(string projectFolder, AssemblyVersion version, string comment, IInfoProcessor iinfoProcessor)
        {
            string filePath   = Path.Combine(projectFolder, iinfoProcessor.RelativeInfoFilePath);
            string backupPath = filePath + ".bak";

            try
            {
                File.Copy(filePath, backupPath, true);

                using (TextReader reader = new StreamReader(backupPath))
                {
                    using (TextWriter writer = new StreamWriter(filePath, false, iinfoProcessor.WriteEncoding))
                    {
                        string line;
                        iinfoProcessor.InitLoading();
                        while ((line = reader.ReadLine()) != null)
                        {
                            iinfoProcessor.ProcessLine(writer, line, version, comment);
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Impossible to write AssemblyInfo file");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyVersion" /> class.<para/>
 /// Copy initializer version.
 /// </summary>
 /// <param name="other">Assembly version object to be duplicated.</param>
 public AssemblyVersion(AssemblyVersion other)
 {
     this.Major    = other.Major;
     this.Minor    = other.Minor;
     this.Build    = other.Build;
     this.Revision = other.Revision;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Increments the revision component of the current version.<para/>
        /// The revision component is the rightmost number.
        /// </summary>
        /// <returns>An object representing the current version with incremented revision number.</returns>
        public AssemblyVersion Next()
        {
            AssemblyVersion result = new AssemblyVersion(this);

            if (result.Revision == uint.MaxValue)
            {
                throw new OverflowException("The revision number is overflowing");
            }

            result.Revision++;
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Processes each single line in the AssemblyInfo source code.
        /// </summary>
        /// <param name="writer">The writer where the new info file must be stored.</param>
        /// <param name="line">The line to be processed.</param>
        /// <param name="version">The new version number.</param>
        /// <param name="comment">The comment to add.</param>
        public override void ProcessLine(TextWriter writer, string line, AssemblyVersion version, string comment)
        {
            if (line.StartsWith(AssemblyVersionSignature))
            {
                writer.Write(AssemblyVersionSignature);
                writer.Write('"');
                writer.Write(version);
                writer.WriteLine("\")]");
            }
            else if (line.StartsWith(AssemblyFileVersionSignature))
            {
                writer.Write(AssemblyFileVersionSignature);
                writer.Write('"');
                writer.Write(version);
                writer.WriteLine("\")]");

                writer.WriteLine("//// " + version + "  Compiled by [" + App.TheUser + "] " + DateTime.Now);
                if (comment != null)
                {
                    foreach (string commentLine in comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        writer.WriteLine("//// " + commentLine);
                    }
                }
            }
            else if (line.StartsWith(StartOfTodoSignature))
            {
                writer.WriteLine(line);
                this.loadingTodoList = true;
            }
            else if (line.StartsWith(TodoParam))
            {
                return;
            }
            else if (this.loadingTodoList)
            {
                if (line.StartsWith(EndOfTodos) || (!line.StartsWith(StartOfTodoFollowing)))
                {
                    this.loadingTodoList = false;

                    ThingTodo.ForEach((todo) =>
                    {
                        string[] todoLines = todo.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        writer.Write(StartOfTodoContent);
                        writer.Write(todo.IsDone ? 'X' : ' ');
                        writer.Write("] ");
                        writer.WriteLine(todoLines[0]);
                        if (todoLines.Length > 1)
                        {
                            for (int i = 1; i < todoLines.Length; i++)
                            {
                                writer.Write(StartOfTodoFollowing);
                                writer.Write(' ');
                                writer.WriteLine(todoLines[i]);
                            }
                        }
                    });

                    writer.WriteLine(EndOfTodos);
                    ProgramProperty.ForEach((property, value) =>
                    {
                        writer.Write(TodoParam);
                        writer.Write(' ');
                        writer.Write(property);
                        writer.Write('=');
                        writer.WriteLine(value);
                    });
                }
                else
                {
                    this.loadingTodoList = line.StartsWith(StartOfTodoFollowing);
                }
            }
            else
            {
                writer.WriteLine(line);
            }
        }
Ejemplo n.º 5
0
        public override void ProcessLine(TextWriter writer, string line, AssemblyVersion version, string comment)
        {
            if (line.Trim().StartsWith(AssemblyVersionSignature))
            {
                writer.WriteLine(string.Format("#define VER_FILEVERSION             {0},{1},{2},{3}", version.Major, version.Minor, version.Build, version.Revision));
                writer.WriteLine(string.Format("#define THEFILEVERSION             \"{0}.{1}.{2}.{3}\\0\"", version.Major, version.Minor, version.Build, version.Revision));
            }
            else if (line.StartsWith(StartOfTodoSignature))
            {
                writer.WriteLine(line);
                this.loadingTodoList = true;
            }
            else if (line.StartsWith(TodoParam))
            {
                return;
            }
            else if (line.StartsWith(AssemblyVersionSignatureString))
            {
                return;
            }
            else if (this.loadingTodoList)
            {
                if (line.StartsWith(EndOfTodos) || (!line.StartsWith(StartOfTodoFollowing)))
                {
                    this.loadingTodoList = false;

                    ThingTodo.ForEach((todo) =>
                    {
                        string[] todoLines = todo.Description.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        writer.Write(StartOfTodoContent);
                        writer.Write(todo.IsDone ? 'X' : ' ');
                        writer.Write("] ");
                        writer.WriteLine(todoLines[0]);
                        if (todoLines.Length > 1)
                        {
                            for (int i = 1; i < todoLines.Length; i++)
                            {
                                writer.Write(StartOfTodoFollowing);
                                writer.Write(' ');
                                writer.WriteLine(todoLines[i]);
                            }
                        }
                    });

                    writer.WriteLine(EndOfTodos);
                    ProgramProperty.ForEach((property, value) =>
                    {
                        writer.Write(TodoParam);
                        writer.Write(' ');
                        writer.Write(property);
                        writer.Write('=');
                        writer.WriteLine(value);
                    });
                }
                else
                {
                    this.loadingTodoList = line.StartsWith(StartOfTodoFollowing);
                }
            }
            else
            {
                if (!this.writtenComments && line.Contains("Compiled by ["))
                {
                    writer.WriteLine("// " + version + "  Compiled by [" + App.TheUser + "] " + DateTime.Now);
                    if (comment != null)
                    {
                        foreach (string commentLine in comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            writer.WriteLine("// " + commentLine);
                        }
                    }

                    this.writtenComments = true;
                }
                writer.WriteLine(line);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Processes each single line in the AssemblyInfo source code.
 /// </summary>
 /// <param name="writer">The writer where the new info file must be stored.</param>
 /// <param name="line">The line to be processed.</param>
 /// <param name="version">The new version number.</param>
 /// <param name="comment">The comment to add.</param>
 public abstract void ProcessLine(TextWriter writer, string line, AssemblyVersion version, string comment);