summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-06-20 22:11:01 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-06-20 22:11:01 -0700
commit15f234f335ab7cdbcb14cc25a97f5dba22c7c663 (patch)
tree69b51e7c23497bcb356614374af925d7dfe97205 /src
parent5893cc9e24eafe3982a7b8c467845b6e99ece8bc (diff)
parent191a46b778536eb9ce26d2589039ddbb765ef5c6 (diff)
downloadDotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.zip
DotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.tar.gz
DotNetOpenAuth-15f234f335ab7cdbcb14cc25a97f5dba22c7c663.tar.bz2
Merge branch 'v4.0'
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Util.cs22
2 files changed, 21 insertions, 3 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs b/src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs
index 98a2186..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 + "/" + Assembly.GetExecutingAssembly().GetName().Version;
+ private static string userAgentValue = Assembly.GetExecutingAssembly().GetName().Name + "/" + Util.AssemblyFileVersion;
#region IWebRequestHandler Members
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>