Empty classes are only generated when in a namespace with a non-empty class

Issue #141 new
Anonymous created an issue

Because of the introduction of line 240 in TsGenerator.cs, empty classes are not generated when no non-empty class exists in the namespace.

For example:

namespace A.B.C
{
    [TsClass]
    public class GetItemsQuery : SortFilterQuery
    {
    }
}

will not be generated when its the only class in namespace A.B.C

This is a problem because we use these classes in TS to make sure the query sent over ajax are of the correct type and contain correct parameters, should the type evolve in the future.

This is a means of encapsulation of the ajax query data we are very happy to use, and it's a shame for us to be forced to include a class with a property in every namespace in order to make this one generate.

What would be good is at least have the option to generate empty types, as they are really useful; or maybe add a check :

if (generatorOutput == TsGeneratorOutput.Properties
    && !classes.Any(c => c.Fields.Any() || c.Properties.Any())
    && !classes.All(c => !c.Fields.Any() && !c.Properties.Any() && !c.Constants.Any()))
{
    return;
}

if (generatorOutput == TsGeneratorOutput.Constants
    && !classes.Any(c => c.Constants.Any())
    && !classes.All(c => !c.Fields.Any() && !c.Properties.Any() && !c.Constants.Any()))
{
    return;
}

I'm making a pull request for this change soon

Comments (3)

  1. eregrith

    @Lukas Kabrt Oh okay ^^ I'm new to bitbucket. I'll fork it later this evening and make a pull request as I plan to not only add the change but also make tests for this change and changes made in the original commit as they are not tested.

  2. Log in to comment