Hi,
I had some code that I was testing the decompiler with, the code caused the code to fail and I narrowed to down to the following.
JustDecompile Version: 2011.1.719.9
Module
Module1
Sub
Main()
End
Sub
Public
Function
Test(value
As
Object
)
As
String
Try
Return
value
Catch
ex
As
Exception
Throw
New
InvalidCastException(value)
End
Try
End
Function
End
Module
When decompiling the Test function the following error is raised
Current member / type: System.
String
JustDecompileVbException.Module1::Test(System.
Object
)
File path: D:\Source\NGTests\Framework 4.0\JustDecompileVbException\bin\Debug\JustDecompileVbException.exe
Stack empty.
at ..()
at ..(MethodReference method)
at ..OnCall(Instruction instruction)
at ..(Instruction instruction, IInstructionVisitor visitor)
at Telerik.JustDecompiler.Decompiler.StatementDecompiler.(Instruction instruction)
at Telerik.JustDecompiler.Decompiler.StatementDecompiler.(InstructionBlock block)
at Telerik.JustDecompiler.Decompiler.StatementDecompiler.(InstructionBlock block)
at Telerik.JustDecompiler.Decompiler.StatementDecompiler.()
at Telerik.JustDecompiler.Decompiler.StatementDecompiler.Process(DecompilationContext context, BlockStatement body)
at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language)
at Telerik.JustDecompiler.Decompiler.Extensions.(DecompilationPipeline pipeline, ILanguage language, MethodBody body)
at Telerik.JustDecompiler.Languages.BaseImperativeLanguageWriter.Write(MethodDefinition method)
at Telerik.JustDecompiler.Languages.BaseLanguageWriter.Write(IMemberDefinition member,
Boolean
showCompilerGeneratedMembers)
at JustDecompile.CodeViewer.CodeWriter.Write() in c:\B\Behemoth\JustDecompile Production Build\Sources\UI\JustDecompile.CodeViewer\Writers\CodeWriter.cs:line 34
at JustDecompile.CodeViewer.ViewModels.CodeViewerViewModel.(AssemblyMemberNode member, CancellationToken cancellationToken) in c:\B\Behemoth\JustDecompile Production Build\Sources\UI\JustDecompile.CodeViewer\ViewModels\CodeViewerViewModel.cs:line 116
The problem occurs when decompiling to C# or VB.NET, the IL is fine however, here is the IL
.method
public
static
string
Test (
object
'value'
) cil managed
{
.locals init (
[0]
string
Test,
[1]
class
[mscorlib]System.Exception ex
)
IL_0000: nop
IL_0001: nop
.
try
{
IL_0002: ldarg.0
IL_0003: call
string
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.Conversions::ToString(
object
)
IL_0008: stloc.0
IL_0009: leave.s IL_0029
IL_000b: leave.s IL_0028
}
catch
[mscorlib]System.Exception
{
IL_000d: dup
IL_000e: call
void
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(
class
[mscorlib]System.Exception)
IL_0013: stloc.1
IL_0014: nop
IL_0015: ldarg.0
IL_0016: call
string
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.Conversions::ToString(
object
)
IL_001b: newobj instance
void
[mscorlib]System.InvalidCastException::.ctor(
string
)
IL_0020:
throw
IL_0021: call
void
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_0026: leave.s IL_0028
}
IL_0028: nop
IL_0029: ldloc.0
IL_002a: ret
}