简体   繁体   中英

c# .cs file with http relative link in comment in Visual Studio

Let Say I have following C# project structure in Visual Studio

  • Spec
    • UserStory1.html
    • UserStory2.html
  • Tests
    • Test1.cs
    • Test2.cs

Now I want to connect my unit tests with Specification written in html in the following way

//http://../path.to.UserStory1.html#or_even_some_anchor
[TestFixture]
public class Test1
{
    [Test]
    public void SomeTest()
    {

    }        
}

That way when I CTRL+Clik on the link in the comment I can jump to the specification and see what should be really tested. Problem is that I don't know how to do a relative path to html file included in the project.

  • How can I do that?
  • If not in standard VS, is there some plugin available that will enable this?

I think that in your case the <see/> documentation tag would make the most sense, but others are available .

This would change your example code to be the following:

/// <summary>
/// This test does something
/// </summary>
/// <see cref="http://../path.to.UserStory1.html#or_even_some_anchor"/>
[TestFixture]
public class Test1
{
    [Test]
    public void SomeTest() { }        
}

I tested with http://www.google.com and it opened it in a new tab within VS. All of this is built into VS without any additional add-ons.

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