dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.72k stars 558 forks source link

Fix for WCFCSTools issue - invalid namedPipe URL throws uncatchable exception in VS. #5604

Closed imcarolwang closed 2 months ago

imcarolwang commented 4 months ago

Description:

WCF CS tool invokes dotnet-svcutil-lib, which uses reflection to download metadata from a net.pipe URL. If an exception occurs during this reflection process and it isn't properly caught, Visual Studio may crash.

The fix is wrapping the reflection code's return type and any potential exceptions with TaskCompletionSource<TheType>instance. This approach ensures that exceptions are available to WCF CS tool, preventing VS crash and providing a more user-friendly exception message.

HongGit commented 4 months ago

/azp run

azure-pipelines[bot] commented 4 months ago
Azure Pipelines successfully started running 1 pipeline(s).
imcarolwang commented 4 months ago

/azp run

azure-pipelines[bot] commented 4 months ago
Azure Pipelines successfully started running 1 pipeline(s).
imcarolwang commented 2 months ago

Is it possible to add a testcase for this change?

I found that the unhandled exception from dotnet-svcutil-lib will be output to the process running the command line tool, whether the fix is applied or not, and cmd.exe does not crash. I think to verify the fix, we will need to invoke the code from WCF CS Tool in VS. We will add this test scenario in testing the WCF CS Tool.