开发者

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

开发者 https://www.devze.com 2022-12-11 05:07 出处:网络
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

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 p开发者_如何学Cresent 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.


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)


This is not the answer you will be wanting to hear, but what is wrong with using Visual Studio - it tells you where the errors are when you try to compile.

If you are looking for a report so that you can scope how long some work will take, then a report is not going to tell you that with any accuracy. It isn't just the fact you are operating with a cut down version of the framework, things are also done considerably differently in Silverlight, for instance WinForms cannot be directly translated and even WebForms will need a reasonable amount of work to become a Silverlight page/form.


I would suggest you split your code into multiple tiers, then you can replace the UI tier without rewriting the lower tiers.

0

精彩评论

暂无评论...
验证码 换一张
取 消