using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; public static class AssemblyExtensions { /// /// Gets the assembly build date according to the visual studio extension (auto version increment). /// The scheme of the assembly version should be {Major}.{Minor}.{BuildNumber}.{YYDDD} /// The revision number contains the number of years since 2000 and day in year. /// /// The assembly. /// public static DateTime GetBuildDate(this Assembly asm) { var version = asm.GetName().Version; String revision = version.Revision.ToString(); if (revision.Length == 5) { int years = int.Parse(new String(revision.Take(2).ToArray())); int day = int.Parse(new String(revision.Skip(2).ToArray())); return new DateTime(2000, 1, 1).AddYears(years).AddDays(day - 1); } else { return new DateTime(2000, 1, 1) .AddDays(version.Revision); } } public static IEnumerable GetLoadableTypes(this Assembly assembly) { try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException e) { return e.Types.Where(t => t != null); } } }