Example #1
0
        /// <summary>
        /// Initializes the assembly version info.
        /// </summary>
        private static AssemblyVersionInfo GetAssemblyVersionInfo()
        {
            var assemblyVersionInfo = new AssemblyVersionInfo();

            var versionInfoAttr = (Attribute.GetCustomAttribute(AssemblyHelper.ExecutingAssembly,
                                                                typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute);

            if (versionInfoAttr == null)
            {
                throw new InvalidOperationException(Resources.Error_MissingVersionInfo);
            }
            else
            {
                string[] versionInfoSplitted = versionInfoAttr.InformationalVersion
                                               .Split(new string[] { Resources.VersionInfoSplitter }, StringSplitOptions.RemoveEmptyEntries);

                assemblyVersionInfo.ReleaseID = Convert.ToInt32(
                    versionInfoSplitted[0].Split(new string[] { Resources.VersionInfoReleaseID }, StringSplitOptions.None)[1]);

                assemblyVersionInfo.DownloadID = Convert.ToInt32(
                    versionInfoSplitted[1].Split(new string[] { Resources.VersionInfoDownloadID }, StringSplitOptions.None)[1]);

                // Beta suffix can be empty
                assemblyVersionInfo.BetaSuffix =
                    versionInfoSplitted[2].Split(new string[] { Resources.VersionInfoBetaSuffix }, StringSplitOptions.None)[1];
            }

            return(assemblyVersionInfo);
        }
Example #2
0
        private string ListActiveMods()
        {
            var builder = new StringBuilder();

            builder.Append("Loaded mods:\n");
            foreach (var modContentPack in LoadedModManager.RunningMods)
            {
                builder.AppendFormat("{0}({1})", modContentPack.Name, modContentPack.PackageIdPlayerFacing);
                TryAppendOverrideVersion(builder, modContentPack);
                TryAppendManifestVersion(builder, modContentPack);
                builder.Append(": ");
                var firstAssembly = true;
                var anyAssemblies = false;
                foreach (var loadedAssembly in modContentPack.assemblies.loadedAssemblies)
                {
                    if (!firstAssembly)
                    {
                        builder.Append(", ");
                    }
                    firstAssembly = false;
                    builder.Append(loadedAssembly.GetName().Name);
                    builder.AppendFormat("({0})", AssemblyVersionInfo.ReadModAssembly(loadedAssembly, modContentPack));
                    anyAssemblies = true;
                }
                if (!anyAssemblies)
                {
                    builder.Append("(no assemblies)");
                }
                builder.Append("\n");
            }
            return(builder.ToString());
        }
        /// <summary>Initializes a new instance of the <see cref="ServiceProgram"/> class.</summary>
        public ServiceProgram()
            : base()
        {
            log.LogInfo("Initializing Service instance.");
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            var type = GetType();

            VersionInfo = AssemblyVersionInfo.FromAssembly(type.Assembly);

            ServiceName = StringExtensions.ReplaceInvalidChars(VersionInfo.Product, ASCII.Strings.Letters + ASCII.Strings.Digits + "_", "_");
        }
Example #4
0
        public AboutForm()
        {
            InitializeComponent();
            AssemblyVersionInfo appInfo = new AssemblyVersionInfo(typeof(DecoderApplication));
            AssemblyVersionInfo dcInfo  = new AssemblyVersionInfo(typeof(CdrDecoder));

            string rtf = Properties.Resources.CDR_Decoder;

            rtf             = rtf.Replace("@@1", String.Format("{0} {1}.{2} - (build {3})", appInfo.Title, appInfo.Version.Major, appInfo.Version.Minor, appInfo.LastBuildDate.ToString("yyMMdd-HHmm")));
            rtf             = rtf.Replace("@@2", appInfo.Copyright);
            rtf             = rtf.Replace("@@3", String.Format("{0} {1}.{2} - (build {3})", dcInfo.Title, dcInfo.Version.Major, dcInfo.Version.Minor, dcInfo.LastBuildDate.ToString("yyMMdd-HHmm")));
            rtf             = rtf.Replace("@@4", dcInfo.Copyright);
            richTextBox.Rtf = rtf;
        }
    public void VisualBasicGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "vb";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.42000
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

<Assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>
<Assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>
<Assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"#If NETFRAMEWORK  Or  NETCOREAPP  Or  NETSTANDARD2_0  Or  NETSTANDARD2_1 Then
<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>
<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>
Partial Friend NotInheritable Class ThisAssembly
#ElseIf NETSTANDARD  Or  NETFRAMEWORK  Or  NETCOREAPP Then
<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>
Partial Friend NotInheritable Class ThisAssembly
#Else
Partial Friend NotInheritable Class ThisAssembly
#End If
    Friend Const AssemblyCompany As String = ""company""
    Friend Const AssemblyFileVersion As String = ""1.3.1.0""
    Friend Const AssemblyVersion As String = ""1.3.0.0""
    Friend Const IsPrerelease As Boolean = False
    Friend Const IsPublicRelease As Boolean = False
    Friend Const RootNamespace As String = """"
End Class
" : "")}";

        Assert.Equal(expected, built);
    }
Example #6
0
    public void FSharpGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "f#";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyCompany = ""company""
  static member internal IsPublicRelease = false
  static member internal IsPrerelease = false
  static member internal RootNamespace = """"
do()
" : "")}";

        Assert.Equal(expected, built);
    }
Example #7
0
        public static void PopulateFromVersionInfo(this IAboutView view, AssemblyVersionInfo verInfo)
        {
            view.SetProgramName(verInfo.Name);

            view.SetVersion(verInfo.VersionBuild);

            view.SetDescription(verInfo.Description);

            view.SetCopyright(verInfo.Copyright);

            if (verInfo.VersionHistory != null)
            {
                view.SetVersionHistory(verInfo.VersionHistory);
            }
        }
Example #8
0
        static void Header()
        {
            if (m_HeaderDisplayed)
            {
                return;
            }
            m_HeaderDisplayed = true;
            if (Quiet)
            {
                return;
            }
            AssemblyVersionInfo v = AssemblyVersionInfo.FromAssembly(typeof(Program).Assembly);

            Log.LogInfo("<yellow>" + v.Title + "<cyan> v" + v.AssemblyVersion + " <default>" + v.Configuration + " " + v.FileVersion + " " + v.Copyright + "\n\n");
        }
Example #9
0
        private static void ReadOwnVersion()
        {
            var ownAssembly    = typeof(HugsLibController).Assembly;
            var ownContentPack = LoadedModManager.RunningMods
                                 .FirstOrDefault(p => p.assemblies != null && p.assemblies.loadedAssemblies.Contains(ownAssembly));

            if (ownContentPack != null)
            {
                libraryVersionFile = VersionFile.TryParseVersionFile(ownContentPack);
                libraryVersionInfo = AssemblyVersionInfo.ReadModAssembly(ownAssembly, ownContentPack);
            }
            else
            {
                Logger.Error("Failed to identify own ModContentPack");
            }
        }
Example #10
0
        // will run on startup and on reload. On reload it will add newly loaded mods
        private void EnumerateChildMods(bool earlyInitMode)
        {
            var modBaseDescendantsInLoadOrder = typeof(ModBase).InstantiableDescendantsAndSelf()
                                                .Select(t => new Pair <Type, ModContentPack>(t, assemblyContentPacks.TryGetValue(t.Assembly)))
                                                .Where(pair => pair.Second != null) // null pack => mod is disabled
                                                .OrderBy(pair => pair.Second.loadOrder).ToArray();

            var instantiatedThisRun = new List <string>();

            foreach (var pair in modBaseDescendantsInLoadOrder)
            {
                var subclass     = pair.First;
                var pack         = pair.Second;
                var hasEarlyInit = subclass.HasAttribute <EarlyInitAttribute>();
                if (hasEarlyInit != earlyInitMode)
                {
                    continue;
                }
                if (childMods.Find(cm => cm.GetType() == subclass) != null)
                {
                    continue;                                                                         // skip duplicate types present in multiple assemblies
                }
                ModBase modbase;
                try {
                    modbase = (ModBase)Activator.CreateInstance(subclass, true);
                    modbase.ApplyHarmonyPatches();
                    modbase.ModContentPack = pack;
                    modbase.VersionInfo    = AssemblyVersionInfo.ReadModAssembly(subclass.Assembly, pack);
                    if (childMods.Find(m => m.ModIdentifier == modbase.ModIdentifier) != null)
                    {
                        Logger.Error("Duplicate mod identifier: " + modbase.ModIdentifier);
                        continue;
                    }
                    childMods.Add(modbase);
                    instantiatedThisRun.Add(modbase.ModIdentifier);
                } catch (Exception e) {
                    Logger.ReportException(e, subclass.ToString(), false, "child mod instantiation");
                }
            }
            if (instantiatedThisRun.Count > 0)
            {
                var template = earlyInitMode ? "early-initializing {0}" : "initializing {0}";
                Logger.Message(template, instantiatedThisRun.ListElements());
            }
        }
Example #11
0
    public void CSharpGenerator()
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "c#";

        var built = info.BuildCode();

        var expected = @"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")]
[assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")]
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[System.CodeDom.Compiler.GeneratedCode(""" + AssemblyVersionInfo.GeneratorName + @""",""" + AssemblyVersionInfo.GeneratorVersion + @""")]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
internal static partial class ThisAssembly {
    internal const string AssemblyVersion = ""1.3.0.0"";
    internal const string AssemblyFileVersion = ""1.3.1.0"";
    internal const string AssemblyCompany = ""company"";
    internal const bool IsPublicRelease = false;
    internal const bool IsPrerelease = false;
    internal const string RootNamespace = """";
}
";

        Assert.Equal(expected, built);
    }
Example #12
0
        private void AddReference(int top, AssemblyVersionInfo verInfo)
        {
            var rowTable = new TableLayoutPanel {
                LayoutSettings = { ColumnCount = 3, RowCount = 1 }, Height = ReferencePanelHeight, Top = top,
                Width          = mTable.ClientSize.Width,
                Anchor         = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
            };

            var pLbl = new Label {
                Text = verInfo.Name, Padding = this.mCellPadding, Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleRight
            };

            rowTable.Controls.Add(pLbl, 0, 0);

            var wLbl = new Label {
                Text = verInfo.Version, Padding = this.mCellPadding, Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleLeft
            };

            rowTable.Controls.Add(wLbl, 1, 0);

            var btn = new Button {
                Text = "Details"
            };

            btn.Click += HandleClicked;
            btn.Tag    = verInfo;

            rowTable.Controls.Add(btn, 2, 0);//.SetAlignment (XAlign.Left, YAlign.Middle);

            rowTable.ColumnStyles.Add(new ColumnStyle {
                SizeType = SizeType.Percent, Width = 60
            });
            rowTable.ColumnStyles.Add(new ColumnStyle {
                SizeType = SizeType.Percent, Width = 20
            });
            rowTable.ColumnStyles.Add(new ColumnStyle {
                SizeType = SizeType.Percent, Width = 20
            });

            mTable.Controls.Add(rowTable);
        }
    public void FSharpGenerator()
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "f#";

        var built = info.BuildCode();

        var expected = @"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""" + AssemblyVersionInfo.GeneratorName + @""",""" + AssemblyVersionInfo.GeneratorVersion + @""")>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyCompany = ""company""
  static member internal RootNamespace = """"
do()
";

        Assert.Equal(expected, built);
    }
Example #14
0
        private string ListActiveMods()
        {
            var builder = new StringBuilder();

            builder.Append("Loaded mods:\n");
            foreach (var modContentPack in LoadedModManager.RunningMods)
            {
                builder.Append(modContentPack.Name);
                var versionFile = VersionFile.TryParseVersionFile(modContentPack);
                if (versionFile != null && versionFile.OverrideVersion != null)
                {
                    builder.AppendFormat("[ov:{0}]: ", versionFile.OverrideVersion);
                }
                else
                {
                    builder.Append(": ");
                }
                var firstAssembly = true;
                var anyAssemblies = false;
                foreach (var loadedAssembly in modContentPack.assemblies.loadedAssemblies)
                {
                    if (!firstAssembly)
                    {
                        builder.Append(", ");
                    }
                    firstAssembly = false;
                    builder.Append(loadedAssembly.GetName().Name);
                    builder.AppendFormat("({0})", AssemblyVersionInfo.ReadModAssembly(loadedAssembly, modContentPack));
                    anyAssemblies = true;
                }
                if (!anyAssemblies)
                {
                    builder.Append("(no assemblies)");
                }
                builder.Append("\n");
            }
            return(builder.ToString());
        }
Example #15
0
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DecoderJob job      = null;
            bool       startJob = false;
            string     cmd      = String.Empty;

            if (args.Length > 0)
            {
                switch (args.Length)
                {
                case 1:
                    cmd = args[0];
                    break;

                case 2:
                    if (String.Equals(args[0], "/s", StringComparison.CurrentCultureIgnoreCase))
                    {
                        startJob = true;
                        cmd      = args[1];
                    }
                    break;
                }

                if (cmd.Length > 0)
                {
                    if (cmd[0] != '/')
                    {
                        job                 = new DecoderJob();
                        job.SourcePath      = cmd;
                        job.DestinationPath = String.Concat(cmd, ".dump");
                    }
                    else if (cmd.Length > 3)
                    {
                        switch (Char.ToLower(cmd[1]))
                        {
                        case 'd':
                            job = new DecoderJob();
                            job.DecodingMode = JobDecodingMode.BatchDecoding;
                            job.SourcePath   = cmd.Substring(3);
                            break;

                        case 'j':
                            job = DecoderJob.Load(cmd.Substring(3)) as DecoderJob;
                            break;
                        }
                    }
                }
            }

            MainForm frm = new MainForm((job != null) ? job : new DecoderJob(), startJob);

            AssemblyVersionInfo vInfo = new AssemblyVersionInfo(typeof(DecoderApplication));

            frm.Text = String.Format("{0} {1}.{2} - (build {3})", vInfo.Title, vInfo.Version.Major, vInfo.Version.Minor, vInfo.LastBuildDate.ToString("yyMMdd-HHmm"));

            Application.Run(frm);

            return((int)frm.ResultCode);
        }
    public void FSharpGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany              = "company";
        info.AssemblyFileVersion          = "1.3.1.0";
        info.AssemblyVersion              = "1.3.0.0";
        info.AdditionalThisAssemblyFields =
            new TaskItem[]
        {
            new TaskItem(
                "CustomString1",
                new Dictionary <string, string>()
            {
                { "String", "abc" }
            }),
            new TaskItem(
                "CustomString2",
                new Dictionary <string, string>()
            {
                { "String", "" }
            }),
            new TaskItem(
                "CustomString3",
                new Dictionary <string, string>()
            {
                { "String", "" }, { "EmitIfEmpty", "true" }
            }),
            new TaskItem(
                "CustomBool",
                new Dictionary <string, string>()
            {
                { "Boolean", "true" }
            }),
            new TaskItem(
                "CustomTicks",
                new Dictionary <string, string>()
            {
                { "Ticks", "637509805729817056" }
            }),
        };
        info.CodeLanguage = "f#";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyCompany = ""company""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal CustomBool = true
  static member internal CustomString1 = ""abc""
  static member internal CustomString3 = """"
  static member internal CustomTicks = new System.DateTime(637509805729817056L, System.DateTimeKind.Utc)
  static member internal IsPrerelease = false
  static member internal IsPublicRelease = false
  static member internal RootNamespace = """"
do()
" : "")}";

        Assert.Equal(expected, built);
    }