The first public preview of Visual ReCode is available for download and best of all, it’s free! We’ve added several new features (see below) for a more comprehensive WCF to gRPC migration experience and significantly revised the UI based on the feedback we got from our private previews.
Visual ReCode will now optionally generate a client library project for the generated gRPC service. The client library includes the gRPC client, generated by the gRPC tools, but also a wrapper around that client that should be mostly compatible with the previous WCF-generated client. This means you can share this library with your users and they can switch to it in their applications with a minimum of code changes.
The client library project targets two frameworks, .NET Standard 2.1 and .NET 4.5, so it can be used in projects targeting .NET Core 3.x or the full .NET Framework.
In WCF, with certain bindings, a method that returned an
IEnumerable<T> value would send results to
the client one at a time instead of building a list on the server and returning it in one go. gRPC
offers similar functionality with “server streaming” methods. See the gRPC Concepts
document for more information.
Visual ReCode will now convert
IEnumerable<T> WCF methods to server streaming RPCs for you. The generated
client methods for these RPCs will behave differently depending on the target framework. For .NET Standard 2.1,
the method will return the new
IAsyncEnumerable<T> type from .NET Core 3.x, allowing you to use the new
await foreach syntax in C# 8. The .NET 4.5 project will read all the values from the service and build
List<T> before returning. We might change this to add a reference to the
Microsoft.Bcl.AsyncInterfaces Nuget Package
and use its
IAsyncEnumerable<T> interface, which would work with the
System.Linq.Async package from
the Rx.NET project. Let us know if you’d like to see that.
If your WCF method returns an
IEnumerable<T> value but you do not want it to be converted to a streaming
RPC, you should change the return type of the method to
IList<T> before running the migration.
There is one key fix in this release. Visual ReCode scans the source project for all the types needed by the WCF service you are migrating. Unfortunately this scan could get stuck in a loop in the first release. Recursive code is difficult! This issue has been fixed in Preview 2, and as a bonus, the scan process writes everything it is doing to the Visual ReCode Output window.
Coming in Preview 3
We’re planning on releasing one more preview before Visual ReCode goes on sale. Preview 3 will add support for WCF duplex services, and support services that use Sessions. This is a bit complicated, so some more detailed explanation seems appropriate.
In WCF, with certain bindings, you can create a persistent connection between client and server, and the server can invoke methods on the client using a Callback Contract interface. This is known as a Full Duplex service. The developer of the client code creates an implementation of the callback contract interface, which is invoked by the WCF runtime.
gRPC does not have an exact equivalent, but it does support bidirectional streaming, which also creates a persistent connection between client and server and allows messages to be sent arbitrarily in both directions. Messages can be of different types, so something similar to a Full Duplex service can be implemented by reading the messages off the stream and invoking different methods based on the message type.
Obviously this implementation code will be very different from the WCF approach, so Visual ReCode’s client generator will provide a mapping between the gRPC stream and a callback contract implementation, meaning that your client code will continue to work as before.
Preview 3 will also support migrating services that rely on WCF Sessions. In WCF, with bindings that support it, you can start a session that keeps the service class alive on the server, so it can retain state between method calls. Again, gRPC does not support anything like this, but again, by using streaming we can emulate the behavior. A WCF service that requires sessions will be converted to a streaming service rather than a regular RPC, which will keep the service instance alive on the server.
We intend for Preview 3 to be the final preview release before Visual ReCode goes on sale and is fully supported. We will continue to add functionality beyond that point, including support for migrating WCF ReST services or ASP.NET Web API 2.x applications to ASP.NET Core 3.1 MVC, and .NET Remoting to gRPC for people with some real legacy code. And we’ll continue to improve and refine the migration process, and look at other ways we can help developers rescue their legacy code and bring it up to date.
Are We Missing Something?
If you have a migration scenario from .NET Framework to .NET Core that’s giving you pause, please reach out to us and let us know about it - we want to be sure we’ve got the most comprehensive option available to re-code your app for the latest in .NET!