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

Tables without rows give a cryptic error message #58

Open
bruno-brant opened this issue Jan 30, 2019 · 0 comments
Open

Tables without rows give a cryptic error message #58

bruno-brant opened this issue Jan 30, 2019 · 0 comments

Comments

@bruno-brant
Copy link

I made a mistake building the Content and created a Table with zero rows.

The error thrown was

Message: System.ArgumentNullException : Value cannot be null.
Parameter name: source

Result StackTrace:	
at System.Linq.Enumerable.SelectMany[TSource,TResult](IEnumerable`1 source, Func`2 selector)
   at TemplateEngine.Docx.Container.<>c__DisplayClass26_0.<get_FieldNames>b__3(TableContent t)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Set`1.UnionWith(IEnumerable`1 other)
   at System.Linq.Enumerable.DistinctIterator`1.FillSet()
   at System.Linq.Enumerable.DistinctIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at TemplateEngine.Docx.RepeatContent.get_FieldNames()
   at TemplateEngine.Docx.Processors.RepeatProcessor.FillContent(XElement contentControl, IContentItem item)
   at TemplateEngine.Docx.Processors.RepeatProcessor.FillContent(XElement contentControl, IEnumerable`1 items)
   at TemplateEngine.Docx.Processors.ContentProcessor.FillContent(XElement content, IEnumerable`1 data)
   at TemplateEngine.Docx.Processors.ContentProcessor.FillContent(XElement content, Content data)
   at TemplateEngine.Docx.TemplateProcessor.FillContent(Content content)
   at Slingshot.Templates.WordTemplate.WordTemplateProcessor.FillContent(Content valuesToFill)
   at Slingshot.Templates.WordTemplate.WordTemplateProcessor.FillContentFromModel(Object model)
   at Slingshot.PropostaDeServico.PropostaDeServicoTemplate.GerarDocumento(IArchive archive, PropostaDeServicoModel model)
   at Slingshot.PipelineAtm.PipelineAtmFull.GerarAtmFull(Stream sementeStream, Stream outputStream)
   at Slingshot.PipelineAtm.Tests.PipelineAtmFullTests.CreateOutput()
Result Message:	
System.ArgumentNullException : Value cannot be null.
Parameter name: source

I traced it to an attempt by a RepeatContent to enumerate all its children, on class Container, at FieldNames:

var repeatsFieldNames = Repeats == null
   ? new List<string>()
   : Repeats.Select(t => t.Name).Concat(Repeats.SelectMany(t => t.Items.SelectMany(r => r.FieldNames)));

I'm not sure if TableContents must have rows, but I recommend a better error message to save us the time diagnosing this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant