DevLabs > DevLabs Forums > Code Contracts > (temporary) Implicit PureAttribute for methods whose names start with Is / Can / Has?
Ask a questionAsk a question
 

Answer(temporary) Implicit PureAttribute for methods whose names start with Is / Can / Has?

  • Monday, July 13, 2009 4:45 PMwinSharp93 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    I do not know whether there has been a discussion about this topic before. I did not found any while searching.

    As there are lots of classes without contracts (and therefore no PureAttributes), there are always some rewriter wrnings "Warning: Call to impure method...".

    It would be nice if the rewriter would not produce warnings for methods with names starting with "Is", "Can" or "Has". Those methods are usually Pure. This could be only temporary until there is a better coverage with contracts.

    What do you think?

    Best regards
    winSharp93
    •  

Answers

  • Wednesday, July 22, 2009 8:06 PMMike BarnettMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    We already have the default (corresponding to the .NET coding guidelines) that properties are always pure. I'm not sure we want to bake in any more defaults, but we are open to the idea. We'll need to wait and see how many people feel the same way that you do.

    Thanks!

All Replies

  • Wednesday, July 22, 2009 8:06 PMMike BarnettMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    We already have the default (corresponding to the .NET coding guidelines) that properties are always pure. I'm not sure we want to bake in any more defaults, but we are open to the idea. We'll need to wait and see how many people feel the same way that you do.

    Thanks!
  • Wednesday, November 04, 2009 4:03 PMManuel FahndrichMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It's not a bad idea. I've had the urge to do just this in the past.
    Cheers, -MaF (Manuel Fahndrich)