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.

Exception thrown when using generics

See original GitHub issue

An exception is thrown when using newer versions of NJsonSchema and NSwag with any simple generics such as class A<T> { }.

I’m still working on isolating this further, but my current test case is located at https://github.com/grovesNL/nswag-test

Running ConsoleApp2 (referencing older NJsonSchema and NSwag versions) will succeed.

Running ConsoleApp3 (referencing newer NJsonSchema and NSwag versions) will fail with System.ArgumentException: 'Invalid type owner for DynamicMethod.'.

I know generics are not fully supported yet (https://github.com/RSuter/NJsonSchema/issues/23 and https://github.com/RSuter/NSwag/issues/704), but for now I was using TypeScriptResolver to replace A`1 with A<T> and it worked well with older versions.

I’ll continue to look into it and use the older versions for now.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RicoSutercommented, Aug 15, 2017

https://github.com/RSuter/NJsonSchema/commit/d6ae1f01ca436c8a121688858cc1c30f9590d519

This one is “fixed” for now - at least it works as before.

0reactions
grovesNLcommented, Aug 15, 2017

@RSuter Sounds great, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Is it wise to use generics for exceptions?
Since type parameters of generics are erased at runtime, there is no way to distinguish between generic exceptions with different type ...
Read more >
Java Exceptions and generic types - Michael Scharhag
Java forbids the creation of generic Exceptions. However, it is possible to pass (and throw) Exceptions as generic type parameters.
Read more >
Dont Throw Generic Exceptions - C2 wiki
In Java, routines must declare the exceptions that they throw unless they are subclasses of RuntimeException or Error. RuntimeExceptions are intended to be ......
Read more >
Java Generics - No Exception
A generic class is not allowed to extend the Throwable class directly or indirectly. ... A method is not allowed to catch an...
Read more >
Beware the dangers of generic Exceptions
This article explores the risks of throwing, catching, and ignoring generic Exceptions and suggests best practices for dealing with complex ...
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