Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
George Schizas
@gschizas
Never mind, I found it (at %APPDATA%\ICSharpCode\ILSpy.xml)
Christoph Wille
@christophwille
Release v3.0.1 is out that fixes the issue for good
Sam Harwell
@sharwell
I am starting testing on the Visual Studio integration. I am planning to file bugs I find on dotnet/roslyn. Some of these may be resolved as External linking to the ILSpy repository.
Christoph Wille
@christophwille
Anyone familiar with windows application packaging projects? (wap) I tried to generate one for ILSpy, and it keeps complaining "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1601,5): error : Project '..\ILSpy\ILSpy.csproj' targets 'net46'. It cannot be referenced by a project that targets '.NETCore,Version=v5.0'." - but I can't find anywhere the spec for wap that says I can't package a net46 app
Christoph Wille
@christophwille
Andrey Shchekin
@ashmind

Hi all, question. I want to move SharpLab to the latest version of ILSpy (from the customized v2 it's using at the moment).
To do that, I need to contribute my customizations into the project.

I want to check if you disagree with any of those before I start working on individual PRs.

  1. ArrayInitializers=false -- an option to de-prettify array initializers:
    https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4AEAMACFBGA3AWACgUBmLAJgwGEMBvIjRrMlAFgwFkAKASjoaaCAbhAQZRCCAE8MAXgwA7OAHcA2gF062ADQZyukgF8ChQYaKGgA===

  2. OperatorOverloading=false -- an option to de-prettify custom operator calls:
    https://sharplab.io/#v2:CYLg1APgAgzABFATHAwnA3gWAFBzw+ADTgFkAKYgDwEoMd8GEB2OSuMVgbnvwF8d+2HLATJiWXPhFQAjADY4xAPYAHAKYAnAIYAXJRo4U4AGzUAzHQBpFcDQEsA5gAsdtALwA+OADsArseNOBgEgA===

  3. CanInlineVariables=false -- an option to avoid inlining variables:
    https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+ABADAAmwEYBuAWAChLsBmQgJnwGF9KBvS/Lwu7AFnwBZABQBLAHYx8EBAHMArmDiSAlKwrd8HDZu4A3GfnFwA7gDUZoiMAA2cAGIB7BAEE5i5VIC8090snkOrqERACcwsbmltZ2Tq5+niqBmgC+lClAA===

  4. LiftedOperators=false -- an option to de-prettify operator lifting (e.g. for nullables):
    https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4AEAMACFBGA3AWACgUBmLAJgwGEMBvIjRrM4Ae1YBsMBZACgBEI8ACoBLMHAD8GACYBKOgybKUAdlkYAfBkEjxcAHQA5VgHcChZQF8iVoA=

  5. AnonymousTypes=false -- an option to de-prettify anonymous types
    https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4AEAMACFBGA3AWACgUBmLAJgwGEMBvIjRrMge2ACs4BjGDAWQAUASjoMm4lAHYMAOzgB3OhgAeGALwZsGAL4FC47UW1A===

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