Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constant propagation library for .NET

Whether any open source .NET (C#/F#) library for abstract static analysis exists? Currently I'm interested in constant propagation algorithm.

It should be abstract (language independed) and open source because I want to use it as base for custom algorithm implementation.

Thanks.

like image 629
gsv Avatar asked Oct 22 '22 02:10

gsv


1 Answers

The library Mono.Cecil is almost what you want. It is open-source, language abstracted and as a bonus it is super polished, fast and stable.

But it is not exactly what you want because Cecil doesn't analyze C#, VB.NET or F# source code, but it analyzes assemblies files (dll and exe) and IL code contained in assemblies. For many static analysis areas it'd be enough, but for constant propagation (I guess you mean literal constant like const string STR = "MyString"; or const int INT = 12345;) there is a loss of information at compile time since the constant value is hardcoded in place of the constant usage. Cecil is also not suited for Abstract Syntax Tree analysis.

You can also look at Microsoft Roslyn. Contrary to Cecil, Roslyn parses C# and VB.NET source code, is very well suited for Abstract Syntax Tree analysis, but it is not open source, doesn't support F#, and is certainly subject to change until it will become RTM, I'd say next year with Visual Studio 2014, (but this is just my guess).

like image 99
Patrick from NDepend team Avatar answered Oct 23 '22 17:10

Patrick from NDepend team