-
Notifications
You must be signed in to change notification settings - Fork 4
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
trying to generate a type with a delegate crashes dotnet #417
Comments
I fixed some types like this recently, I'm surprised this got through. Thanks for the replication, I'll check it out. |
@hahn-kev are you using the latest version? I've tested this and it doesn't exception. |
I'm so sorry, I did not try the latest version, we updated last month so I didn't think to check for a newer version. It does not crash anymore, however it just returns null which I didn't expect as it's not annotated to return null. I would prefer to configure it to throw an exception if it can't generate a type for some reason, would that be possible? This is especially important when generating an object graph and some dependency deep down can't be generated. |
@hahn-kev perhaps that's an option that could be added (e.g. |
I kinda feel like if it can return null then the API should communicate that to the developer. If I don't know then my code will throw at some point when it tries to use it. Your code can throw early or my code can throw later. |
@hahn-kev I wanted to make sure you're clear that even if we mark the generate() method as possibly returning null, it might generate a top level object with an instance but downstream objects could still be null. Does the nullable return value still help you considering this? |
Not really, which is why I would still want an option to throw, otherwise a test might fail or code throw when something is null that shouldn't be null. |
I came across this when trying to generate a bunch of types
exception
something as simple as this will reproduce the crash:
I don't think generating Actions is even possible or should be supported, but I do think a good error should be thrown, In my case I was trying to generate a bunch of types and it was quite difficult to track down the offender because I didn't know what was going on. A simple test like
type.IsAssignableTo(typeof(Delegate)
should work in my testing.The text was updated successfully, but these errors were encountered: