Skip to content

'Go To Definition' does not work with partial classes. #53

MrClyfar opened this Issue Mar 30, 2011 · 14 comments

8 participants


If step bindings are declared in a partial class, for example:



public partial class Steps {}


public partial class Steps {}


public partial class Steps {}

The 'Go To Definition' feature is unable to locate step bindings which are in StepsWhen.cs or StepsThen.cs.

object commented Apr 28, 2011

I performed some tests on this, and it looks like "Go To Definition" only works when a partial class definition has "Binding" attribute. With partial classes attributes can only be assigned once - this assignment will be shared with all other partial definitions. But SpecFlow detects only the one with this attribute and ignores others (which is of course a bug).

ghost commented Jun 21, 2011

I have a very similar problem to this, that might (and might not) be related to this bug: "Go to definition" doesn't work for external steps (defined in other assemblies than the feature file) either. It doesn't matter if I use a regex or regular string match. If I move the step class files to the same assembly, it works.

ghost commented Oct 1, 2011


Have you added the external assemblies to your SpecFlow configuration file as mentioned in the documentation? Check out the "Default Configuration" section. Apparently, you have to add a <stepAssemblies> tag in which you list all your assemblies.

SpecFlow Configuration Documentation

After going through the code real quick it seems like it first looks for the method in the current assembly and after that goes through each assembly defined in the configuration file.

Try adding them to your configuration file and report your findings :)


We also have this issue (the "go to definition" not working when steps defined in partial classes) - is this planned to be fixed?


@ghost Unknown added a commit that referenced this issue Oct 5, 2011
raytheon Add support for "Go To Definition" in partial classes (Issue #53)
Currently SpecFlow only supports the "Go To Definition" for full(?) classes (non-partial classes) because it only looks at classes which are marked with the [Binding] attribute. This change extends the search to partial classes by first finding all classes marked with [Binding] then checking to see whether any of these are partial classes. If so, those partial classes are assumed to be binding classes and are scanned as well.
ghost commented Oct 5, 2011

Here's something that might work. The last commit adds support for partial classes. It basically works like this:

  1. Get all classes marked with the [Binding] attribute
  2. Of these classes, get all partial classes
  3. Merge the two sets
  4. Scan the combined set of classes for the steps

The original example given by MrClyfar seems to work fine so far.

Looking forward to hearing your comments :)


Thanks raytheon, hopefully your change gets pulled in!


cool, thx. merged now. will be included in 1.8

@gasparnagy gasparnagy closed this Oct 17, 2011
GulinSS commented Jan 23, 2013

not works in 1.9.1



Do you try [Given(@"нажавший на строку "(.*)"")] ? =)
And where is [Binding]? Do you define it in another part of the partial class?

GulinSS commented Jan 23, 2013

I tried, but no luck.
Yes, I defined it in another part of the partial.

GulinSS commented Jan 23, 2013
public partial class UnknownSteps
  // lalala more more russian-english code :-)
@gasparnagy gasparnagy reopened this Mar 8, 2013

fixed the regression issue. 1.9.2 will contain the fix

@gasparnagy gasparnagy closed this Mar 13, 2013

I'm having this issue, using VS2013 and SpecFlow IDE Integration I'm using 4 partial classes and applied [Binding] in the first one. The tests run fine, but the Go To Definition does no work for the steps defined in the other 3 parts of the class. It says the step was not found and presents a suggestion of step template.


We're having the same issue with and VS 2013 that @rafaelromao describes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.