Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Generator #516

Open
ehsangfl opened this issue Jun 15, 2024 · 4 comments
Open

Client Generator #516

ehsangfl opened this issue Jun 15, 2024 · 4 comments
Labels

Comments

@ehsangfl
Copy link
Contributor

ehsangfl commented Jun 15, 2024

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

@ehsangfl ehsangfl added the bug label Jun 15, 2024
@Daniel-Svensson
Copy link
Member

Daniel-Svensson commented Jun 18, 2024

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
Copy link
Member

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

@ehsangfl
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants