Use Package Private Classes, Types and Methods as a Data Source for LINQ Reporting Engine (C# .NET) | DOCX Word Template

Hiho,

we currently implement a report using the ReportingEngine. We create an object of a custom type and call the build method of the ReportingEngine with this object (i.e. we use this object as the data-source). This custom type is declared as package private.

As long as we do not declare it as public, we get the following error if executing the ReportingEngine:

A data source object must be of a visible type or implement ‘interface java.lang.Iterable’.\r\nParameter name: dataSource

Simple question: Is there any way how we can avoid to mark the type (and it’s methods) as public?

@ingo.griebsch,

As per documentation, the LINQ reporting engine does not support working with types that are not visible outside of its declaring package (this would break encapsulation). So, there is no way to use an instance of a package-private type as a data source.

However, if you do not want to expose the type of an object used as a data source publicly, there is still a way to make it happen. You can declare the type as public in a separate package/JAR. Then the JAR can be embedded as a (possibly encrypted) resource to the main JAR and loaded dynamically during runtime. With this approach, the type will not be visible to client code, but will be visible to the LINQ reporting engine. Some useful information on the matter can be found here.