Decompile multiple projects under single solution and use ProjectReference's
Steps to reproduce
- Use either a) the ILSpy WPF desktop app, or b) ILSpyCmd w/ 8.0 prev 1 (CLI requires #2364 to support multiple assemblies)
- Make sure you have at least two DLL's where one of them has a dependency on the other (i.e.
First.dlldepends onSecond.dll) - Using CLI in terminal, execute command:
ilspycmd First.dll Second.dll -p -o TEMP - Open the newly generated solution in VS from the
TEMPdirectory - Notice in project
Firsthow the reference toSecondis a DLL reference, NOT a project reference.
Expectation
-
Firstshould seeSecondas a project reference
Details
The main culprit of this issue is in ICSharpCode.Decompiler.Solution.SolutionCreator with the use of ProjectFileNamespace which is coded for how this would work with the old project file structure.
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.Decompiler/Solution/SolutionCreator.cs#L32
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.Decompiler/Solution/SolutionCreator.cs#L163-L165
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.Decompiler/Solution/SolutionCreator.cs#L176-L193
Since the new SDK style is used by default (from CLI or UI), our only option is to manually correct this after decompilation, which is a ton of work. From some quick testing, simply using string.Empty in replace of the XML namespace works just fine for the expected behavior to work. However, the correct solution would probably involve finding a way to pull in ICSharpCode.Decompiler.DecompilerSettings into SolutionCreator somehow so that we can reference the UseSdkStyleProjectFormat boolean.
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.Decompiler/DecompilerSettings.cs#L1868
The only public method of that class is one of the WriteSolutionFile overloads...
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.Decompiler/Solution/SolutionCreator.cs#L43
...which seems to be referenced in two different areas: ICSharpCode.ILSpyCmd.ILSpyCmdProgram.OnExecute & ICSharpCode.ILSpy.SolutionWriter.CreateSolution.
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs#L137
https://github.com/icsharpcode/ILSpy/blob/94982b5368c46f58f0af2bdbd3ba300574e0f8e4/ILSpy/SolutionWriter.cs#L124
Workaround
- I don't see any workarounds at the momment, so I think this will ultimately require a code fix.