Razorlight: new RawString(string.empty) crashes

Created on 28 Mar 2018  路  10Comments  路  Source: toddams/RazorLight

new RawString(string.Empty) is crashing. It should not throw an argument null exception.

Most helpful comment

I disagree, it should mimic the Html.Raw Razor directive, which handles empty/null content. If the value is empty or null it returns HtmlString.Empty. A similar approach should be taken here.

All 10 comments

Seems like the check here could be ammended to check for null rather than NullOrEmpty.

I disagree, it should mimic the Html.Raw Razor directive, which handles empty/null content. If the value is empty or null it returns HtmlString.Empty. A similar approach should be taken here.

I agree with @nloding. Coming from RazorEngine, a whole bunch of our tests around are templates are broken because we didn't specify a value for every single property.

@mscrivo you beat me to it - I was going to submit a PR this weekend :) Thanks for doing that, hopefully @toddams can get it pulled in!

@nloding no problem .. am actively working with it right now and it's blocking me, so I don't have much choice :) I've published a package with the changes here: https://www.nuget.org/packages/RazorLight.Unofficial .. will likely get rid of that at some point if @toddams merges the changes, or has a better way of fixing these issues.

@toddams what is the logic with throwing an exception when the argument is null, which is break from how the Razor engine handles Html.Raw?

Why is this issue closed? The latest package(2.0.0-beta1) doesn't resolve this problem.

Issue is resolved as fix is merged to master

Any news on this issue? Is a new version coming?

+1
Getting this issue also.

Was this page helpful?
0 / 5 - 0 ratings