@dgrunwald Thank you. I'm trying to do it, when I initialise an instance of CSharpCompiler that points to my current assembly,
var file = Assembly.GetEntryAssembly().Location;
var decompiler = new CSharpDecompiler(file, new UniversalAssemblyResolver(file, true, ".NETCOREAPP"), new DecompilerSettings());
I get the exception
An unhandled exception of type 'ICSharpCode.Decompiler.Metadata.AssemblyResolutionException' occurred in ICSharpCode.Decompiler.dll: 'Failed to resolve assembly: 'ICSharpCode.Decompiler, Version=4.0.0.4521, Culture=neutral, PublicKeyToken=d4bfe873e7598c49'
Reading the source file of UniversalAssemblyResolver
(specifically, method ResolveInternal
), I see that it doesn't search in the NuGet directory.
When I do dotnet publish
and run my application, it works (the instantiation of CSharpDecompiler
), because it includes the ICSharpCode.Decompiler
dll in the publish
folder.
Is there a way to make it work in development, by looking in NuGet packages?
I've 'fixed' #1764 by changing _.MatchLdcI(1)
to _.MatchLdcI(1) || _.MatchLdcF4(1) || _.MatchLdcF8(1)
in 3 places.
Test cases are passing fine (except for Cecil which has always had path issues). Am I overlooking something obvious or is this a simple fix?
byte*
/sbyte*
.
paraphrasing the ILAst of the obfuscated code, before "Duplicate block exit" + "Extract else block" the control flow looks like this:
if (...) {
call Something()
} else {
while (true) {
if (...)
return;
}
}
return;
and after it looks like this:
if (...) {
call Something()
return;
}
while (true) {
if (...)
return;
}
return;
public void Issue1524V3(string str)
{
if (!string.IsNullOrEmpty(str))
{
return;
}
if (int.TryParse(str, out int id))
{
Console.WriteLine(new Func<int>(() => id));
}
}
public void Issue1524V4(string str)
{
if (string.IsNullOrEmpty(str))
{
if (int.TryParse(str, out int id))
{
Console.WriteLine(new Func<int>(() => id));
}
}
}
stloc V_1(newobj <>c__DisplayClass10_0..ctor())
is before the first if
TransformDisplayClassUsage
removes the display class init and store, but it runs after ConditionDetection
ConditionDetection
(or a part of it) againAssemblyResolver.AddSearchDirectory
?