diff --git a/.gitignore b/.gitignore index 84e9edd9f51..fd23a9aaa49 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ bin/ /src/Main/ICSharpCode.SharpDevelop.Sda/ICSharpCode.SharpDevelop.Sda.dll.config /src/Main/StartUp/Project/SharpDevelop.exe.config /src/Main/GlobalAssemblyInfo.cs +/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.cs diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.template b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.template new file mode 100644 index 00000000000..595cfce8132 --- /dev/null +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.template @@ -0,0 +1,17 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UsageDataCollector +{ + partial class AnalyticsMonitor + { + const string BranchName = "$INSERTBRANCHNAME$"; + const string CommitHash = "$INSERTCOMMITHASH$"; + } +} diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs index 0b59d896449..97eb7193e41 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.UsageDataCollector /// /// Main singleton class of the analytics. This class is thread-safe. /// - public sealed class AnalyticsMonitor : IAnalyticsMonitor + public sealed partial class AnalyticsMonitor : IAnalyticsMonitor { const string UploadUrl = "http://usagedatacollector.sharpdevelop.net/upload/UploadUsageData.svc"; const string ProductName = "sharpdevelop"; @@ -120,10 +120,12 @@ public void OpenSession() static IEnumerable GetAppProperties() { List properties = new List { - new UsageDataEnvironmentProperty { Name = "appVersion", Value = RevisionClass.FullVersion }, + new UsageDataEnvironmentProperty { Name = "appVersion", Value = RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision }, new UsageDataEnvironmentProperty { Name = "language", Value = ResourceService.Language }, new UsageDataEnvironmentProperty { Name = "culture", Value = CultureInfo.CurrentCulture.Name }, - new UsageDataEnvironmentProperty { Name = "userAddInCount", Value = AddInTree.AddIns.Where(a => !a.IsPreinstalled).Count().ToString() } + new UsageDataEnvironmentProperty { Name = "userAddInCount", Value = AddInTree.AddIns.Where(a => !a.IsPreinstalled).Count().ToString() }, + new UsageDataEnvironmentProperty { Name = "branch", Value = BranchName }, + new UsageDataEnvironmentProperty { Name = "commit", Value = CommitHash } }; string PROCESSOR_ARCHITECTURE = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"); if (string.IsNullOrEmpty(PROCESSOR_ARCHITECTURE)) { @@ -132,11 +134,6 @@ static IEnumerable GetAppProperties() if (!string.IsNullOrEmpty(PROCESSOR_ARCHITECTURE)) { properties.Add(new UsageDataEnvironmentProperty { Name = "architecture", Value = PROCESSOR_ARCHITECTURE }); } - #pragma warning disable 0162 - if (RevisionClass.BranchName != null) { - properties.Add(new UsageDataEnvironmentProperty { Name = "branch", Value = RevisionClass.BranchName }); - } - #pragma warning restore 0162 #if DEBUG properties.Add(new UsageDataEnvironmentProperty { Name = "debug", Value = "true" }); #endif diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/UsageDataCollector.AddIn.csproj b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/UsageDataCollector.AddIn.csproj index 84550e75512..1a096aaad9b 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/UsageDataCollector.AddIn.csproj +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/UsageDataCollector.AddIn.csproj @@ -5,7 +5,7 @@ Debug AnyCPU Library - UsageDataCollector.AddIn + ICSharpCode.UsageDataCollector UsageDataCollector.AddIn v4.0 ..\..\..\..\..\AddIns\Misc\UsageDataCollector\ @@ -56,6 +56,9 @@ GlobalAssemblyInfo.cs + + AnalyticsMonitor.AppProperties.template + @@ -67,6 +70,7 @@ + Always diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj index 13db5fb770b..c5b4df48520 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj @@ -22,6 +22,7 @@ -Microsoft.Design#CA1020;-Microsoft.Design#CA1033;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810 ..\..\..\..\bin\ ..\..\..\..\bin\ICSharpCode.AvalonEdit.xml + 1607 true diff --git a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Properties/AssemblyInfo.cs b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Properties/AssemblyInfo.cs index 49469d7d903..ebe7358ae32 100644 --- a/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Properties/AssemblyInfo.cs +++ b/src/Libraries/SharpTreeView/ICSharpCode.TreeView/Properties/AssemblyInfo.cs @@ -34,18 +34,6 @@ )] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] - [assembly: XmlnsPrefix("http://icsharpcode.net/sharpdevelop/treeview", "treeview")] [assembly: XmlnsDefinition("http://icsharpcode.net/sharpdevelop/treeview", "ICSharpCode.TreeView")] diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/AddInReference.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/AddInReference.cs index 1a056b42c4d..e4901a0f557 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/AddInReference.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/AddInReference.cs @@ -112,7 +112,7 @@ internal static Version ParseVersion(string version, string hintPath) if (version.StartsWith("@")) { if (version == "@SharpDevelopCoreVersion") { if (entryVersion == null) - entryVersion = new Version(RevisionClass.FullVersion); + entryVersion = new Version(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision); return entryVersion; } if (hintPath != null) { diff --git a/src/Main/GlobalAssemblyInfo.template b/src/Main/GlobalAssemblyInfo.template index 791a1c132aa..677c6701d48 100644 --- a/src/Main/GlobalAssemblyInfo.template +++ b/src/Main/GlobalAssemblyInfo.template @@ -21,7 +21,8 @@ using System.Reflection; [assembly: AssemblyCompany("ic#code")] [assembly: AssemblyProduct("SharpDevelop")] [assembly: AssemblyCopyright("2000-$INSERTYEAR$ AlphaSierraPapa for the SharpDevelop Team")] -[assembly: AssemblyVersion(RevisionClass.FullVersion)] +[assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)] +[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-$INSERTSHORTCOMMITHASH$")] [assembly: NeutralResourcesLanguage("en-US")] internal static class RevisionClass @@ -31,8 +32,5 @@ internal static class RevisionClass public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string MainVersion = Major + "." + Minor; - public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; - - public const string BranchName = null; + public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$"; } diff --git a/src/Main/StartUp/Project/Dialogs/SplashScreen.cs b/src/Main/StartUp/Project/Dialogs/SplashScreen.cs index 5963bddb1b7..2e589c01c52 100644 --- a/src/Main/StartUp/Project/Dialogs/SplashScreen.cs +++ b/src/Main/StartUp/Project/Dialogs/SplashScreen.cs @@ -31,7 +31,6 @@ public class SplashScreenForm : Form public SplashScreenForm() { const string versionText = "SharpDevelop" - + (RevisionClass.BranchName != null ? "-" + RevisionClass.BranchName : "") + " " + RevisionClass.FullVersion #if DEBUG + " (debug)" diff --git a/src/Main/StartUp/Project/SharpDevelopMain.cs b/src/Main/StartUp/Project/SharpDevelopMain.cs index 2a6d89deebf..ee61a913ce8 100644 --- a/src/Main/StartUp/Project/SharpDevelopMain.cs +++ b/src/Main/StartUp/Project/SharpDevelopMain.cs @@ -158,14 +158,14 @@ static void RunApplication() string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; if (String.IsNullOrEmpty(configDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "ICSharpCode/SharpDevelop" + RevisionClass.MainVersion); + "ICSharpCode/SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); } startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { - startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.MainVersion); + startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index d1780e1f188..981323378df 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -72,6 +72,7 @@ Configuration\GlobalAssemblyInfo.cs + GlobalAssemblyInfo.template diff --git a/src/Tools/UpdateAssemblyInfo/Main.cs b/src/Tools/UpdateAssemblyInfo/Main.cs index 9ead72ba13e..cbe149aa701 100644 --- a/src/Tools/UpdateAssemblyInfo/Main.cs +++ b/src/Tools/UpdateAssemblyInfo/Main.cs @@ -47,6 +47,10 @@ class MainClass Input = "doc/ChangeLog.template.html", Output = "doc/ChangeLog.html" }, + new TemplateFile { + Input = "src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.template", + Output = "src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.AppProperties.cs" + } }; class TemplateFile @@ -86,7 +90,8 @@ public static int Main(string[] args) "versionInfo", new XElement("version", fullVersionNumber), new XElement("revision", revisionNumber), - new XElement("commitHash", gitCommitHash) + new XElement("commitHash", gitCommitHash), + new XElement("branchName", gitBranchName) )); doc.Save("REVISION"); } @@ -108,8 +113,12 @@ static void UpdateFiles() content = content.Replace("$INSERTVERSION$", fullVersionNumber); content = content.Replace("$INSERTREVISION$", revisionNumber); content = content.Replace("$INSERTCOMMITHASH$", gitCommitHash); + content = content.Replace("$INSERTSHORTCOMMITHASH$", gitCommitHash.Substring(0, 8)); content = content.Replace("$INSERTDATE$", DateTime.Now.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture)); content = content.Replace("$INSERTYEAR$", DateTime.Now.Year.ToString()); + content = content.Replace("$INSERTBRANCHNAME$", gitBranchName); + bool isDefaultBrach = string.IsNullOrEmpty(gitBranchName) || gitBranchName == "master" || char.IsDigit(gitBranchName, 0); + content = content.Replace("$INSERTBRANCHPOSTFIX$", isDefaultBrach ? "" : ("-" + gitBranchName)); if (File.Exists(file.Output)) { using (StreamReader r = new StreamReader(file.Output)) { if (r.ReadToEnd() == content) { @@ -173,12 +182,14 @@ static void SetVersionInfo(string fileName, Regex regex, string replacement) static string revisionNumber; static string fullVersionNumber; static string gitCommitHash; + static string gitBranchName; static void RetrieveRevisionNumber() { if (revisionNumber == null) { if (Directory.Exists(".git")) { ReadRevisionNumberFromGit(); + ReadBranchNameFromGit(); } else { Console.WriteLine("There's no git working copy in " + Path.GetFullPath(".")); } @@ -192,7 +203,7 @@ static void RetrieveRevisionNumber() static void ReadRevisionNumberFromGit() { - ProcessStartInfo info = new ProcessStartInfo("cmd", "/c git rev-list --first-parent " + BaseCommit + "..HEAD"); + ProcessStartInfo info = new ProcessStartInfo("cmd", "/c git rev-list " + BaseCommit + "..HEAD"); string path = Environment.GetEnvironmentVariable("PATH"); path += ";" + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "git\\bin"); info.EnvironmentVariables["PATH"] = path; @@ -215,12 +226,35 @@ static void ReadRevisionNumberFromGit() } } + static void ReadBranchNameFromGit() + { + ProcessStartInfo info = new ProcessStartInfo("cmd", "/c git branch"); + string path = Environment.GetEnvironmentVariable("PATH"); + path += ";" + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "git\\bin"); + info.EnvironmentVariables["PATH"] = path; + info.RedirectStandardOutput = true; + info.UseShellExecute = false; + using (Process p = Process.Start(info)) { + string line; + gitBranchName = "(no branch)"; + while ((line = p.StandardOutput.ReadLine()) != null) { + if (line.StartsWith("* ", StringComparison.Ordinal)) { + gitBranchName = line.Substring(2); + } + } + p.WaitForExit(); + if (p.ExitCode != 0) + throw new Exception("git-branch exit code was " + p.ExitCode); + } + } + static void ReadRevisionFromFile() { try { XDocument doc = XDocument.Load("REVISION"); revisionNumber = (string)doc.Root.Element("revision"); gitCommitHash = (string)doc.Root.Element("commitHash"); + gitBranchName = (string)doc.Root.Element("branchName"); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine();