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

.NET Core/Standard library #36

Open
Artur-A opened this issue Feb 6, 2017 · 9 comments
Open

.NET Core/Standard library #36

Artur-A opened this issue Feb 6, 2017 · 9 comments

Comments

@Artur-A
Copy link

Artur-A commented Feb 6, 2017

Hi @andry-tino,
Thank you for your awesome project.

Roslyn now supports .NET Core cross platform applications.

Do you have plans to support .NET core in your project?

@andry-tino andry-tino self-assigned this Feb 6, 2017
@andry-tino
Copy link
Owner

Hi @Artur-A and thanks for your message and also thanks for your very valid point.

Support for .NET Core

The feature is planned as part of efforts scheduled after the first milestone for the definition generator. I will create that milestone and assign this issue to that.

The priority of this feature is a little low as you can imagine, however here are a couple of questions for you:

  1. Why are you using Rosetta? For translating code or for generating definition files?
  2. Why are you in need of .NET Core support?

Notes

Those will help me redefine the priority of this task. .NET Core is a technology I am very interested in and am looking forward to making my hands dirty into that, so I would not mind using Rosetta as a start project. So let me know.

@Artur-A
Copy link
Author

Artur-A commented Feb 6, 2017

I see, the plan looks reasonable and good.

1. Why are you using Rosetta? For translating code or for generating definition files?
I have not used your project yet because there is a need of .NET Core support, although checked the code quality and the volume of work, it looks pretty good. The plan is to use the project for code transpilation C# => TypeScript.

2. Why are you in need of .NET Core support?
There is a medium sized ASP .NET Core app that I am working now on, plus two similar are waiting. And there are a lot of code duplication with C# and TypeScript. For example, in order to get a 1950s idea about ranged types the next classes become handy:

class Whatsapp : SubstrateText {
      public override decimal MinLength { return 7;}
      public override decimal MaxLength { return 256;}

     public static IMayConvertFrom<string, Whatsapp> Factory {get;}
      // and so on ...
}

The objects of this class will be transferred via wire and may be converted from string, or may not. The custom guard is used for deserialisation on the server side.
I don't like to use existed DataAnotation approach, cause my objects should be always valid if they are constructed.

Now in order to serialize Whatsapp from a user's input there is a need to have a similar TypeScript (JavaScript) implementation:

class Whatsapp extends SubstrateText{
      //    and so on
}

The same is for internationalisation and for a lot of other shared logic between a server and a client.

@andry-tino
Copy link
Owner

All right! I see you actually have a real need for this.

I will soon start an investigation of the effort to make this happen and let you know. If the amount of work is reasonably low, I will probably prioritize this issue and start working on it :)

@michaelaird
Copy link

@Artur-A Have you looked at NSwag ( https://github.com/NSwag/NSwag ) ? It might meet your needs for generating TypeScript client code to match your server-side API.

@Artur-A
Copy link
Author

Artur-A commented Feb 24, 2017

Thank you @michaelaird, NSwag is a nice tool.

My final point is too be able to use most of the shared code between a server (.NET) and a client (ts/js) in C#. Just write it once.

NSwag is what Microsoft was doing with Web services and WCF for more than a decade: generating client proxies.
I want to have not only dumb DTO objects and dumb service calls be auto generated for a client, but also to have the shared logic.

For example, let's say we have a validation for Address input on the server side (API). There is a logic written in C# that the string address should have at least 10 symbols and no more than 100 symbols. Then Address should have only English symbols and numbers, no Asian or Arabic. Then there is a logic with a date birth using C# DateTime class.

All these checks need to be duplicated on a client side to reduce the bandwidth and good UX. We start to write duplicated classes just in different languages, use moment.js instead of DateTime and so on:

Site.Client.Server.proj
|__Address.cs
|__AddressDto.cs
|__Address.ts // <-- this is the problem, which Rosetta can resolve
|__AddressDto.ts // can be done with NSwag and Rosetta

The idea is to reach an isomorphic application as much as it possible and drastically reduce developers time.

  • Write server logic in C#/F#.
  • Write client-server shared logic in C#/F# once. Reuse it in Web site via generated TS/JS, reuse code in WPF and Xamarin. (Web Client/Server partially implemented in Google Web Toolkit, however produces ugly JS, which is not much usable as TypeScript).
  • Write exclusive UI for Web site, exclusive UI for Mobile app, exclusive UI for WPF.
  • Write shared UI controls and logic for Web site, WPF and Mobile app once. (Web site/Mobile UI sharing is done in React Native, Phone Gap and others)
  • Support different platforms: Linux/Mac/Windows/Mobile-Tablet OS (.Net Core is evolving in this direction)
  • Write custom static code checks and code generators or edit/configure existing (Roslyn).
  • Be ready to support in future C# code compilation to Universal Web Assembly.

This is why this project is so important.

@andry-tino
Copy link
Owner

Hi all
We have some important changes to make in the ScriptSharp definition generator which I need to prioritize for my team. Hence this has to be postponed. I value this issue and I will get back to it for sure, but for the moment I need to hold on this unfortunately.

Will get back to you when my priority work is done. Thank you

@graceleecat
Copy link

@Artur-A hi, I read your comments above, I found that your needs are very similar to what I want to achieve-- The C# logic on the server side (such as validation, judgment) also wants to be used again at the web side in the way of TS. I wonder if you find the right thing now.
I'm looking forward to your reply, thanks :)
I am also grateful for the owner of the project :)

@Artur-A
Copy link
Author

Artur-A commented Jan 25, 2018

Hi @graceleecat, I ended up with TypeScript logic duplication.

Webassembly can resolve all isomorphic problems with big Microsoft contribution, but we need to wait, in my estimation, at least 4 years.

@andry-tino
Copy link
Owner

Hi again
I understand the need to move to .NET Core and I am convinced it is a good course of action. Unfortunately I have no time at the moment to do this, but I have started investigating a bit more on the effort. Any help is more than appreciated of course.

However I have a few comments here. As far as i could understand, you want to actually integrate Rosetta components in your ASP.NET Core application in order to solve some serialization/deserialization issues. The reason why you need Rosetta in .NET Core is because you would compile Rosetta source files together with your solution. However how about you separate the two applications? You can create a web service on top of which Rosetta sits which handles the calls you need for converting C# code into TS. From your ASP.NET Core app you can invoke this web service and get files transpiled. Would it work?

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

No branches or pull requests

4 participants