Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot write HTML reports: Crash error (strongly-named assemblies) #141

Closed
craigfowler opened this issue May 5, 2018 · 5 comments
Closed
Labels
bug A defect in the software wontfix This won't be worked on

Comments

@craigfowler
Copy link
Member

Here's an error I've seen from the Agiil project.

Error whilst writing HTML report                                                                                                                                                                                                 
CSF.Zpt.Rendering.RenderingException: An unexpected exception occurred whilst resolving metal:extend-macro="reportable" at [Unknown source file] (line 100). ---> System.InvalidOperationException: Sequence contains no matching element                                                                                                                                                                                                                         
  at System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00070] in <9cf10939da67463f9bbe1799644fd07e>:0                                           
  at CSF.Zpt.Tales.ExpressionEvaluatorService.PopulateCache (CSF.Zpt.Tales.ExpressionEvaluatorCache cache) [0x000b9] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                     
  at CSF.Zpt.Tales.ExpressionEvaluatorCache.PopulateIfRequired (System.Action`1[T] populationCallback) [0x00029] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                         
  at CSF.Zpt.Tales.ExpressionEvaluatorService.GetCache () [0x0000a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                                                      
  at CSF.Zpt.Tales.ExpressionEvaluatorService.GetDefaultEvaluator () [0x00000] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                                           
  at CSF.Zpt.Tales.SimpleEvaluatorSelector.GetEvaluator (CSF.Zpt.Tales.Expression expression) [0x0005b] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                  
  at CSF.Zpt.Tales.TalesModel.Evaluate (CSF.Zpt.Tales.Expression talesExpression, CSF.Zpt.Rendering.IRenderingContext context) [0x00022] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                 
  at CSF.Zpt.Tales.TalesModel.Evaluate (System.String expression, CSF.Zpt.Rendering.IRenderingContext context) [0x0001b] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                 
  at CSF.Zpt.Metal.MacroFinder.GetReferencedMacro (CSF.Zpt.Rendering.IRenderingContext context, System.String attributeName) [0x00025] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                   
   --- End of inner exception stack trace ---                                                                                                                                                                                    
  at CSF.Zpt.Metal.MacroFinder.GetReferencedMacro (CSF.Zpt.Rendering.IRenderingContext context, System.String attributeName) [0x0005b] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                   
  at CSF.Zpt.Metal.MacroFinder.GetExtendedMacro (CSF.Zpt.Rendering.IRenderingContext context) [0x00000] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                  
  at CSF.Zpt.Metal.MacroFinder.GetUsedMacro (CSF.Zpt.Rendering.IRenderingContext context) [0x00012] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                      
  at CSF.Zpt.Metal.MacroExpander.GetUsedMacro (CSF.Zpt.Rendering.IRenderingContext context) [0x0000e] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                    
  at CSF.Zpt.Metal.MacroExpander.ExpandMacros (CSF.Zpt.Rendering.IRenderingContext context) [0x0000e] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                    
  at CSF.Zpt.Metal.MetalVisitor.Visit (CSF.Zpt.Rendering.IRenderingContext context) [0x00034] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                            
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0000e] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitRecursively (CSF.Zpt.Rendering.IRenderingContext context) [0x0004a] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                       
  at CSF.Zpt.Rendering.ContextVisitorBase.VisitContext (CSF.Zpt.Rendering.IRenderingContext context) [0x00000] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                           
  at CSF.Zpt.Rendering.ElementRenderer.RenderElement (System.Object model, CSF.Zpt.Rendering.IZptElement element, CSF.Zpt.Rendering.IRenderingSettings options, System.Action`1[T] contextConfigurator) [0x000f7] in <98708389b29a4e1ba5b5e88847f013e9>:0                                                                                                                                                                                                         
  at CSF.Zpt.ZptDocument.Render (System.Object model, System.IO.TextWriter writer, CSF.Zpt.Rendering.IRenderingSettings options, System.Action`1[T] contextConfigurator) [0x00025] in <98708389b29a4e1ba5b5e88847f013e9>:0       
  at CSF.Screenplay.Reporting.HtmlReportWriter.Write (CSF.Screenplay.Reporting.Models.Report report) [0x00015] in <96227bdcf28744778b4bdcd64f2bfea8>:0 
  at Agiil.Tests.BDD.ScreenplayIntegrationConfig.WriteHtmlReport (CSF.Screenplay.Reporting.IObjectFormattingService formatter, CSF.Screenplay.Reporting.Models.Report report, System.IO.DirectoryInfo directory) [0x00023] in <7bab6ac18aac4304adb315a438674d7d>:0

Additionally, at the end of the test run I saw this:

Unable to find assembly 'CSF.Zpt.Abstractions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730'.
Agent Process was terminated successfully after error.
@craigfowler craigfowler added the bug A defect in the software label May 5, 2018
@craigfowler
Copy link
Member Author

I think that this might be caused by the HardCodedZptSharpConfigurationProvider.

There's a method:

public IEnumerable<string> GetAllPluginAssemblyPaths();

I think that this needs to be returning the assembly full names instead of their simple names. Now that the assemblies are strongly-named, they won't load properly with just simple names.

@craigfowler
Copy link
Member Author

In fact, I can reproduce this if I remove the ZPT-Sharp configuration from the App.config file. I shouldn't need to do this though, because I am specifying a configuration which is hard-coded.

Maybe ZPT-Sharp is 'spinning up' another config instance which is using the configuration file instead of my hard-coded config source.

@craigfowler
Copy link
Member Author

craigfowler commented May 5, 2018

Workaround

Place the following config into your test project's App.config:

  <configSections>
    <sectionGroup name="CSF">
      <sectionGroup name="Zpt">
        <section name="PluginConfigurationSection"
          type="CSF.Zpt.PluginConfigurationSection, CSF.Zpt, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
        <sectionGroup name="ExpressionEvaluators">
          <sectionGroup name="CSharpExpressions">
            <section name="ExpressionConfigurationSection"
              type="CSF.Zpt.ExpressionEvaluators.CSharpExpressions.ExpressionConfigurationSection, CSF.Zpt.ExpressionEvaluators.CSharpExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          </sectionGroup>
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <CSF>
    <Zpt>
      <PluginConfigurationSection DefaultHtmlDocumentProvider="CSF.Zpt.DocumentProviders.HtmlZptDocumentProvider"
        DefaultXmlDocumentProvider="CSF.Zpt.DocumentProviders.XmlLinqZptDocumentProvider"
        DefaultExpressionEvaluator="CSF.Zpt.ExpressionEvaluators.PathExpressions.PathExpressionEvaluator">
        <PluginAssemblies>
          <Assembly Name="CSF.Zpt.DocumentProviders.XmlLinq, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.ExpressionEvaluators.CSharpExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.ExpressionEvaluators.NotExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.ExpressionEvaluators.PathExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.ExpressionEvaluators.StringExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.DocumentProviders.HtmlHAP, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
          <Assembly Name="CSF.Zpt.ExpressionEvaluators.LoadExpressions, Version=1.0.6.0, Culture=neutral, PublicKeyToken=83989bab8a1a4730"/>
        </PluginAssemblies>
      </PluginConfigurationSection>
      <ExpressionEvaluators>
        <CSharpExpressions>
          <ExpressionConfigurationSection>
            <Assemblies>
              <Assembly Name="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            </Assemblies>
            <Namespaces>
              <Namespace Name="System"/>
              <Namespace Name="System.Linq"/>
            </Namespaces>
          </ExpressionConfigurationSection>
        </CSharpExpressions>
      </ExpressionEvaluators>
    </Zpt>
  </CSF>

craigfowler added a commit to csf-dev/agiil that referenced this issue May 5, 2018
This provides working HTML reports, using the workaround documented at:

  csf-dev/CSF.Screenplay#141 (comment)
@craigfowler craigfowler added the defer/blocked Could be worked-on but not yet; lower priority label Jun 5, 2018
@craigfowler
Copy link
Member Author

I have had to defer this for now, since it's blocked on an upstream ZPT-Sharp issue.

@craigfowler craigfowler changed the title Error writing HTML report using strong-named assemblies Devs cannot write HTML reports due to a crash error relating to strongly-named assemblies Jun 25, 2018
@craigfowler craigfowler changed the title Devs cannot write HTML reports due to a crash error relating to strongly-named assemblies Cannot write HTML reports: Crash error (strongly-named assemblies) Jun 26, 2018
@craigfowler
Copy link
Member Author

This is no longer critical. Because of architectural changes it is now acceptable to keep this in the app.config for the HTML report renderer.

Wontfix.

@craigfowler craigfowler added wontfix This won't be worked on and removed defer/blocked Could be worked-on but not yet; lower priority labels Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the software wontfix This won't be worked on
Projects
None yet
Development

No branches or pull requests

1 participant