SpecFlowOSS / SpecFlow.VisualStudio

Visual Studio extension of SpecFlow (extracted from the main SpecFlow repo)
Other
67 stars 73 forks source link

GherkinLanguageServiceFactory ObjectDisposedException when switching branches #182

Open PaulFarry opened 3 years ago

PaulFarry commented 3 years ago

SpecFlow Version:

Used Test Runner

Version number: 3.6.23

Project Format of the SpecFlow project

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup>
    <PackageReference Include="SpecFlow.MsTest" Version="3.6.23" />
    <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.6.23" />
  </ItemGroup>
</Project>

.feature.cs files are generated using

// SpecFlow Version:3.6.0.0 // SpecFlow Generator Version:3.6.0.0

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Implementation:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

(no file)

Issue Description

When you switch between branches with a feature file open, then visual studio presents an object disposed exception in the info area above the code editor.

Steps to Reproduce

If you are on a branch and have a feature file open switch branches where the same feature file has changed

you get the folowing error in the visual studio log

  <entry>
    <record>1961</record>
    <time>2021/03/12 02:40:30.664</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ObjectDisposedException: Cannot access a disposed object.&#x000D;&#x000A;Object name: &apos;GherkinLanguageService&apos;.&#x000D;&#x000A;   at TechTalk.SpecFlow.VsIntegration.Implementation.LanguageService.GherkinLanguageService.TextBufferChanged(GherkinTextBufferChange change)&#x000D;&#x000A;   at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinLanguageServiceFactory.&lt;&gt;c__DisplayClass8_0.&lt;CreateLanguageService&gt;b__0(Object sender, TextContentChangedEventArgs args) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinLanguageServiceFactory.cs:line 58&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

Repro Project