badamczewski / PowerUp

⚡ Decompilation Tools and High Productivity Utilities ⚡
GNU Affero General Public License v3.0
1.64k stars 54 forks source link

IndexOutOfRangeException during C# compilation #10

Closed harrison314 closed 2 years ago

harrison314 commented 2 years ago

Hello, i used PowerUpWatcher (commit 894ffa42ee58396acf55262bfaff9a7c8c1ebe9f) on Windows 11 64-bit.

With test.cs:

int M(int i)
{
    if(i==1) return 1;
    i++;
    i++;
    return i;
}

alwais write to test.asm:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at PowerUp.Watcher.ILWriter.ToILString(DecompilationUnit unit) in C:\Users\**\Desktop\PowerUp-main\src\PowerUp.Watcher\ILWriter.cs:line 20
   at PowerUp.Watcher.CSharpWatcher.<>c__DisplayClass10_0.<<WatchFile>b__0>d.MoveNext() in C:\Users\**\Desktop\PowerUp-main\src\PowerUp.Watcher\CSharpWatcher.cs:line 218

I compile project using dotnet publish -c Release -f net6.0.

And screenshot of console output: obrázok

badamczewski commented 2 years ago

@harrison314 the Watcher is unable to find any file you provided (see the WARNING message in the log) it will use your cmd working directory to figure out the relative path, so either fix that or provide an absolute path. In this case, the output files are not found, so the best way to handle this would be to just try and create them.

I will add such code path to the watcher(s)

EDIT:

This code path already exists and it works well, it is something else ... I'm trying to work out the problem.

EDIT2:

The problem is with line endings, however, it blows up on Split NewLine I cannot repo it locally, so what I did for now is even when it blows up the rest of ouptuts will continue and succeed.