summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Core/Util.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Util.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Core/Util.cs b/src/DotNetOpenAuth.Core/Util.cs
index 5a1a5d0..e9d617a 100644
--- a/src/DotNetOpenAuth.Core/Util.cs
+++ b/src/DotNetOpenAuth.Core/Util.cs
@@ -36,10 +36,12 @@ namespace DotNetOpenAuth {
/// Gets a human-readable description of the library name and version, including
/// whether the build is an official or private one.
/// </summary>
- public static string LibraryVersion {
+ internal static string LibraryVersion {
get {
- string assemblyFullName = Assembly.GetExecutingAssembly().FullName;
+ var assembly = Assembly.GetExecutingAssembly();
+ string assemblyFullName = assembly.FullName;
bool official = assemblyFullName.Contains("PublicKeyToken=2780ccd10d57b246");
+ assemblyFullName = assemblyFullName.Replace(assembly.GetName().Version.ToString(), AssemblyFileVersion);
// We use InvariantCulture since this is used for logging.
return string.Format(CultureInfo.InvariantCulture, "{0} ({1})", assemblyFullName, official ? "official" : "private");
@@ -47,6 +49,22 @@ namespace DotNetOpenAuth {
}
/// <summary>
+ /// Gets the assembly file version of the executing assembly, otherwise falls back to the assembly version.
+ /// </summary>
+ internal static string AssemblyFileVersion {
+ get {
+ var assembly = Assembly.GetExecutingAssembly();
+ var attributes = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
+ if (attributes.Length == 1) {
+ var fileVersionAttribute = (AssemblyFileVersionAttribute)attributes[0];
+ return fileVersionAttribute.Version;
+ }
+
+ return assembly.GetName().Version.ToString();
+ }
+ }
+
+ /// <summary>
/// Tests for equality between two objects. Safely handles the case where one or both are null.
/// </summary>
/// <typeparam name="T">The type of objects been checked for equality.</typeparam>