C
C#•5mo ago
FAAAAT

Type <class name> appears to be immutable, but no constructor found to accept values.

Hi guys, could someone help me with a werid issue about immutable class? I have a class looks like this: As you can see I am using command line parser to create a command line tools. I can run debug output successfully but not with release output. The error is: Unhandled exception. System.InvalidOperationException: Type SugonBMCMegarac.ScriptVerb appears to be immutable, but no constructor found to accept values. at CommandLine.Core.InstanceBuilder.BuildImmutable[T](Type, Maybe1, IEnumerable1, IEnumerable1, List1) at CommandLine.Core.InstanceBuilder.<>cDisplayClass1_01.<Build>b5() at CommandLine.Core.InstanceBuilder.Build[T](Maybe1, Func3, IEnumerable1, StringComparer, Boolean, CultureInfo, Boolean, Boolean, Boolean, IEnumerable1) at CommandLine.Parser.ParseArguments[T](IEnumerable1) at SugonBMCMegarac.Program.Main(String[])
No description
7 Replies
Pobiega
Pobiega•5mo ago
Try removing the constructor, the class is clearly mutable with only public setters as far as I can see.
FAAAAT
FAAAATOP•5mo ago
HI Pobiega, thanks for your helping here. Actually I tried it. Doesn't work 🥲
Pobiega
Pobiega•5mo ago
What is the IDE warning for DomainOrIP btw? The other string props don't have any warnins
FAAAAT
FAAAATOP•5mo ago
Just typo I think
No description
Pobiega
Pobiega•5mo ago
Ok No idea then, except making sure you are not running a previous build The class is not immutable, so I don't know why the cli helper would say it is
FAAAAT
FAAAATOP•5mo ago
Yeah, I also wonder about it. Since I am not using keyworkd "record", and I can run the debug output successfully, I think maybe the compiler do the magic for me by default.... Thanks anyway. I will try delete all the output and try again. Hi guys, after some debug, I found it is not related with the feature "Immutable Class". It caused by CommandLine.Core.InstanceBuilder.BuildImmutable in package CommandLineParser. It simply check the ScriptVerb.IsMutable to decide which build method should be call BuildImmutable or BuildMutable. Need further investigation. Will take another time to finish it. PS: I checked the repo of CommandLineParser, it seems stop update about 2 years.... The bugs user reported leaves there for a long time.
Pobiega
Pobiega•5mo ago
There are other, better, alternatives for CLI development I personally really enjoy https://github.com/Tyrrrz/CliFx
Want results from more Discord servers?
Add your server