extent-framework / extentreports-csharp

Extent Reporting Library, .NET
http://extentreports.com
Apache License 2.0
49 stars 40 forks source link

extent.Flush() thowing RazorEngine error #167

Open bzhechkov opened 1 year ago

bzhechkov commented 1 year ago

extent.Flush() was working fine with v4.1.0 for ages and recently started to fail with this:

System.ArgumentException HResult=0x80070057 Message=Expression of type 'CompiledRazorTemplates.Dynamic.RazorEngine_059ef63a8d6748b1bdcc58bfe5871a11' cannot be used for return type 'RazorEngine.Templating.ITemplate' Source=System.Linq.Expressions StackTrace: at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection1 parameters, String paramName) at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable1 parameters) at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, Boolean tailCall, IEnumerable1 parameters) at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, ParameterExpression[] parameters) at RazorEngine.Templating.TypeLoader.GetConstructorInternal(Type type) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at RazorEngine.Templating.TypeLoader.GetConstructor(Type type) at RazorEngine.Templating.TypeLoader.CreateInstance(Type type) at RazorEngine.Templating.DefaultActivator.CreateInstance(InstanceContext context) at RazorEngine.Templating.RazorEngineCore.CreateTemplate(ICompiledTemplate template, Object model, DynamicViewBag viewbag) at RazorEngine.Templating.RazorEngineCore.d12.MoveNext() at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>cDisplayClass16_0.b0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at AventStack.ExtentReports.Reporter.ExtentHtmlReporter.Flush(ReportAggregates reportAggregates) at AventStack.ExtentReports.Core.ReportObservable.<>cDisplayClass59_0.b__0(IExtentReporter x) at System.Collections.Generic.List1.ForEach(Action1 action) at AventStack.ExtentReports.Core.ReportObservable.NotifyReporters() at AventStack.ExtentReports.Core.ReportObservable.Flush() at AventStack.ExtentReports.ExtentReports.Flush()`

kais-khalifa commented 1 year ago

Not sure if it's related to the same issue but we are facing the a similar issue with extent.Flush() on our Net7 project. I tried to experiment with different Target Frameworks and It seems to be working with NetFramework48, but not with Net6/Net7

`TearDown : System.TypeLoadException : Could not load type 'Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine' from assembly 'Microsoft.AspNetCor...

TearDown : System.TypeLoadException : Could not load type 'Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine' from assembly 'Microsoft.AspNetCore.Razor.Language, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
--TearDown
   at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable`1 namespaces, TypeContext context)
   at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
   at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.CompileType(TypeContext context)
   at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
   at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
   at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at AventStack.ExtentReports.Reporter.ExtentHtmlReporter.Flush(ReportAggregates reportAggregates)
   at AventStack.ExtentReports.Core.ExtentObservable.<>c__DisplayClass59_0.<NotifyReporters>b__0(IExtentReporter x)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.Core.ExtentObservable.NotifyReporters()
   at AventStack.ExtentReports.Core.ExtentObservable.Flush()
   at AventStack.ExtentReports.ExtentReports.Flush()
   at Web.UI.UiBase.AssemblyBase.AssemblyTearDown() in ...`
image