Closed zspitz closed 4 years ago
For IL, this post describes options with GUIs, a couple commercial ones mentioned at the end: https://www.hanselman.com/blog/WhatsBetterThanILDasmILSpyAndDnSpyAreToolsToDecompileNETCode.aspx
Basics of getting started with IL decompilation: https://github.com/icsharpcode/ILSpy/wiki/Getting-Started-With-ICSharpCode.Decompiler
For Roslyn indexing, [without Visual Studio] you're limited to .NET Core projects with standalone Roslyn and nuget msbuild. Instead, I've had the best success with real-world .NET code by installing the Visual Studio extension development workload and a few other things, and then using the "C# Stand-Alone Code Analysis Tool" project template as described at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/get-started/syntax-analysis though the documentation landing page is https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/ and there's a lot of it. :)
You'll find the template here if you don't or can't run VS for whatever reason: https://github.com/dotnet/roslyn-sdk/blob/master/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/ProjectTemplates/CSharp/ConsoleApplication/Program.cs
For those who'd prefer to read code over documentation, there's the really quite excellent https://github.com/dotnet/roslyn-sdk/blob/master/samples/CSharp/APISamples/FAQ.cs which slowly increases in complexity. For CFG and data flow examples, there's https://github.com/dotnet/roslyn-sdk/blob/37e2a003dfd4308007792c06f3fdaafef909b377/samples/CSharp/APISamples/SymbolsAndSemantics.cs
The basics appear to be that you can use a SemanticModel as documented at https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.semanticmodel?view=roslyn-dotnet and the run through all the syntax in the solution's projects, using https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.modelextensions.getsymbolinfo?view=roslyn-dotnet#Microsoft_CodeAnalysis_ModelExtensions_GetSymbolInfo_Microsoft_CodeAnalysis_SemanticModel_Microsoft_CodeAnalysis_SyntaxNode_System_Threading_CancellationToken_ to get SymbolInfo which in turn has the symbol that was referred to by the syntax node, if any https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.symbolinfo?view=roslyn-dotnet
For F#, I'm not sure how up to date this is but it either serves as a useful SDK or some good examples on how to do equivalent calls with the F# compiler: https://github.com/fsprojects/Roslyn.FSharp
Thanks for putting all that information together! So it looks like we definitely need C# bindings for SourcetrailDB!
@LouisStAmour
For Roslyn indexing, you're limited to .NET Core projects with standalone Roslyn and nuget msbuild.
I don't follow -- why can't you use Roslyn against .NET Framework sources? And if it's because the newer versions of the compiler don't support .NET Framework, isn't it still possible to fall back to the older versions?
Ah I was referring specifically to the NuGet msbuild package. The fallback is to use locator code as in the sample and install Visual Studio for build tools, yes.
Added with merge of pull request #40.
Are there any plans to add bindings for .NET languages?
If I understand correctly, this could easily be done via SWIG, which can output C# as a target language. The resulting C# might then be compiled into a DLL together with any other dependencies and packaged as a NuGet package; the bindings would be available to any .NET developer.
This would open many possibilities: