Roslinq

Roslinq is a Roslyn based component that enables queries over C# source code.

Features

Roslinq currently supports:

  • MSBuild based workspaces (.sln, .csproj)
  • class queries
  • method queries

Examples

Private static methods taking int parameter input:

var codeQuery = new ProjectQuery(@"path\to\RoslinqTestTarget.csproj");
var result = codeQuery
    .Classes
    .Methods
    .WithModifier(MethodModifier.Static)
    .WithModifier(MethodModifier.Private)
    .WithParameterType<int>()
    .Execute();

HTTP POST handlers in MVC Controllers:

var codeQuery = new ProjectQuery(@"path\to\RoslinqTestTarget.csproj");
var postControllerActions = codeQuery
    .Classes.InheritingFrom<Controller>()
    .Methods.WithAttribute<HttpPostAttribute>()
    .Execute();

Nuget package

Install-Package Roslinq -pre