Open ashishjw opened 7 years ago
Seems like your template type is a generic type with an unexpected full name.
Can you tell me more about the IntranetDASHBOARD.Core.MVC.TemplateBase<iDNotification>
type?
Can you show the typeof(T).FullName
string for all relevant types (including the full generic type, the generic type-defs and all parameters)?
The following code is failing for your type.
If you could provide a unit test with a fix as PR that would be awesome!
Hey matthid, Thanks for the reply. It turned out to be an obfuscation issue for us which got resolved when we de-obfuscated namespaces for the class where we have used Razor Engine. Its all good now running great.
We problably should still work with the obfuscated code. I'd say it's still a bug but not as urgent as I initially assumed. The requested info would still help...
May be but i am not so convinced, the reason for that is the way we have implemented obfuscation through dotfuscator tool internally. The namespaces which are mentioned in the template have been obfuscated and we cannot refer to obfuscated code from say aspx and cshtml page. If we do so then we have to exclude them from obfuscation. The reason for this error i am assuming is after obfuscation template type which is "IntranetDASHBOARD.Core.MVC.Models.Emails.iDNotification" name has been renamed to something else and then this code (type.FullName.IndexOf('`')) inside CSharpGetRawTypeName is causing exception.
Although i can still give you information which you have requested - "iDNotification" is the model inside MVC.Models.Emails namespace(obfuscation of which was causing issue) . It has a property Notifications As List(Of iDNotificationActivity) which contains all the information about Notifications. Template base is Generic class(TemplateBase(Of T)). And typeof(T).Fullname is IntranetDASHBOARD.Core.MVC.Models.Emails.iDNotification
@ashishjw I see what you are saying:
Because of the obfuscation the template is invalid and RazorEngine is unable to compile it.
But that is only half of the truth, because you can remove the
@inherits IntranetDASHBOARD.Core.MVC.TemplateBase<iDNotification>
line and set it programmatically (by setting a template-base in the configuration).
Now it still wouldn't compile, because all fields are removed/renamed/obfuscated. But in theory a empty template (or a template using only System
stuff should work. Even when using a obfuscated template-base.
What I'm saying is that our code is failing too early (which is the bug you found). We would need the "obfuscated" type name to fix it. But the bug is really really minor, because - as you noticed - we still couldn't compile the template in all practical cases later on.
Any updates on this one? I am getting the same error in a previously working template.
Hi, Razor Engine throws ArgumentOutOfRangeException on RunCompile method, Below is the stack trace for the same. This is one very weird issue i am facing, although it run fine on dev branch , this issue comes on prod, template which we are using is same on dev and prod branches as well as the dll version of Razor Engine.
and my template looks like this