Resharper [Pure] versus Microsoft [Pure]

The JetBrains documentation for [Pure] is here:

It states that it is the same as System.Diagnostics.Contracts.PureAttribute.

However, it is not. The System.Diagnostics version has the following attribute usage:

[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate,
    AllowMultiple = false, Inherited = true)]
The JetBrains version has this:


This is a problem for me because I am currently going through the process of changing from using Microsoft Code Contracts (which is no longer supported) to Resharper Annotations.

I have a number of get-only properties that are declared as [Pure] using the Microsoft attribute, but I cannot change to using the Resharper [Pure] because it is not applicable to properties.

Would it be safe for me to change this to include AttributeTargets.Property in my version of the JetBrains annotations?

(And should the JetBrains version be changed to match the Microsoft one?)

Comment actions Permalink

ReSharper treats all properties reads as "Pure". So, it is safe fore you  to patch local version of JetBrains annotations but probably it is better to remove this attribute from properties to avoid confusing

Comment actions Permalink

Ah ok thanks - I shall do tat!

Comment actions Permalink
Microsoft Code Contracts (which is no longer supported)

Where did you hear that? As far as I can see, there's no mention of that on the MSDN page, the GitHub project or the FAQ. The GitHub project was last updated in December.

There's a discussion thread on GitHub about CC not working in .NET Core yet, and another discussion about it not working in VS2017 yet. But I don't see any suggestion that it will never work, or that the project is no longer supported.

Comment actions Permalink

I meant that it's no longer supported by *Microsoft*. (Code contracts doesn't currently work with VS2017RC, and given that VS2017 is going to be released on March 7th I think it's safe to say that it won't be fixed before then.)


Please sign in to leave a comment.