Fix caching in RuntimeInformation.
authorLakshmi Priya Sekar <lasekar@microsoft.com>
Mon, 11 Jul 2016 05:56:18 +0000 (22:56 -0700)
committerLakshmi Priya Sekar <lasekar@microsoft.com>
Mon, 11 Jul 2016 05:56:18 +0000 (22:56 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/12cf3c411aecd548a5048080e94458386dd01c5f

src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs

index 33fc838..4f975cf 100644 (file)
@@ -23,10 +23,14 @@ namespace System.Runtime.InteropServices
         {
             get
             {
-                AssemblyFileVersionAttribute attr = (AssemblyFileVersionAttribute)(typeof(object).GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute)));
-                Debug.Assert(attr != null);
-                return s_frameworkDescription ?? 
-                    (s_frameworkDescription = $"{FrameworkName} {attr.Version}");
+                if (s_frameworkDescription == null)
+                {
+                    AssemblyFileVersionAttribute attr = (AssemblyFileVersionAttribute)(typeof(object).GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute)));
+                    Debug.Assert(attr != null);
+                    s_frameworkDescription = $"{FrameworkName} {attr.Version}";
+                }
+
+                return s_frameworkDescription;
             }
         }
     }