Closed hey24sheep closed 2 years ago
Hi @hey24sheep - the best place to start is the h5 template available on nuget.
Alternatively you can take a look at our UI library to get an idea on how we use it: http://github.com/curiosity-ai/tesserae, with examples here: http://curiosity.ai/tesserae It's on my backlog to add some more documentation, but can't promise anything now as we're quite busy with work!
@theolivenbaum Is there any example which shows how to convert a class library to JS (no U.I).
Like, I have a project (class library) which is a nuget package to provide helper functions to users in C#. I want to convert that to JS. Is it possible with H5?
It is absolutely possible but you'll take a dependency at least on the base h5.js (or h5.min.js) or more depending on what you use (Json serialization for example). I'll add an example to the repository on how to do it!
So, I wont add H5 nuget right? because if I add it, my project breaks completly and doesn't build. An example will be really helpful, thank you.
You need to have the h5 package as that's providing what normally the SDK provides. You also need the special project target so it compiles with h5 and not with the dotnet compiler.
That might sound complicated, but it isn't: the way we do on our side is to have two projects and just add the files of one as "links" on the second project. Something like this%20Right%2Dclick%20%E2%80%9Cutilities,select%20%E2%80%9CAdd%20As%20Link%E2%80%9D.).
This way you can compile each project targeting their own SDK, and have code shared between them.
Another way to handle this is to have a shared code project with all the code, and just reference it on two empty projects, one targeting c# the other targeting h5.
Okay, thank you I understand now. I thought, it could work as a T4 template but it's more like a Rosyln compile time and not runtime. I will try it later on my project.
It would be really helpful if you could add an example. It will help other people as well.
No hurry though, take your time. Thanks a lot, really helps.
Hi @hey24sheep,
I've added a repository for samples on how to use h5: h5-samples I'll add over time more examples in there. If you have any suggestions feel free to open an issue there! I've written about the first two here too: https://medium.com/@theolivenbaum/building-web-apps-in-c-part-1-92e944fa5874
Hi @theolivenbaum ,
I just tried the way you have told in the blog. I think the issue is the project is in C# 10 and because of that H5 gives error and doesn't build. I tried <LangVersion>10.0</LangVersion>
of H5 project too but it didn't help.
Here is the project. I always get these three errors displayed in the pic. I am also getting the errors that extended classes are not available in this context. In no way I want you to do my work but I am just reporting this maybe it's a feature missing or some other bug. Thanks a lot for quick response and helpful guide. I have given the project so many you could know better and if this is a feature enchancement it could help you in debugging too.
Project looks like this, I have replicated the original project structure.
The missing types
3 Errors I always get.
Hi @hey24sheep,
Unfortunately h5 supports for now only c# 7.2 plus some features from 7.3.
If you change it to 7.3 you should be able to compile it - but obviously you'll miss the nice record classes.
I think there's a check during compilation for it, I might experiment to see what happens if I remove the check - but my guess is that there's a non trivial around of work to get up to version 10.
Hi @theolivenbaum, I figured, well I cannot change the C# version of this project as I am just a contributor and they are trying to use all the latest features in this library.
Well, then this is a complete new enhancement issue, different than this one :D I will stop bumping this one then. Thanks a lot for all your help. Will keep a watch on it for C# 10 updates. Thanks again 👍🏼
No worries! What you can also do is just add conditional compilation and write the record classes as normal classes only for h5.
Need wiki/doc on how to implement/use within a c# project, thanks