Is failing for generic method
Good day!
Was trying to use your tool to see asm of generic method, but the tool is failing for me.
Input C#:
using System;
using System.Runtime.CompilerServices;
public class C
{
public bool M(string left, string right)
{
return IsSame(left, right);
}
public static bool IsSame<T>(T left, T right)
{
if(typeof(T) == typeof(string))
{
var leftStr = (string)(object)left;
var rightStr = (string)(object)right;
return string.Equals(leftStr, rightStr, StringComparison.Ordinal);
}
return false;
}
}
I've compiled the tool locally and run with the following args:
c:\Projects\PowerUp\src\PowerUp.Watcher\bin\Release\net6.0\PowerUp.Watcher.exe -cs .\checks.cs checks_out.asm
Output I'm getting:
System.ArgumentException: The given generic instantiation was invalid.
at System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(RuntimeMethodHandleInternal method, IntPtr* pInstantiation, Int32 cInstantiation)
at System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation)
at PowerUp.Core.Decompilation.JitExtensions.ToAsm(MethodInfo methodInfo, ILMethodMap[] sourceCodeMap) in C:\Projects_External\PowerUp\src\PowerUp.Core\Decompilation\JITExtensions.cs:line 214
at PowerUp.Core.Decompilation.JitExtensions.ToAsm(Type typeInfo, ILMethodMap[] sourceCodeMap, Boolean private) in C:\Projects_External\PowerUp\src\PowerUp.Core\Decompilation\JITExtensions.cs:line 161
at PowerUp.Watcher.CSharpWatcher.DecompileToASM(String code) in C:\Projects_External\PowerUp\src\PowerUp.Watcher\CSharpWatcher.cs:line 811
at PowerUp.Watcher.CSharpWatcher.<>c__DisplayClass10_0.<<WatchFile>b__0>d.MoveNext() in C:\Projects_External\PowerUp\src\PowerUp.Watcher\CSharpWatcher.cs:line 195
Here is output in console:
Input >> -cs .\checks.cs checks_out.asm
CSharp Watcher Initialize:
Input File: .\checks.cs
ASM File: checks_out.asm
IL File:
CS File:
[WARNING]: IL File doesnt exist
[WARNING]: Lowered CSharp File doesnt exist
Libs Path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-rc.1.21451.13\
.NET Enviromment variables:
Language Version: default
.NET Version: 6.0.10
[RELEASE]
App Configuration:
CppCompilerPath = [Invalid or Missing] Watchers might fail.
DotNetCoreDirPathDefault = C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-rc.1.21451.13\
DotNetCoreDirPathNet3 = C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.18\
DotNetCoreDirPathNet5 = C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.17\
DotNetCoreDirPathNet6 = C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0-rc.1.21451.13\
DotNetCoreDirPathNet7 = C:\Program Files\dotnet\shared\Microsoft.NETCore.App\
FSharpCompilerPath = C:\Program Files\dotnet\sdk\6.0.100-rc.1.21458.32\FSharp\fsc.dll
GOCompilerPath = [Invalid or Missing] Watchers might fail.
RustCompilerPath = [Invalid or Missing] Watchers might fail.
I know that generics are tricky, so am curious whether it's a well-known limitation of the tool or whether I'm doing something wrong 🤔
Open generics are a problem, but I have made some progress, and they used to work in some instances; perhaps one of the recent changes broke them ... I'm still committed to make open generics work in a Non-AOT JIT environment, but I don't have time to dig deep into the compiler :)
@zvirja Took a while but I finally had time to implement better support.
