christianhelle / apiclientcodegen

A collection of Visual Studio custom tool code generators for Swagger / OpenAPI specification files
http://bit.ly/restapicodegen
GNU General Public License v3.0
177 stars 23 forks source link

Crashes Visual Studio When Opening docker-compose.yml #190

Open dlumpp opened 3 years ago

dlumpp commented 3 years ago

When I click docker-compose.yml in Solution Explorer to open an editor, Visual Studio immediately locks up and becomes unresponsive, requiring a task kill.

I only discovered it was this extension when I happened to notice a message from you in my output window that said something like "unexpected file type DockerCompose."

I'm happy to provide logs to help you troubleshoot if you tell me how to gather them.

christianhelle commented 3 years ago

Oh wow... I never tried or heard of this before but this definitely sounds bad!

Thanks for letting me know!

I'll investigate immediately what could be wrong. I know that if you add a custom tool to a json/yml/yaml file on the project then the custom tool will run some code in my extension. Since the custom tool needs to be explicitly set, either manually, or by using the "Add New REST API Client" context menu, I have some assumptions that the json/yml/yaml file is an Open API specifications document and I parse accordingly. I handle errors here by writing to the output window and if the error is unexpected or critical I show a message prompt

christianhelle commented 3 years ago

I'm happy to provide logs to help you troubleshoot if you tell me how to gather them.

@dlumpp That would be great to have for troubleshooting.

I log everything out to the Output Window. So just copy/pasting from that would be enough

Thanks in advance

dlumpp commented 3 years ago

Sorry I tried a few times but I can't get that log output to show up again before VS becomes unresponsive. I must have gotten lucky the one time I noticed it!

christianhelle commented 3 years ago

Thank you very much for trying @dlumpp

I also tried as well from my end but I can't seem to reproduce it

If you don't mind I just have a few more questions...

Something like this:

  <ItemGroup>
    <None Update="docker-compose.yml">
      <Generator>AutoRestCodeGenerator</Generator>
    </None>
  </ItemGroup>

If its not included in a C# project and there is no custom tool or <Generator> associated with it then I'm a bit at a loss. But I will keep this issue open until I can fully figure out what could be wrong

When I write to the Output Window, I use the my own category called REST API Client Code Generator. All trace information is written directly to this

christianhelle commented 3 years ago

Oh and one last thing @dlumpp

Do you mind sharing the support key of your installation. You can find it under Tools -> Options -> REST API Client Code Generator -> Analytics

Screenshot 2021-04-01 22 06 37

Thanks in advance

dlumpp commented 3 years ago

My support key is b463d8b. Thanks for putting so much effort into looking into this.

There is some special tooling around docker compose files. It's built into Visual Studio. When it's working you get a docker-compose node with the little docker whale icon under your solution and you can pick "Docker Compose" as your start up project. I think VS does this via a pseudo-project entry in the sln file.

I went looking for a sample project for you. Open up the src/sln file in https://github.com/dotnet-architecture/eShopOnContainers/ and you'll see what I mean. Interestingly enough, this solution does not crash my VS, however I do see your extension outputting Unexpected output type found - DockerCompose repeatedly in the output window. Perhaps my own file has something more complex than this one that's causing problems.

christianhelle commented 3 years ago

I couldn't see any analytics or error data from your support key, even after waiting a day. My tool is designed to lazy load upon use and "use" in this case is defined by generating code via any of my custom tool (single file generators) or using any of the solution explorer context menu extensions

All that said, I think this issue is very interesting as I have no idea what's wrong. Thank you very much for reporting this @dlumpp. I take pride in my work and helping others, and I hope that I can figure out what's going on here

If you don't mind sharing your Docker Compose file then it might help me a bit. You can post it in this issue or you can send it to christian [dot] helle [at] outlook [dot] com. But please trim out the secrets or at least replace them with bogus incorrect values first :)

christianhelle commented 3 years ago

Status Update:

I started investigating the solution you provided @dlumpp (thanks again for that)

I can see that my TraceListener implementation that writes to the Visual Studio Output Window is getting calls from Visual Studio itself, or other Visual Studio extensions. The thing is, when you build Visual Studio extensions, you're extension is running in the Visual Studio context meaning that if Visual Studio itself, or other extensions, use Trace.WriteLine(string) then my TraceListener captures these messages and writes it to my custom Output Window category. The same goes for capturing unhandled exceptions, my extension captures all sorts of exceptions that have nothing to do with my code. Unfortunately, this doesn't really explain why Visual Studio hangs completely.

I'll dig deeper into this and find a fix or at least come up with a work around