R – Are there any tools to ease porting of .NET code to silverlight

netsilverlight

We have some .NET client side code, which we would like to port to Silverlight. However, the current .NET code simply does not compile on the Silverlight platform. Along with some subtle issues, there are many simple issues, like:
– some exceptions have less constructors in SL
– Debug.Fail does not exist in SL
– BindingList does not exist in SL
– severe limitations are placed on private reflection
etc…

Some of these differences can be applied to the plain .NET code, in order to minimize the differences between the .NET and SL code base. Like I do not mind to call Debug.Assert with false instead of Debug.Fail in my .NET code if it makes the code less polluted with #if SILVERLIGHT. The same is true about replacing BindingList with ObservableCollection.

My question is there a tool which given a .NET assembly can present some kind of Silverlight compatibility report, which would indicate the changes that must be made to the .NET code base in order to bring it as close as possible to the Silverlight platform?

Thanks.

EDIT:

The tool does slightly more complex job that just compiling the code in SL and presenting the errors. This has to do with code present in SL and .NET, but in SL it is unavailable to the regular (transparent) code. Invoking it would result in an exception on SL.

EDIT 2:

A few words of further clarifications are due:

  1. The code is not a UI code. It is neither WinForms, nor WebForms nor WPF. It is pure business logic code upon which the client side UI depends.
  2. We base our business logic on the Lhotka's CSLA library, which does have an SL port.
  3. Using VS to compile the project in SL only reports the compilation errors. It will not notify me of any invalid API usages, like invoking a method which is SecurityCritical in SL.

Best Answer

You do realise that your business logic does not have to be Silverlight compliant? Why don't you just expose your business logic through some webservices (which is a relatively trivial task), and call it from the Silverlight code? The Silverlight code and webservices can even reside on the same machine and each uses their own version of the framework, you don't have to host the webservices on a different machine. Doing things this way means you can code up a nice thin Silverlight UI, and do minimal work on the business layer.

(this answer supercedes my previous one and is in response to the clarified question)