ctx/internal/plugins/csharp/csharp.go
Ricardo Carneiro 15dc1b6b2f feat(csharp): implement 'outline' command for single-file structural summary
Adds OutlineHandler.cs to the Roslyn helper using CSharpSyntaxTree.ParseText
and manual syntax tree traversal (no solution load required). Extracts
namespaces, types, method/property/field/event signatures and line numbers
without method bodies. Handles file-scoped namespaces, generics, records,
nested types, partial classes, top-level statements, and [Obsolete] markers.

Adds Microsoft.CodeAnalysis.CSharp 4.13.0 as the sole new NuGet dependency
(pure parser, no MSBuild coupling). Go side adds Outline() client method,
OutlineResult/Type/Member types, outline.go command, and WriteOutline formatter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 19:41:47 -03:00

33 lines
952 B
Go

// Package csharp implements the ctx csharp plugin — .NET solution analysis via Roslyn helper.
package csharp
import (
"github.com/ricarneiro/ctx/internal/core"
"github.com/spf13/cobra"
)
func init() {
core.Register(&csharpPlugin{})
}
type csharpPlugin struct{}
func (c *csharpPlugin) Name() string { return "csharp" }
func (c *csharpPlugin) Version() string { return "0.1.0" }
func (c *csharpPlugin) ShortDescription() string { return "C# / .NET project analysis via Roslyn" }
func (c *csharpPlugin) Command(ctx *core.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "csharp",
Short: c.ShortDescription(),
Long: `Analyze C# / .NET projects and emit compact markdown summaries
optimized for Claude Code consumption.
Requires the Roslyn helper (ctx-roslyn-helper) to be built.
See 'ctx csharp project --help' for details.`,
}
cmd.AddCommand(projectCmd(ctx))
cmd.AddCommand(outlineCmd(ctx))
return cmd
}