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

Possible Bug #24

Closed
matthewblott opened this issue Sep 10, 2020 · 6 comments
Closed

Possible Bug #24

matthewblott opened this issue Sep 10, 2020 · 6 comments
Assignees

Comments

@matthewblott
Copy link

matthewblott commented Sep 10, 2020

When I tried to access a route in ASP.NET with a strongly typed paramter I kept getting the following error:

Model bound complex types must not be abstract or value types and must have a parameterless constructor.

I had real trouble finding the problem as I had the code working prior to using the StronglyTypedId library itself. After much hunting I found the offending line:

return sourceType == typeof(int) || base.CanConvertFrom(context, sourceType);

In the example on your website here typeof(string) is used in place of typeof(int). The example is for a Guid and not an int but the behaviour is the same when used with ASP.NET routes (which is what I thought that snippet was for). FWIW the Long template also references int. Shall I fix?

@andrewlock
Copy link
Owner

Sorry for the delay, this one slipped past me!

Just to clarify, you say this error is in ASP.NET routes, is that ASP.NET as in pre-ASP.NET Core? I've not tied it in there, but I don't think they will work at all based on that error message, as it implies you can't use structs (which is required in the library at the moment)

@matthewblott
Copy link
Author

No, this is specifically ASP.NET Core (3.1).

@andrewlock
Copy link
Owner

Urgh, looks like an SDK update has broken the build, will have to try and fix that first before I can fix this 😭

@matthewblott
Copy link
Author

Urgh, looks like an SDK update has broken the build, will have to try and fix that first before I can fix this 😭

No worries, thanks for the update :-)

@andrewlock
Copy link
Owner

This took rather too long to address, sorry 😳

I've released a beta version of a major update to the library converts to using Source generators. There's quite a few breaking changes in the release, so please make sure to check the release notes for how to update, but I'd appreciate any feedback you have before I do a final release! It fixes this issue too.

I've also written a blog post announcing the update that goes into a bit more details: https://andrewlock.net/rebuilding-stongly-typed-id-as-a-source-generator-1-0-0-beta-release

Thanks! 🙂

@andrewlock
Copy link
Owner

I believe this is solved in the latest betas, so I'll close it for now. Feel free to reopen if you still have any issues

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

Successfully merging a pull request may close this issue.

2 participants