Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:41:28+00:00 2026-05-24T02:41:28+00:00

I want to write a test framework extension for resharper. The docs for this

  • 0

I want to write a test framework extension for resharper. The docs for this are here: http://confluence.jetbrains.net/display/ReSharper/Test+Framework+Support

One aspect of this is indicating if a particular piece of code is part of a test. The piece of code is represented as a IDeclaredElement.

Is it possible to get the filename and line number of a piece of code represented by a particular IDeclaredElement?

Following up to the response below:

@Evgeny, thanks for the answer, I wonder if you can clarify one point for me.

Suppose the user has this test open in visual studio: https://github.com/fschwiet/DreamNJasmine/blob/master/NJasmine.Tests/SampleTest.cs
Suppose the user right clicks on line 48, the “player.Resume()” expression.
Will the IDeclaredElement tell me specifically they want to run at line 48? Or is it going to give me a IDeclaredElement corresponding to the entire class, and a filename/line number range for the entire class?

I should play with this myself, but I appreciate tapping into what you already know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:41:29+00:00Added an answer on May 24, 2026 at 2:41 am

    Yes.

    The “IDeclaredElement” entity is the code symbol (class, method, variable, etc.). It could be loaded from assembly metadata, it could be declared in source code, it could come from source code implicitly.

    You can use

    var declarations = declaredElement.GetDeclarations() 
    

    to get all AST elements which declares it (this could return multiple declarations for partial class, for example)

    Then, for any IDeclaration, you can use

    var documentRange = declaration.GetDocumentRange()
    if (documentRange.IsValid())
      Console.WriteLine ("File: {0} Line:{1}",
     DocumentManager.GetInstance(declaration.GetSolution()).GetProjectFile(documentRange.Document).Name,
    documentRange.Document.GetCoordsByOffset(documentRange.TextRange.StartOffset).Line
    );
    

    By the way, which test framework extension are you developing?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a unit test that performs HTTP requests directly (instead of
I want to write a unit test for a Django manage.py command that does
Give a base class Base , I want to write a method Test, like
I want to test a Ajax based web application. I want to write the
Using Nunit, I want to be able to write a test fixture that will
I'm trying to write a generic repository for my Entity Framework based application. Here's
I want to write a program (in vb.net) that checks a customers configuration to
I want to upload an image in Zend-framework. In Application_Form_Test.php I write following code....
I am using the Google App Engine testbed framework to write test cases with
As you know there is a generic class List in .NET framework. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.