Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Siegfried Pammer
@siegfriedpammer
@ashmind May I ask you to open a PR for easier discussion? The most of the options should be fine, but, please be aware that an option like CanInlineVariables might be a problem for other transformations, because some of them rely on variables being inlined properly.
Andrey Shchekin
@ashmind
@siegfriedpammer Sure, I'll do that.
Christoph Wille
@christophwille
Also via this channel: if you are using ics.decompiler, please add your software to https://github.com/icsharpcode/ILSpy/wiki/Third-Party-Software-Using-ICS.Decompiler
Andrey Shchekin
@ashmind
Question: how does setting ObjectOrCollectionInitializers work in the latest ILSpy? I can't find any references to it:
https://github.com/icsharpcode/ILSpy/search?utf8=%E2%9C%93&q=ObjectOrCollectionInitializers&type=
Siegfried Pammer
@siegfriedpammer
see #1049 thank you for pointing this out. Are you fine with using a nuget from appveyor for now?
Andrey Shchekin
@ashmind
@siegfriedpammer btw I'm already doing "Ugly" tests f
(sorry sent too early) ...for ArrayInitializers=false — might be useful to follow same structure for ObjectOrCollectionInitializers.
Siegfried Pammer
@siegfriedpammer
if you have any tests that might be of interest to us, please consider opening a pull request
Andrey Shchekin
@ashmind
yes, still work in progress, I'll open once done
Siegfried Pammer
@siegfriedpammer
if you need an "officially" released nuget on nuget.org, please tell us, I will cherry-pick the required changes back to 3.0.x and then we'll eventually release the next update. But please be aware that we would like to keep the service releases down to a minimum
Andrey Shchekin
@ashmind
no problem, I'm using a my v2 fork through submodule anyways until I can contribute all my changes to v3
Christoph Wille
@christophwille
@ashmind we are currently finalizing our planning for 3.1 - is everything you need included as per your last pull request?
Christoph Wille
@christophwille
I'd also like to extend the "bug bash call" to gitter: https://gist.github.com/christophwille/cf88971bcc4a9cbe067fa27293ec02ed
Stijn Herreman
@stijnherreman
Apparently a number of releases have been done since version 2.4.0.1963, how come the 'Check for Updates' functionality still says "No update for ILSpy found." ?
Siegfried Pammer
@siegfriedpammer
I can only speculate, but I think it might be because we moved the update check from HTTP to HTTPS and the version you are using is unable to retrieve version information.
Captain Chaos
@screig
May I ask how one can export to file, with a csproj and subdirs (eg just like from the gui) once I have decompiled the code via the CSharpDecompiler. thanks
Christoph Wille
@christophwille
@screig if you want to decompile a whole assembly, take a look at that sample https://github.com/icsharpcode/ILSpy/blob/master/ICSharpCode.Decompiler.Console/Program.cs#L121
Captain Chaos
@screig
thanks very much, just what I was after
Marat Mukhamadiev
@maratoss
Hi! I did not find following options now:
Decompile anonymous methods/lambdas
Decompile anonymous types
Whe is it?
Siegfried Pammer
@siegfriedpammer
icsharpcode/ILSpy#1471 will be merged soon, then the settings should all be back!
Marat Mukhamadiev
@maratoss
Aha! Good thanks, now i am calm! :)
FreddyD-GH
@FreddyD-GH
Does ILSpy (or ICSharpCode.Decompiler) have an easy way to generate a list of all references to external assemblies (Types/Methods/Properties/etc.) from a given assembly? Perhaps there is sample code already somewhere that does this?
Jesse Talavera-Greenberg
@JesseTG
Is it possible to use ILSpy to get inter-class dependencies within a single assembly? My project is mostly compiled into one big assembly that I want to break into a bunch of smaller assemblies.
Claudiu Guiman
@clguimanMSFT

Hello! I might have a dumb question so please bear with me :)
Why is IDecompilerTypeSystem.FindType() expecting generic types to not include the argument list, just the arity (`1), but if I get the same type as an IType (let's say I got it from a return type of a method) the ReflectionName property has the argument list?.

For example:

decompiler.TypeSystem.FindType(new FullTypeName("System.Threading.Tasks.Task`1[[System.String]]")) // returns Unknown
decompiler.TypeSystem.FindType(new FullTypeName("System.Threading.Tasks.Task`1")) // works

IMethod myMethod = ...
Console.Write(myMethod.ReturnType.ReflectionName); //outputs "System.Threading.Tasks.Task`1[[System.String]]"

Shouldn't the FullTypeName ctor also include the arguments?

Siegfried Pammer
@siegfriedpammer
IDecompilerTypeSystem.FindType() only returns ITypeDefinition
you can make a generic type by using var taskOfT = decompiler.TypeSystem.FindType(KnownTypeCode.TaskOfT).GetDefinition(); var taskOfString = new ParameterizedType(taskOfT, new[] { decompiler.TypeSystem.FindType(KnownTypeCode.String) });
using the KnownTypeCode overload for all known types is faster than using the FullTypeName overload
Siegfried Pammer
@siegfriedpammer
The return type of a "specialized" generic method is a ParameterizedType, that's why the reflection name includes type arguments
Siegfried Pammer
@siegfriedpammer
@FreddyD-GH sorry, for taking so long to reply: Unfortunately, ILSpy does not currently offer such functionality.
@JesseTG ILSpy lets you analyze a single member/type, but not all dependencies in one single step.
Claudiu Guiman
@clguimanMSFT
@siegfriedpammer thanks for the explanation. So the short name format ("System.Threading.Tasks.Task`1") is only for well known generic types? If I have a user defined generic type the full type name will also include the argument list?
Siegfried Pammer
@siegfriedpammer
no, FullTypeName can be used for any fully-qualified type definition in the type system. However, if you are looking for "special types" like void, int, string, IEnumerable<T>, Nullable<T>, Task, Task<T>, Span<T>, Memory<T>, etc. (see https://github.com/icsharpcode/ILSpy/blob/master/ICSharpCode.Decompiler/TypeSystem/KnownTypeReference.cs#L26 for the full list)
Siegfried Pammer
@siegfriedpammer
typeSystem.FindType(KnownTypeCode.TaskOfT) should yield the same result as typeSystem.FindType(new FullTypeName("System.Threading.Tasks.Task1"))`, however the first one should be faster, because it directly uses the KnownTypeCache instead of having to parse a type-name and searching the whole compilation.
ThunderFrost0001
@ThunderFrost0001
Is it not possible to import this to Unity?
areller
@areller
Hi. I'm looking for a way to decompile an anonymous method (Action<T>) in .NET Core.
Basically, I have something like this
public void Add(Action<Cursor> action)
{
    var il = action.Method.GetMethodBody().GetILAsByteArray();
    var ast = decompiler.Decompile(il); // Is it possible?
}
Sorry for the newbie question but I couldn't find how to do it.
Daniel Grunwald
@dgrunwald
The IL bytes alone are not sufficient to decompile anything, as the decompiler also needs the metadata tables. (e.g. the IL bytecode itself only says "call method nr. 42", which means the method name and signature can be found in row 42 of the "methoddef" metadata table)
@areller The decompiler's type system (which reads from these tables) is based on System.Reflection.Metadata, so you can't use the decompiler with a normal System.Reflection assembly
next best thing you can do is to load the assembly again using System.Reflection.Metadata, and re-discover the method in question using its metadata-token
areller
@areller

@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?

areller
@areller
Okay, I found out that It has something to do with the version that I pass to UniversalAssemblyResolver. I will look into it
Chicken-Bones
@Chicken-Bones

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?

Chicken-Bones
@Chicken-Bones
@dgrunwald @siegfriedpammer any rules about pinging?
Daniel Grunwald
@dgrunwald
Hmm looks like it's really that simple. The other helper functions involved are shared with the code for compound assignments/preincrement, and that already supports floats.
Daniel Grunwald
@dgrunwald
There's also #947 which is a bit more complicated, i guess the current code only works for byte*/sbyte*.
Chicken-Bones
@Chicken-Bones
I'll PR it sometime this week, with some test cases.
Chicken-Bones
@Chicken-Bones
I'm really struggling to conceive of a piece of code requiring the fix in icsharpcode/ILSpy@6c0216b
There's no test case or issue number