简体   繁体   中英

Resharper External Attributes with MSTest's [DeploymentItem]

In certain cases (like when writing URIs in XAML), ReSharper magically figures out I am writing out a relative path to a file in the current project and offers very useful smart-completion for it, and a warning if I misspell something and get it wrong, and even goes to the file if I ctrl+click it.

Can I somehow tell ReSharper to do the same when I'm typing in the parameter to MSTest's DeploymentItem attribute?

This should work through an external annotation . Open the following file:

C:\\Program Files (x86)\\JetBrains\\ReSharper\\v7.1\\Bin\\ExternalAnnotations\\Visual Studio\\Microsoft.VisualStudio.QualityTools.UnitTestFramework.xml

(Or whatever version of Resharper you're using.)

Add these lines inside the assembly tag:

<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.#ctor(System.String)">
    <parameter name="path">
        <attribute ctor="M:JetBrains.Annotations.PathReferenceAttribute.#ctor" />
    </parameter>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.#ctor(System.String,System.String)">
    <parameter name="path">
        <attribute ctor="M:JetBrains.Annotations.PathReferenceAttribute.#ctor" />
    </parameter>
</member>

That tells Resharper to throw the PathReference attribute on the path parameter of both constructors of DeploymentItem .

However , after testing for some time now I cannot see this attribute working on anything that I try within the C# text editor. It could be that it doesn't work for my version (7.1), but I'm a bit stumped. Perhaps someone can add to this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM