Skip to content

Fix warning CA2002: Do not lock on objects with weak identity#184

Merged
mattwar merged 1 commit intodotnet:masterfrom
zerhacken:dev/lock-private-object
Feb 13, 2015
Merged

Fix warning CA2002: Do not lock on objects with weak identity#184
mattwar merged 1 commit intodotnet:masterfrom
zerhacken:dev/lock-private-object

Conversation

@zerhacken
Copy link
Contributor

This commit changes 'lock (this)' usage into a lock on a private
object which only instance is knowledgeable about.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use the name gate here instead? I believe that is the verbiage we most commonly associate with object values used only in lock statements.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean _gate 😄

@jaredpar
Copy link
Member

jaredpar commented Feb 1, 2015

Thanks for doing this. Left some minor comments on the change.

I think this will be good to go once we are in a position to accept PR's (very, very soon).

@zerhacken
Copy link
Contributor Author

Changed field name from "lockable" to "_gate" and fixed comment (maintained "lock(gate) on access")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment isn't really needed, but XML doc comments would be more appropriate if you're going to keep them. IDE goodness and all. Ditto for everything else.

@zerhacken
Copy link
Contributor Author

@jasonmalinowski fixed comments to XML doc, if a commentless fix is preferred I will of course remove them as necessary. I would personally keep the comments as a fair warning.

@gafter
Copy link
Member

gafter commented Feb 10, 2015

👍

This commit changes 'lock (this)' usage into a lock on a private
object which only instance is knowledgeable about.
@zerhacken
Copy link
Contributor Author

git fetch upstream
git rebase upstream/master

mattwar added a commit that referenced this pull request Feb 13, 2015
Fix warning CA2002: Do not lock on objects with weak identity
@mattwar mattwar merged commit a8f98af into dotnet:master Feb 13, 2015
@srivatsn
Copy link
Contributor

@zerhacken - If you haven't already, can you please sign the CLA here - https://cla2.dotnetfoundation.org ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants