Is StringFormatMethod working with generic arguments?

Hi,

I use resharper_7.1.1 with vs2010 and I have a method from 3rd-party library with the signature Debug<TArgument>(string message, TArgument).

I wanted to have the same code analysis as for string.Format() that checks if the message contains a {0} for TArgument.
So I tried to add an annotation xml file with the following member, but it doesn't work:
<member name="M:[AssemblyName].Debug``1(System.String,``0)">
<attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)"><argument>message</argument></attribute>
</member>


My question: Is it possible to use a StringFormatMethodAttribute with generic typed arguments? And if yes, can anybody give me an example?


Thank you in advance.

2 comments
Comment actions Permalink

I've just tried this with ReSharper 7.1.3, and it works fine. Here's the xml file I'm using:

<assembly name="StringFormatAttributeTest">
    <member name="M:StringFormatAttributeTest.Class1.Debug``1(System.String,``0)">
        <attribute ctor="M:JetBrains.Annotations.StringFormatMethodAttribute.#ctor(System.String)">
            <argument>message</argument>
        </attribute>
    </member>
</assembly>



This is for an assembly called StringFormatAttributeTest.dll, with the Debug<T>(string, T) method living in a namespace also called StringFormatAttributeTest. The file is called StringFormatAttributeTest.ExternalAnnotations.xml and lives side-by-side with the dll.
0
Comment actions Permalink

Thanks Matt

I didn't see that there exist overloads of the method for value data types like Debug(string, int) of Debug(string, long) and I only tried with this kind of data types.

0

Please sign in to leave a comment.