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

Issue: DynamicClassFactory fails to create dynamic type without properties #215

Closed
david-garcia-garcia opened this issue Oct 29, 2018 · 1 comment
Assignees
Labels

Comments

@david-garcia-garcia
Copy link
Contributor

Will work on a PR when got the time, just posting here for the record.

DynamicClassFactory.CreateType() will create a DynamicType with a "duplicate" constructor when the type has no properties and createParamterCtro = true.

This breaks later code when they try to find the constructor implementation.

I found this when doing:

                    var countQuery = query;

                    if (this.GroupBy != null)
                    {
                        countQuery = countQuery.GroupBy(
                            CustomParsingConfig.ParsingConfig,
                            this.GroupBy.KeySelector.Expression,
                            "new()");
                    }

                    result.Count = countQuery.Count();

Here I am using a dummy new() for the projection because I only want to count the results.

As a workaround, I replaced "new()" with "1", but still the bug is there.

The problem is when names.Length = 0:

image

The solution is to not create the second constructor if the type has no parameteres.

@StefH StefH added the bug label Oct 29, 2018
@StefH StefH changed the title DynamicClassFactory fails to create dynamic type without properties Issue: DynamicClassFactory fails to create dynamic type without properties Oct 29, 2018
@StefH
Copy link
Collaborator

StefH commented Oct 30, 2018

Thanks.

Make sure you start a branch from the latest master.

@StefH StefH mentioned this issue Nov 25, 2018
@StefH StefH closed this as completed Nov 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants