Roslyn-based C# analyzer for analyzer-lsp and kantra. Uses CSharpCompilation and SemanticModel for full symbol resolution.
dotnet build src/CSharpProvider.csproj
dotnet run --project . -- --port 9876See ARCHITECTURE.md for a more thorough explanation.
-
Project loading (
Analysis/ProjectLoader.cs): Tries MSBuild workspace first (.sln/ SDK-style.csproj), falls back to ad-hoc compilation with NuGet package resolution. -
Package resolution (
Analysis/PackageResolver.cs): Downloads NuGet packages for the detected target framework. Supportspaket.lock,packages.config, andPackageReferenceformats. -
Symbol querying (
Analysis/SymbolQuery.cs): Walks the syntax tree with aCSharpSyntaxWalker, resolving symbols viaSemanticModel. Matches FQDNs against regex patterns.
- Imports:
usingdirectives - Type references: variable types, return types, parameters, casts,
typeof, generics, base classes - Member access: method calls, property/field access (explicit and implicit
this) - Object creation:
new T() - Attributes:
[Authorize], etc. - Value flow: arguments, return values, and assignments where the expression type matches
- Dynamic access:
ViewBag.Xand similar dynamic member chains - Inheritance-aware matching: querying
Controlleralso finds members accessed throughController, even if declared onControllerBase
And more!
See tests/README.md for the full test infrastructure.
# Using the build script
cd src
../scripts/build-container.sh
# Or manually with podman
podman build -f Dockerfile -t quay.io/konveyor/c-sharp-roslyn-provider:latest .# Using the test script (interactive)
../scripts/test-container.sh
# Or manually
podman run --rm -p 14651:14651 quay.io/konveyor/c-sharp-roslyn-provider:latest
# Test with a project volume
podman run --rm -p 14651:14651 \
-v /path/to/your/project:/projects:Z \
quay.io/konveyor/c-sharp-roslyn-provider:latestThe container:
- Runs as user 1001 (non-root)
- Has group 0 (root group) permissions for OpenShift compatibility
- Requires
:Zflag on volume mounts for SELinux systems - Includes the .NET SDK for runtime
dotnet restoreon analyzed projects
See INTEGRATION.md for complete integration guide including:
- Provider configuration examples
- Testing with analyzer-lsp/kantra
- Troubleshooting tips
- Advanced configuration options
Patterns are regex, matched against the fully-qualified symbol name:
# Exact type
grpcurl -plaintext -d '{"cap":"referenced","id":"1","conditionInfo":"{\"referenced\":{\"pattern\":\"^System\\\\.Web\\\\.Mvc\\\\.Controller$\"}}"}' \
localhost:9876 provider.ProviderService/Evaluate
# Wildcard (type + all members)
grpcurl -plaintext -d '{"cap":"referenced","id":"1","conditionInfo":"{\"referenced\":{\"pattern\":\"^System\\\\.Web\\\\.Mvc\\\\.Controller(\\\\..*)$\"}}"}' \
localhost:9876 provider.ProviderService/Evaluate