Documentation
¶
Overview ¶
Package csprovider implements the C# language provider for SuitCode.
The import graph is derived exclusively from <ProjectReference> elements in .csproj files — the authoritative, compiler-verified project dependency declaration. No heuristics such as `using` directive parsing are used. Avalonia .axaml ↔ .axaml.cs code-behind pairs are linked as direct peers within the same project.
csharp-ls (the Roslyn-based LSP server) is REQUIRED for FileImporters. If it is not installed, FileImporters returns a "tool_not_available" Limitation and empty data — it does NOT fall back to the coarse .csproj project-level graph, which would flood callers with irrelevant files. Run "suitcode installdeps" to install csharp-ls via "dotnet tool install --global csharp-ls".
Index ¶
- type CSHarpLanguageProvider
- func (p *CSHarpLanguageProvider) Capabilities() provider.ProviderCapabilities
- func (p *CSHarpLanguageProvider) Close() error
- func (p *CSHarpLanguageProvider) DaemonInfo() provider.DaemonInfo
- func (p *CSHarpLanguageProvider) FileImporters(ctx context.Context, filePath string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) FileImports(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) FilePeers(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) FileTests(_ context.Context, _ string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) GetImports(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) GetPackageRefs(filePath string) []PackageRef
- func (p *CSHarpLanguageProvider) GetSymbols(ctx context.Context, filePath string) (*provider.ProviderResult[[]string], error)
- func (p *CSHarpLanguageProvider) Ready() bool
- func (p *CSHarpLanguageProvider) WaitForDaemons(_ context.Context) bool
- type PackageRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSHarpLanguageProvider ¶
type CSHarpLanguageProvider struct {
// contains filtered or unexported fields
}
CSHarpLanguageProvider implements provider.ImportGraphProvider for C# repositories, including Avalonia UI projects.
CSHarpLanguageProvider is safe for concurrent use after construction.
func NewCSHarpLanguageProvider ¶
func NewCSHarpLanguageProvider(ctx context.Context, repoPath string) (*CSHarpLanguageProvider, error)
NewCSHarpLanguageProvider creates a CSHarpLanguageProvider for the given repository root. The import graph (Phase 1) is built synchronously before returning. An error is returned only when repoPath is not a valid directory. All other failures (no .csproj files, parse errors) are captured as Limitations and do not prevent the provider from being returned.
func (*CSHarpLanguageProvider) Capabilities ¶
func (p *CSHarpLanguageProvider) Capabilities() provider.ProviderCapabilities
Capabilities returns the static metadata for this provider.
func (*CSHarpLanguageProvider) Close ¶
func (p *CSHarpLanguageProvider) Close() error
Close shuts down the LSP client (if running) and releases resources. Safe to call multiple times.
func (*CSHarpLanguageProvider) DaemonInfo ¶
func (p *CSHarpLanguageProvider) DaemonInfo() provider.DaemonInfo
DaemonInfo returns information about the csharp-ls subprocess managed by this provider. Returns a not-running DaemonInfo when csharp-ls is not available.
func (*CSHarpLanguageProvider) FileImporters ¶
func (p *CSHarpLanguageProvider) FileImporters(ctx context.Context, filePath string) (*provider.ProviderResult[[]string], error)
FileImporters returns the absolute paths of files that reference exported types defined in filePath.
Requires csharp-ls: uses textDocument/references for file-level precision — only files that actually reference an exported type in filePath are returned.
Fail-fast: if csharp-ls is not installed, returns empty data and a "tool_not_available" Limitation. No .csproj project-level fallback is used — that fallback returns every file in any referencing project (including unrelated files like App.axaml, Program.cs, Themes/) and produces noisy, misleading context. Run "suitcode installdeps" to install csharp-ls.
func (*CSHarpLanguageProvider) FileImports ¶
func (p *CSHarpLanguageProvider) FileImports(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
FileImports returns the absolute paths of files in projects that filePath's project directly references. Avalonia partner is included when present.
func (*CSHarpLanguageProvider) FilePeers ¶
func (p *CSHarpLanguageProvider) FilePeers(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
FilePeers returns the absolute paths of all other source files in the same .csproj project as filePath. These files compile into the same assembly — a manifest fact, not a filesystem heuristic.
func (*CSHarpLanguageProvider) FileTests ¶
func (p *CSHarpLanguageProvider) FileTests(_ context.Context, _ string) (*provider.ProviderResult[[]string], error)
FileTests returns an empty result for C# — test projects are separate .csproj assemblies whose relationship to the code project is expressed via <ProjectReference>. Use FileImporters to find projects that reference this project, then filter by test framework package presence.
func (*CSHarpLanguageProvider) GetImports ¶
func (p *CSHarpLanguageProvider) GetImports(_ context.Context, filePath string) (*provider.ProviderResult[[]string], error)
GetImports returns the absolute paths of files in projects that filePath's project directly references. This is the closest C# analogue to "imports". The Avalonia partner (.axaml ↔ .axaml.cs) is included when present.
func (*CSHarpLanguageProvider) GetPackageRefs ¶
func (p *CSHarpLanguageProvider) GetPackageRefs(filePath string) []PackageRef
GetPackageRefs returns the NuGet <PackageReference> items declared in the .csproj that contains filePath. Returns nil when the provider is not ready or filePath is not part of any tracked C# project.
func (*CSHarpLanguageProvider) GetSymbols ¶
func (p *CSHarpLanguageProvider) GetSymbols(ctx context.Context, filePath string) (*provider.ProviderResult[[]string], error)
GetSymbols returns the symbol names defined in the file at filePath using csharp-ls.
Requires csharp-ls: uses textDocument/documentSymbol for file-level symbol extraction. Fail-fast: if csharp-ls is not installed, returns empty data and a "tool_not_available" Limitation — does NOT silently return nothing, so callers know the gap.
func (*CSHarpLanguageProvider) Ready ¶
func (p *CSHarpLanguageProvider) Ready() bool
Ready reports whether the Phase 1 import graph was built with at least one C# source file found. Returns false for repos with no .csproj files.
func (*CSHarpLanguageProvider) WaitForDaemons ¶
func (p *CSHarpLanguageProvider) WaitForDaemons(_ context.Context) bool
WaitForDaemons implements provider.DaemonWaiter. csharp-ls is initialised synchronously in the constructor (Initialize blocks until the LSP handshake completes), so this method returns immediately. It exists so the dispatcher can treat all providers uniformly via the DaemonWaiter interface, and so that future async startup can be added here without changing call-sites.
type PackageRef ¶
type PackageRef struct {
Name string // e.g. "Avalonia.Controls.ItemsRepeater"
Version string // e.g. "12.0.0" — empty when not declared
}
PackageRef is one <PackageReference> entry from a .csproj file.