question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error generating typescript client System.Int64' cannot be converted to type 'System.Int32

See original GitHub issue

Environment - ASP.NET Owin.

After upgrading NJsonSchema.CodeGeneration ^ NJsonSchema.CodeGeneration.TypeScript to 10.1.11 and NSwag.CodeGeneration.TypeScript 13.3.0 generator throws error. On any method (tried to mark all with [OpenApiIgnore], and find “bugged method” but without success)

NJsonSchema.CodeGeneration 10.1.5 and NSwag.CodeGeneration.TypeScript 13.2.3 version working fine.

Any clues how to fix it?

"Error while rendering Liquid template TypeScript/Class: System.ArgumentException: Object of type ‘System.Int64’ cannot be converted to type ‘System.Int32’.

at DotLiquid.Context.HandleError(Exception ex) at DotLiquid.Block.RenderAll(List`1 list, Context context, TextWriter result) at DotLiquid.Document.Render(Context context, TextWriter result) at DotLiquid.Template.RenderInternal(TextWriter result, RenderParameters parameters) at DotLiquid.Template.Render(TextWriter writer, RenderParameters parameters) at DotLiquid.Template.Render(RenderParameters parameters) at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render()

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
dmandreevcommented, Apr 1, 2020

As I can see, it’s change in DotLiquid that introduced by
commit 7c168d18b4ec5665076e03cde8152ebceecb1985 Author: David Burg daviburg@microsoft.com Date: Tue Feb 25 13:14:34 2020 -0800

Support integer values for numbers beyond the range of 32 bit integers but within the RFC allowed 64 bit integers.

at Context.cs Contect class in function private object Resolve(string key, bool notifyNotFound = true)

Old code parses integers in such way:

   match = IntegerRegex.Match(key);
            if (match.Success)
                return Convert.ToInt32(match.Groups[1].Value);

new code parses integers and return long

           // Integer.
            match = IntegerRegex.Match(key);
            if (match.Success)
            {
                return Convert.ToInt64(match.Groups[1].Value);
            }

after that it leads to exception in Strainer.Invoke due to dynamic “tab” filter invocation because it has signature {(, System.String Tab(DotLiquid.Context, System.String, Int32))}

The workaround is to downgrade DotLiquid to 2.0.314

0reactions
daviburgcommented, Jun 2, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Expression.Convert: Object of type 'System.Int64' cannot be ...
to initialize an instance of Person using above method, this error occurs: Object of type 'System.Int64' cannot be converted to type 'System.
Read more >
System.InvalidCastException: Unable to cast object of type ...
I think that it cannot be always converted. Try using long or Int64 instead of int in your class and other parts. (Or...
Read more >
Unable to cast System.Int32 to System.Int64 : r/csharp
Int32 ' to type 'System.Int64'.' I can make a helper method to solve my problem, but I am curious as to why the...
Read more >
The JSON value could not be converted to System.Int32
Issue resolution for System.Text.Json.JsonException: The JSON value could not be converted to System.Int32 or other primitives types Boolean or double etc.
Read more >
Unable to cast object of type 'system.int32' ...
int Number = int.Parse(dr.GetString(0)); combocustomer.Items.Add(Number); find the above code , am going to fetch the customer_ID ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found