OpenRIAServices / OpenRiaServices

The Open RIA Services project continues what was previously known as WCF RIA Services.
https://openriaservices.gitbook.io/openriaservices/
Apache License 2.0
54 stars 48 forks source link

Client Generator #516

Open ehsangfl opened 5 months ago

ehsangfl commented 5 months ago

Describe the bug When I Implement a new code generator for the client based on CSharpClientCodeGenerator, the proxy class will change and increase the lines of code. for example, every proxy class moves to its namespace instead of all proxy classes inside a namespace.

Before

namespace AppModel.Web.Model
{
public class a{}
public class b{}
}

After

namespace AppModel.Web.Model
{
public class a{}
}
namespace AppModel.Web.Model
{
public class b{}
}

I want to change the client proxy namespace through

  public override string TransformText()
  {
      return base.TransformText().Replace("AppModel.Web.Model", "AppModel.Client.Model");
  }

in the Blazer web app (blazer 8), the server has access to the client *.dll and the server model caused conflict with the client model we should change the namespace of the client

Daniel-Svensson commented 5 months ago

~I am not that familiar with CodeDOM but my beast guess is that you might create different instances of some namespace object. IF that is the case maybe you can keep a dictionary (with object reference compare) from original namespace object to new namespace.~

~There is also the possibility to use the T4 code generation and se if it is easier to modify that. Unfortunately it lacks goos documentation but there were a few blog posts released about using it.~

update: it seems you are using the t4 text template generator?

I se nothing strange with the small code snippet. I have not looked that much on the generated code from t4, but I assume it will generate redundant namespaces just because it wad easier to implement it that way.

If there are any methods or similar that need to be made public to make extending the code generation easier I am very open to do so. I had planned to make naming etc public, but never did.

If the feature works good then I am open consider adding it to openriaservices (with a project setting for specifying namespace translations)

Daniel-Svensson commented 5 months ago

Forgot to ask: Does it work fine anyway (with the exception of slightly more code)?

ehsangfl commented 5 months ago

Thanks for your reply, I think it's better to have settings for the client namespace I haven't tested the new version and am running a new Blazor project. I will inform you when finish, but the previous versions work like a charm

ehsangfl commented 5 months ago

Hey @Daniel-Svensson .Sorry, I found this is a misunderstanding of the Blazor web app (.net 8) structure. In the new structure, the client and server work together and the server side is not only the host of the client (I can say both server and client are new clients, one client on the browser and the other on the server). so we have to setup a new API server for Host OpenRiaServices. so we don't need to change anything but it is a good idea to have a namespace setting. If I have a chance, I will do it