Closed rizi closed 6 months ago
Without actually troubleshooting, I'm betting the parameterless constructor is being chosen for the creation point.
In that case OnConstruction() is being called which is a partial, and it's failing.
I wonder if the best solution is to fail gracefully and return null for this object (because the object can't be created) or maybe try the next constructor or something.. any other ideas?
Without actually troubleshooting, I'm betting the parameterless constructor is being chosen for the creation point.
In that case OnConstruction() is being called which is a partial, and it's failing.
I wonder if the best solution is to fail gracefully and return null for this object (because the object can't be created) or maybe try the next constructor or something.. any other ideas?
I digged a little bit deeper into the problem and it's definitely not the partial method call, it's the
MessageParser
public MessageParser(Func<T> factory)
: this(factory, false, (ExtensionRegistry) null)
{
}
internal MessageParser(
Func<T> factory,
bool discardUnknownFields,
ExtensionRegistry extensions)
: base((Func<IMessage>) (() => (IMessage) factory()), discardUnknownFields, extensions)
{
this.factory = factory;
}
I don't know if it's possible to fake such an object, would be quite helpful though.
If it's not possible I would (as you suggested) fail gracefully and return null.
What do you think?
Br
Can you look at this commit: https://github.com/soenneker/soenneker.utils.autobogus/commit/4c4b80e9d33927056221a9bb0aa792883cdf8a0d
To boil the change down: if a constructor has a Func as a parameter, it is excluded from generation.
I think you should be able to still generate the parent ArticleCulture now at least... let me know how it works
@soenneker it's working with the latest version! (https://github.com/soenneker/soenneker.utils.autobogus/commit/4c4b80e9d33927056221a9bb0aa792883cdf8a0d) Thank you very much.
When trying to create a fake from a generated class (gRPC object), the following error (crashes the whole test runner process) occurs:
Exit code is -1073741819 (Fatal error. Internal CLR error. (0x80131506)
Here is the sample class which is generated by the C#-Protobuf compiler:
Here is the code, that causes the error: