Skip to content
wpdev

.NET / C#

Month: March 2017

You are browsing the site archives for March 2017.

Uncovering a bug in Attribute.GetHashCode

2017-03-26
By: Kevin Gosse
On: March 26, 2017
Tagged: .NET, C#

It started from a question on StackOverflow. The following code will return inconsistent value for the hashcode of the attribute: View the code on Gist. This will print the output: 1234567 0 0 We can see that the hashcode value changes between the first and second invocation. Even more interesting, commenting line 3 seems to fix the behavior and GetHashCode will always return 1234567. To understand what’s going on, we first need to look at the source code of the Attribute.GetHashCode method: View the code on Gist. In a nutshell, what it does is: Enumerate the fields of your attribute Find the first field thatRead More →

Recent Posts

  • Uncovering a bug in Attribute.GetHashCode
  • [UWP] NavigationService with back button handler priority
  • [UWP] Bandwidth adaptive image control
  • [uwp] Animation orchestration using Caliburn.Micro coroutines
  • Should I await the last call in a method

Archives

  • March 2017 (1)
  • February 2016 (1)
  • January 2016 (1)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • May 2015 (1)
  • April 2015 (1)
  • March 2015 (3)
  • October 2014 (1)
  • September 2014 (1)
  • November 2013 (1)
  • August 2013 (1)
  • May 2013 (1)
  • February 2013 (1)
  • December 2012 (1)
  • October 2012 (2)
  • July 2012 (1)
  • May 2012 (1)
  • February 2012 (1)
  • January 2012 (4)

Follow me on Twitter

My Tweets

Designed using Dispatch. Powered by WordPress.