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.

Generic method in generic class issue

See original GitHub issue

Use MrAdvice with dnlib (MrAdvice nuget package). Have some issue with generic method on mono only. Can’t it reproduce on windows and can’t create synthetic test for this issue on linux unfortunately. Got exception only on live project. Have async generic method in generic class like: class Class < T1 > { async Task < IEnumerable < T2 > > Method < T2 > () }

When call this method with second parameter type got exception:

Error: [2016-10-17T19:36:29.858+03] 2 399 - System.AggregateException: One or more errors occurred ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at ArxOne.MrAdvice.Threading.TaskCompletionSourceImplementation`1[System.Collections.Generic.IEnumerable`1[System.String]].SetResult (System.Object result) [0x00000] in <filename unknown>:0 
  at ArxOne.MrAdvice.Invocation.ContinueTask (System.Threading.Tasks.Task adviceTask, ArxOne.MrAdvice.Threading.TaskCompletionSource adviceTaskSource, ArxOne.MrAdvice.Advice.AdviceValues adviceValues) [0x00000] in <filename unknown>:0 
  at ArxOne.MrAdvice.Invocation+<>c__DisplayClass1_0.<ProceedAdvice>b__1 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.TaskActionInvoker+ActionTaskInvoke.Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
 --> (Inner exception 0) System.InvalidCastException: Cannot cast from source type to destination type.
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at ArxOne.MrAdvice.Threading.TaskCompletionSourceImplementation`1[System.Collections.Generic.IEnumerable`1[System.String]].SetResult (System.Object result) [0x00000] in <filename unknown>:0 
  at ArxOne.MrAdvice.Invocation.ContinueTask (System.Threading.Tasks.Task adviceTask, ArxOne.MrAdvice.Threading.TaskCompletionSource adviceTaskSource, ArxOne.MrAdvice.Advice.AdviceValues adviceValues) [0x00000] in <filename unknown>:0 
  at ArxOne.MrAdvice.Invocation+<>c__DisplayClass1_0.<ProceedAdvice>b__1 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.TaskActionInvoker+ActionTaskInvoke.Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 

I have two specific methods and crashes only second one (think JIT is in business). I.e first call Method<string> is ok, and then Method<DateTime> crashes. Then restart the application and call Method<DateTime> first, and then Method<string> crashes. So it depends which method I invoke first.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:57 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexanderButscommented, Oct 25, 2016

Checked 2.1.2. Unit tests are ok. Exception flow is ok. Original issue (with generics) is fixed. But now seems to me aspect is created on every generic method call. With non-generic methods it works as earlier did. It shouldn’t be like that, I think.

1reaction
AlexanderButscommented, Oct 19, 2016

unit test is ok (exception propagation issue). original issue will check a little bit later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java generic methods in generics classes
Whilst generic methods are instance methods, it is not clear to me that JLS 4.8 applies to generic methods. The generic method's type...
Read more >
Generic Methods - Java™ Tutorials
Generic methods allow type parameters to be used to express dependencies among the types of one or more arguments to a method and/or...
Read more >
Generic Methods - Learning the Java Language
Generic methods are methods that introduce their own type parameters. This is similar to declaring a generic type, but the type parameter's scope...
Read more >
Java Generics Example Tutorial - Generic Method, Class ...
We use <T> to create a generic class, interface, and method. The T is replaced with the actual type when we use it....
Read more >
Generics in Java
Generics means parameterized types. The idea is to allow type (Integer, String, … etc., and user-defined types) to be a parameter to methods ......
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