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

MissingMethodException thrown after upgrading to 2.11.0 #683

Closed
espenekvang opened this issue Jul 17, 2024 · 5 comments
Closed

MissingMethodException thrown after upgrading to 2.11.0 #683

espenekvang opened this issue Jul 17, 2024 · 5 comments

Comments

@espenekvang
Copy link

espenekvang commented Jul 17, 2024

We upgraded from 2.10.0 to 2.11.0 but when trying to generate clients using CSharpClientGenerator and the method GenerateFile it now throws an exception:

_Unhandled exception. System.TypeInitializationException: The type initializer for 'LiquidTemplate' threw an exception.
 ---> System.MissingMethodException: Method not found: 'Parlot.Fluent.Parser`1<System.Collections.Generic.List`1<!!0>> Parlot.Fluent.Parsers.OneOrMany(Parlot.Fluent.Parser`1<!!0>)'.
   at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidParser..ctor()
   at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate..cctor()
   --- End of inner exception stack trace ---
   at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate..ctor(String language, String template, Func`3 templateContentLoader, Object model, String toolchainVersion, CodeGeneratorSettingsBase settings)
   at NJsonSchema.CodeGeneration.DefaultTemplateFactory.CreateTemplate(String language, String template, Object model)
   at NSwag.CodeGeneration.CSharp.CSharpClientGenerator.GenerateClientTypes(String controllerName, String controllerClassName, IEnumerable`1 operations)+MoveNext()
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateAllClientTypes()
   at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(ClientGeneratorOutputType outputType)
   at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile()_

When downgrading to 2.10.0 of Fluid.Core the exception is no longer thrown.

@sebastienros
Copy link
Owner

It could mean that you have an old Parlot dll version sticking around. Or a direct reference to an old one. The current one to use is 1.0.0.
Or the other way around actually, that there is something using the older version of Fluid which tries to use the old Parser<> ctor that appears in the log but doesn't exist anymore.

Since it's a generator, it's executed by the compiler or VS, so it is definitely possible that a restart/clean could fix it.

Can I try to repro it locally? I haven't used NSwag so I shouldn't hit this issue if that is the case, if you have a branch I can try.

@espenekvang
Copy link
Author

Ok - thanks. I will try to look for an old dll first and let you know the result.

@espenekvang
Copy link
Author

Closing this. The errors was caused by and implicit reference to Fluid.Core 2.9.0 from NSwag.CodeGeneration.CSharp. For us to upgrade to latest Fluid.Core we would need NSwag.CodeGeneration.CSharp to be upgraded first.

@lahma
Copy link
Collaborator

lahma commented Jul 17, 2024

I've created a PR to update NJsonSchema's dependencies, including Fluid: RicoSuter/NJsonSchema#1719

@sebastienros
Copy link
Owner

Thank you @lahma

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

No branches or pull requests

3 participants