cake-contrib / Cake.Issues.Reporting.Generic

:cake: :jigsaw: :mag_right: Addin for creating text based issue reports (HTML, Markdown, ...)
https://cakeissues.net
Other
1 stars 8 forks source link

Support running on .NET Core #3

Closed pascalberger closed 4 years ago

pascalberger commented 7 years ago

Addin should support running on .NET Core.

RazorEngine was replaced with Gazorator as rendering engine which requires the following changes to the templates:

pascalberger commented 6 years ago

As RazorEngine doesn't support netstandard 2.0 RazorLight or gazorator might be an option

AdmiringWorm commented 5 years ago

There is also the RazorEngine.NetCore, which is a fork of RazorEngine itself.

Although the repository of the project is currently looking for new maintainers, I think it could be a good alternative until the codebase have been updated to use an alternative engine. (Mainly I think it is a good idea, just to be able to provide a .NET Core compatible project).

pascalberger commented 5 years ago

@AdmiringWorm I tried to replace RazoreEngine with RazorEngine.NetCore, but unfortunately it doesn't seem to be a drop in replacement and there are compilation errors with the current templates. If you wan't to give it a try I would happily accept a PR for it.

RazorLight also seems to be unmaintained nowadays, with no final 2.0 version. And Gazorator requires at least https://github.com/mholo65/gazorator/issues/4 to be implemented first.

AdmiringWorm commented 5 years ago

I see, I thought it would perhaps be a drop-in replacement. (Never tried anyone of them, nor programmed directly using RazorEngine either unfortunately).

But I'll see if I can't get it to work (unfortunately got other priorities right now, so it probably will take some time until I do).

AdmiringWorm commented 5 years ago

I've been trying to figure out how to do this for a while now, and I'm sorry to say that I can not figure out how to make it work.

I'm including a patch of the changes I made, in case someone else is able to continue the work (and they don't have to start from scratch).

These was the latest errors I got ``` An exception of type 'RazorEngine.Templating.TemplateCompilationException' occurred in Cake.Issues.Reporting.Generic.dll but was not handled in user code: 'Errors while compiling a Template. Please try the following to solve the situation: * If the problem is about missing/invalid references or multiple defines either try to load the missing references manually (in the compiling appdomain!) or Specify your references manually by providing your own IReferenceResolver implementation. See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details. Currently all references have to be available as files! * If you get 'class' does not contain a definition for 'member': try another modelType (for example 'null' to make the model dynamic). NOTE: You CANNOT use typeof(dynamic) to make the model dynamic! Or try to use static instead of anonymous/dynamic types. More details about the error: - error: (16, 18) The name 'model' does not exist in the current context - error: (66, 22) Could not find an implementation of the query pattern for source type 'IEnumerable'. 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'? Temporary files of the compilation can be found in (please delete the folder): /tmp/RazorEngine_q1aoizn2.zbx The template we tried to compile is: ``` I have excluding the template in the error message above.

razoreengine.netcore-patch.txt

phillipsj commented 5 years ago

@pascalberger it looks like RazorLight has active development. I would be happy to pick this up and run with it since I want to use Cake.Recipe on .NET Core.

pascalberger commented 5 years ago

@phillipsj What bothers me about Razor Light is that while there seem to be commits to the repo, their last (pre)release was over one and a half release ago, the last proper release over two years.

gavinjonesnz commented 4 years ago

@pascalberger Thankfully, seems to be some betas now coming through, so Razor Light may still be viable. https://github.com/toddams/RazorLight/releases Was the intention to shift to the new dotnet project files? I've got a build working for them. Not sure there's much point in a PR just for that - guessing you're keen to have this multi-targeted for netcoreapp2.0 and net461 ? If so I can have a go based on @phillipsj code - tho he seems to have removed it.

pascalberger commented 4 years ago

@gavinjonesnz I'm happy to accept a PR for changing to the new project format. Would even prefer to have it separated from the change of the rendering engine.

If you want to take over #185, and give it a try with latest beta you're welcome to do so. @phillipsj is currently not working on it, but the existing code seems like a good start.

gavinjonesnz commented 4 years ago

I think (cross fingers) I've got RazorLight mostly working, however there's some oddities with the Expando in RazorLight meaning I think you have to supply a dictionary with all the ViewBag items (otherwise you end up with null object errors because the properties don't exist). Going to test the theory manually, then will have a look on cleaner options. I'll get the tests working, but did you have a larger suite of test cases to try things out on if I do get things going?

pascalberger commented 4 years ago

@gavinjonesnz There are not really more test cases than in the projects.

What you can try is to rebuild the demo files for the documentation by running /demos/build.ps1. This will create reports for all included templates with most possible options.

pascalberger commented 4 years ago

@gavinjonesnz Did you had any success on this?

There will be a release with breaking change upcoming soon, and therefore it would be a good time for fundamental changes now :)

gavinjonesnz commented 4 years ago

@pascalberger yeah, sorry, as usual RL got in the way (and calamity). Will revisit, as I've not done much since Jan. I found some odd perf results with RazorLight, and never really resolved the issues with dynamic/expandos and razor binding the ViewBag. Was going to suggest perhaps a PR to generic-ise the report generator anyway? This is my test-out branch to anyone interested, probably needs a clean up now that other PR merged: https://github.com/gavinjonesnz/Cake.Issues.Reporting.Generic/tree/feature/multitarget-razorlight

pascalberger commented 4 years ago

@gavinjonesnz No problem. What is your idea regarding making the addin more generic?

gavinjonesnz commented 4 years ago

Oh, it was more about making a generic interface for the renderer. Made my YAGNI itch, but it was the first thing I played with when trying to run the current renderer and compare it against something new. Just super basic, like this: https://github.com/gavinjonesnz/Cake.Issues.Reporting.Generic/blob/ec82ccbecbb87566b0095f6322f4df7a975f0ef0/src/Cake.Issues.Reporting.Generic/IGenericIssueReportGenerator.cs

pascalberger commented 4 years ago

Cake.Issues.Reporting.Generic is already an implementation of an IIssueReportFormat abstraction. Cake.Issues.Reporting.Sarif is another issue report implementation which uses SARIF SDK (instead of Razor like in this case) to generate a SARIF compatible output.

You suggestion would be an abstraction layer about different Razor Engine implementations in this specific report format addin. I'm not sure if it is worth going this route, since evey implementation will also add additional dependencies to the addin.

pascalberger commented 4 years ago

We also have a look at this on tonights stream from @gep13. 19:00 UTC. Anybody interested is very welcome to join.

https://twitter.com/gep13/status/1282617611528933377