How to set obsolete to external library

Hello,

we have our web application and now we rewrite ti use knockout in views. For authorization we used "ValidateAntiForgeryToken" and because our plan is to use Ajax calls and supplay Validation token inside header of Ajax post, we build our own implementation of AntiForgeryToken that will do validation. Now we need way to mark default attribute as Obsolute.

How to accomplish that with Resharper? We need to prevent future usage of default implementation and also to quickly see in all controllers where are the old. I try to play with custom annotation but without success. Any idea?

[ValidateAntiForgeryToken] <---- should be visibly marked as obsoleted.

3 comments
Comment actions Permalink

You can do this with external annotations, although it's not strictly intended for this. You can use the external annotations mechanism to attach an attribute to a particular member, in this case, ObsoleteAttribtue to ValidateAntiForgeryTokenAttribute. Here's a blog post that explains how you can do it:

http://hmemcpy.com/2013/03/even-more-resharper-annotations-hackery-marking-3rd-party-code-as-obsolete/

0
Comment actions Permalink

Hi Matt,I read that article before I posted question.

This is what I have done:
  1. Inside Resharper\Bin\ExternalAnnotations i created file ---> System.Web.Mvc.xml
  2. Content of the file (I have no idea how to set up this) :


<assembly name="System.Web.Mvc">
  <member name="T:ValidateAntiForgeryToken">
    <attribute ctor="M:System.ObsoleteAttribute.#ctor">
      <argument>Use ValidateAjaxAntiForgeryToken instead.</argument>
      <argument>true</argument>
    </attribute>
  </member>
</assembly>


I have no idea how to setup this.

0
Comment actions Permalink

That looks pretty close, but your file has a couple of mistakes. The member name should be the fully qualified name of the type, including namespace, and the ctor should include the parameters e.g. #ctor(System.String, System.Boolean)

0

Please sign in to leave a comment.