diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-06-20 22:02:09 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-06-20 22:02:34 -0700 |
commit | 726d6d66e39a001c43cb29e3ad2861242679be2f (patch) | |
tree | 24f2114f1b06a2a571b392e57b28d05b7945d53f | |
parent | 5cc8587e6da7a804a481c1589cc86904d569a2d0 (diff) | |
download | DotNetOpenAuth-726d6d66e39a001c43cb29e3ad2861242679be2f.zip DotNetOpenAuth-726d6d66e39a001c43cb29e3ad2861242679be2f.tar.gz DotNetOpenAuth-726d6d66e39a001c43cb29e3ad2861242679be2f.tar.bz2 |
Logging banner now includes the precise build version.
Fixes #161
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs | 16 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Core/Util.cs | 22 |
2 files changed, 21 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs b/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs index 7774e49..114c191 100644 --- a/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs +++ b/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs @@ -27,7 +27,7 @@ namespace DotNetOpenAuth.Messaging { /// <summary> /// The value to use for the User-Agent HTTP header. /// </summary> - private static string userAgentValue = Assembly.GetExecutingAssembly().GetName().Name + "/" + GetAssemblyFileVersion(); + private static string userAgentValue = Assembly.GetExecutingAssembly().GetName().Name + "/" + Util.AssemblyFileVersion; #region IWebRequestHandler Members @@ -245,19 +245,5 @@ namespace DotNetOpenAuth.Messaging { } } } - - /// <summary> - /// Gets the assembly file version of the executing assembly, otherwise falls back to the assembly version. - /// </summary> - private static string GetAssemblyFileVersion() { - 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(); - } } } 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> |