Skip to content

Commit 68f4a65

Browse files
ATrefzerclaude
andauthored
Claude/ux improvements quickstart (#71)
* Add Quick Start guide and movement parent indicator README: - Add Key Concepts section explaining Model vs. Canvas vs. Tree View - Add Quick Start with two main workflows: cycle search and code exploration TreeControl: - Show a yellow indicator bar when a movement parent is set, displaying its name with a clear button; bar is hidden when no target is active TreeViewModel: - Add HasMovementTarget and MovementTargetName computed properties - Add ClearMovementTargetCommand - Notify UI after SetMovementTarget, MoveCodeElement, and ClearMovementTarget RefactoringService: - Add ClearMovementTarget() method Strings.resx: - Add MovementParent_Label and MovementParent_Clear_Tooltip https://claude.ai/code/session_011QMVhyH8xEWBZqhHMqk4yk * Restructure README: rename Key Concepts to Terminology, fix section order - Rename "Key Concepts" to "Terminology" with first-person voice - Add Quick Start guide with cycles-first ordering (primary use case) - Move "Find and visualize cycles" directly after Quick Start - Place "Simulated refactoring" after cycles (thematically linked) - Restore "Exploring your codebase" section after Simulated refactoring - Move "Validate architectural rules" toward end as a nice-to-have feature https://claude.ai/code/session_011QMVhyH8xEWBZqhHMqk4yk * Update README.md * Cleanup UI * Margins --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 07de4b2 commit 68f4a65

File tree

6 files changed

+177
-57
lines changed

6 files changed

+177
-57
lines changed

CSharpCodeAnalyst/Features/Refactoring/RefactoringService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ public void MoveCodeElements(HashSet<string> sourceIds)
315315
return _target;
316316
}
317317

318+
public void ClearMovementTarget()
319+
{
320+
_target = null;
321+
}
322+
318323
public void DeleteRelationships(List<Relationship> relationships)
319324
{
320325
if (_graph is null || !relationships.Any())

CSharpCodeAnalyst/Features/Tree/TreeControl.xaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</UserControl.Resources>
2525
<Grid>
2626
<Grid.RowDefinitions>
27+
<RowDefinition Height="Auto" />
2728
<RowDefinition Height="Auto" />
2829
<RowDefinition Height="*" />
2930
</Grid.RowDefinitions>
@@ -58,7 +59,32 @@
5859
</Grid>
5960

6061
</DockPanel>
61-
<TreeView Grid.Row="1"
62+
<!-- Movement parent indicator -->
63+
<Border Grid.Row="1"
64+
Background="#FFF3CD"
65+
BorderBrush="#FFCA2C"
66+
BorderThickness="1,1,1,1"
67+
Padding="3 3 0 3"
68+
Margin="5 0 5 0"
69+
Visibility="{Binding HasMovementTarget, Converter={StaticResource BooleanToVisibilityConverter}}">
70+
<DockPanel>
71+
<Button DockPanel.Dock="Right"
72+
Command="{Binding ClearMovementTargetCommand}"
73+
ToolTip="{x:Static resources:Strings.MovementParent_Clear_Tooltip}"
74+
Width="22" Height="22"
75+
Padding="0"
76+
Background="Transparent"
77+
Margin="4,0,0,0">
78+
<Image Source="/Resources/clear_32.png" />
79+
</Button>
80+
<TextBlock VerticalAlignment="Center" FontSize="11" TextTrimming="CharacterEllipsis">
81+
<Run Text="{x:Static resources:Strings.MovementParent_Label}" FontWeight="Bold" />
82+
<Run Text="{Binding MovementTargetName, Mode=OneWay}" />
83+
</TextBlock>
84+
</DockPanel>
85+
</Border>
86+
87+
<TreeView Grid.Row="2"
6288
x:Name="CodeTree"
6389
ContextMenuOpening="TreeView_ContextMenuOpening"
6490
ItemsSource="{Binding TreeItems}"

CSharpCodeAnalyst/Features/Tree/TreeViewModel.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public TreeViewModel(MessageBus messaging, RefactoringService refactoringService
4242

4343
SetMovementTargetCommand = new WpfCommand<TreeItemViewModel>(RefactoringSetMovementTarget, RefactoringCanSetMovementTarget);
4444
MoveCommand = new WpfCommand<TreeItemViewModel>(RefactoringMoveCodeElement, RefactoringCanMoveCodeElement);
45+
ClearMovementTargetCommand = new WpfCommand(ClearMovementTarget);
4546
SelectedItemChangedCommand = new WpfCommand<TreeItemViewModel>(OnSelectedItemChanged);
4647

4748
_treeItems = [];
@@ -82,6 +83,10 @@ public string SearchText
8283

8384
public ICommand SetMovementTargetCommand { get; private set; }
8485
public ICommand MoveCommand { get; private set; }
86+
public ICommand ClearMovementTargetCommand { get; private set; }
87+
88+
public bool HasMovementTarget => _refactoringService.GetMovementTarget() != null;
89+
public string MovementTargetName => _refactoringService.GetMovementTarget()?.Name ?? string.Empty;
8590

8691
public ICommand SelectedItemChangedCommand { get; }
8792

@@ -110,6 +115,7 @@ private void RefactoringMoveCodeElement(TreeItemViewModel? tvm)
110115
}
111116

112117
_refactoringService.MoveCodeElements([id]);
118+
NotifyMovementTargetChanged();
113119
}
114120

115121
private bool RefactoringCanSetMovementTarget(TreeItemViewModel tvm)
@@ -120,6 +126,19 @@ private bool RefactoringCanSetMovementTarget(TreeItemViewModel tvm)
120126
private void RefactoringSetMovementTarget(TreeItemViewModel tvm)
121127
{
122128
_refactoringService.SetMovementTarget(tvm.CodeElement?.Id);
129+
NotifyMovementTargetChanged();
130+
}
131+
132+
private void ClearMovementTarget()
133+
{
134+
_refactoringService.ClearMovementTarget();
135+
NotifyMovementTargetChanged();
136+
}
137+
138+
private void NotifyMovementTargetChanged()
139+
{
140+
OnPropertyChanged(nameof(HasMovementTarget));
141+
OnPropertyChanged(nameof(MovementTargetName));
123142
}
124143

125144
private static void OnCopyToClipboard(TreeItemViewModel vm)

CSharpCodeAnalyst/Resources/Strings.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CSharpCodeAnalyst/Resources/Strings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,12 @@ Search with resharper style = Use at least one uppercase character in a search t
851851

852852
<data name="Refactoring_SetAsMovementParent" xml:space="preserve">
853853
<value>_Set as movement parent</value>
854+
</data>
855+
<data name="MovementParent_Label" xml:space="preserve">
856+
<value>Movement parent: </value>
857+
</data>
858+
<data name="MovementParent_Clear_Tooltip" xml:space="preserve">
859+
<value>Clear movement parent</value>
854860
</data>
855861
<data name="ArchitectureRules_Info" xml:space="preserve">
856862
<value>Three rules are supported:

README.md

Lines changed: 102 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,69 @@
11
# C# Code Analyst
22

3+
[TOC]
4+
35
This application helps you to explore, understand, and maintain C# code.
46

5-
Here is a [presentation on YouTube](https://www.youtube.com/watch?v=o_r1CdQy0tY) on using the application to analyze cyclic dependencies.
7+
Here is a [YouTube presentation](https://www.youtube.com/watch?v=o_r1CdQy0tY) on using the application to analyze cyclic dependencies.
68

79
**Note:** You must install MSBuild on your computer for the application to function correctly.
810

9-
## Exploring your codebase
11+
## Terminology
1012

11-
While this application was written to analyze cyclic code structures, it also offers functions to explore and understand the source code.
13+
I use the following terms throughout this documentation:
1214

13-
### General
15+
**Model** — The complete code graph built from your imported C# solution. It contains all assemblies, namespaces, classes, methods, and their relationships.
1416

15-
![image-20240731123233438](Documentation/Images/code-explorer.png)
17+
**Code Explorer (Canvas)** — Interactive working area. Pick elements from the model and add them here to build a focused view. Think of it as a whiteboard where you can place only what you need right now.
1618

17-
- Import a C# solution (*.sln).
19+
**Tree View** — A hierarchical browser for the model. Use it to find individual elements and add them to the canvas.
1820

19-
- Use the **Tree View** tab to add a single code element to the canvas.
21+
## Quick Start
2022

21-
- Use the **Advanced Search** tab to search for code elements via more complex expressions. From the search result, you can add multiple code elements at once to the canvas.
23+
All workflows start the same way: **import your C# solution file** via
24+
*Home → Import → Import Visual Studio solution*.
2225

23-
- Explore the relationships between code elements using the context menu. For instance, you can track all incoming method calls or expand the inheritance tree.
26+
Here is what you can do with this app:
2427

25-
- To perform operations on multiple selected elements, use the tool buttons in the Code Explorer.
28+
### Find and break Dependency Cycles
2629

27-
- Note: You can export graphs to DGML format for further analysis in Visual Studio. Also, PlantUML class diagrams are supported.
30+
The cycle search always runs on the complete model.
2831

32+
1. Click **Cycles** in the ribbon
33+
2. The *Cycle Groups* tab lists all detected cycles with the involved elements
34+
3. **Right-click** a cycle group → *Show in Code Explorer* to visualize it as a graph
35+
4. Optionally, click **AI Advisor** to get ideas on how to break the cycle
2936

30-
### Examples
37+
> **Where to start?** Cycles at the **namespace level** have the highest impact.
3138
32-
Here are some general examples of how to use the application to explore a code base.
39+
See [Find and Break Dependency Cycles](#find-and-break-dependency-cycles-1) for details.
3340

34-
- [Essential concepts](Documentation/example-general-concepts.md)
35-
- [Find the call origins of a method](Documentation/example-find-call-origin.md)
36-
- [Understand how you could split a large class](Documentation/example-partition-class.md)
41+
### Explore your Codebase
3742

38-
### Performance Tips
43+
1. In the **Tree View** (left panel), find a code element and right-click →
44+
*Add to Code Explorer* — the element appears on the canvas
45+
2. **Right-click** the element on the canvas to explore relationships, for example:
46+
- *Find incoming calls* — who calls this method?
47+
- *Find inheritance tree* — what does this class extend?
48+
3. Keep following relationships that interest you — the graph grows step by step
3949

40-
When the graph contains more than ~200 code elements, performance slows down. However, viewing so many elements at once is not helpful. You can collapse and expand container elements by double-clicking them to minimize the number of visible elements. When using the Advanced Search to add multiple code elements, consider adding them in a collapsed state to maintain focus and start with a smaller, faster graph.
50+
See [Explore Your Codebase](#export-your-graph-1) for details, including Advanced Search and performance tips.
51+
52+
### Export your graph
4153

54+
Once you have a graph you want to share, export it for example as a **PlantUML class diagram** or
55+
**DGML** file. See [Document Your Findings](#document-your-findings-1).
4256

43-
## Find and visualize cycles in your codebase
57+
### Validate architectural rules
4458

45-
**Note: This function finds strongly connected components in the code graph, not the elementary cycles. **
59+
Define DENY, RESTRICT, or ISOLATE rules and check them against your codebase.
60+
See [Validate Architectural Rules](#validate-architectural-rules-1).
4661

62+
---
4763

64+
## Find and Break Dependency Cycles
65+
66+
**Note:** This function finds strongly connected components in the code graph, not the elementary cycles.
4867

4968
![](Documentation/Images/cycle-summary.png)
5069

@@ -54,7 +73,7 @@ Use the context menu to copy the related code elements to the explorer graph for
5473

5574
![](Documentation/Images/cycle-graph.png)
5675

57-
### Why Look for Cycles?
76+
### Why look for cycles?
5877

5978
More than 40 years ago, in his often-cited paper ["Designing software for ease of extension and contraction"](https://courses.cs.washington.edu/courses/cse503/08wi/parnas-1979.pdf) David Parnas suggested organizing software hierarchically, keeping the modules "loop-free." Similarly, Robert C. Martin's Acyclic Dependency Principle pushes in the same direction.
6079

@@ -85,13 +104,13 @@ Once you have loaded a cycle group into the Code Explorer, the **AI Advisor** bu
85104

86105
To use this feature, open **Settings** and enter your API endpoint and key. The tool supports any OpenAI-compatible endpoint, including local models (e.g. Ollama) and Anthropic's API.
87106

88-
> **Use with care.** The AI suggestions are generated without any knowledge of your actual business domain, team conventions, or broader system constraints. They may be technically incorrect, impractical, or simply not applicable to your situation.
107+
> **Use with care.** The AI suggestions are generated without any knowledge of your actual business domain, team conventions, or broader system constraints. They may be technically incorrect, impractical, or simply not applicable to your situation.
89108
90-
That said, the feature can be genuinely useful for getting a first set of ideas when you are staring at a complex cycle and don't know where to begin. The AI often recognises structural patterns — such as hidden abstractions, circular service dependencies, or missing interfaces — that are worth considering. The advice can be saved as a Markdown file for later reference.
109+
That said, the feature can be genuinely useful for getting a first set of ideas when you are staring at a complex cycle and don't know where to begin. The AI often recognizes structural patterns — such as hidden abstractions, circular service dependencies, or missing interfaces — that are worth considering. The advice can be saved as a Markdown file for later reference.
91110

92111
![](Documentation/Images/ai-advise.png)
93112

94-
## Simulated refactoring
113+
### Simulated Refactoring
95114

96115
The refactoring simulation feature is basic but useful. It helps you to explore how changes to the code structure affect cyclic dependencies without modifying the actual source code. A typical scenario involves identifying a large cyclic cluster, making adjustments in the source code, and re-importing the solution - only to find the cycle still unresolved. This process can be repetitive and time-consuming.
97116

@@ -116,16 +135,59 @@ Context Menu Options:
116135
- **Set as movement parent** – Sets the current element as the parent for subsequent move operations.
117136
- **Move** – Once a movement parent is set, this option moves the selected element and all its children to the chosen parent.
118137

119-
Additionally in the Code Explorer
138+
Additionally in the Code Explorer:
120139

121140
- **Delete edge from model** – Deletes the relationships between two code elements. If the edge is bundled, multiple relationships get deleted.
122141

123-
## Validate your architectural rules
142+
---
124143

125-
You can define architectural rules and check if they are violated.
126-
In the ribbon, go to Analyzers and there click "Architectural rules". If a project is loaded, this opens a dialog where you can define the rules.
144+
## Explore your Codebase
145+
146+
While this application was written to analyze cyclic code structures, it also offers functions to explore and understand the source code.
147+
148+
### How it works
149+
150+
![image-20240731123233438](Documentation/Images/code-explorer.png)
151+
152+
- Use the **Tree View** tab to add a single code element to the canvas.
153+
- Use the **Advanced Search** tab to search for code elements via more complex expressions. From the search result, you can add multiple code elements at once to the canvas. It supports `type:class`, `type:method`, `source:intern` and ReSharper-style camel-case search (e.g. `SC` finds `ShoppingCart`).
154+
- Explore the relationships between code elements using the context menu. For instance, you can track all incoming method calls or expand the inheritance tree.
155+
- To perform operations on multiple selected elements, use the tool buttons in the Code Explorer.
156+
157+
### Examples
158+
159+
Here are some general examples of how to use the application to explore a code base.
160+
161+
- [Essential concepts](Documentation/example-general-concepts.md)
162+
- [Find the call origins of a method](Documentation/example-find-call-origin.md)
163+
- [Understand how you could split a large class](Documentation/example-partition-class.md)
164+
165+
### Performance Tips
166+
167+
When the graph contains more than ~200 code elements, performance slows down. However, viewing so many elements at once is not helpful. You can collapse and expand container elements by double-clicking them to minimize the number of visible elements. When using the Advanced Search to add multiple code elements, consider adding them in a collapsed state to maintain focus and start with a smaller, faster graph.
168+
169+
---
170+
171+
## Export your graph
127172

173+
You can export your code graph (canvas) in various formats like **DGML** for further analysis in Visual Studio or as **PNG** image.
128174

175+
When you document code, a UML class diagram is often more helpful than a colored code graph. You can create a UML class diagram from the code elements in the graph. Note that all code elements are included in the diagram, even when collapsed and not visible.
176+
177+
Select "Copy to PlantUml class diagram" from the Export menu.
178+
179+
![](Documentation/Images/export-uml-class-diagram.png)
180+
181+
The PlantUml syntax is copied to the clipboard. You can use any online editor to render it.
182+
183+
![](Documentation/Images/example-uml.png)
184+
185+
---
186+
187+
## Validate architectural rules
188+
189+
You can define architectural rules and check if they are violated.
190+
In the ribbon, go to Analyzers and there click "Architectural rules". If a project is loaded, this opens a dialog where you can define the rules.
129191

130192
![](Documentation/Images/rule-configuration.png)
131193

@@ -168,33 +230,17 @@ The result of the analysis is shown in the table output for analyzers.
168230

169231
![](Documentation/Images/rule-result.png)
170232

171-
172-
173233
### Command-line
174234

175235
To integrate the tool into a build pipeline, you can call it without a user interface. You can find the syntax of the command-line here:
176236

177237
[Command-line arguments](Documentation/command-line-arguments.md)
178238

179-
## Generate UML class diagrams
180-
181-
When you document code, a UML class diagram is often more helpful than a colored code graph. You can create a UML class diagram from the code elements in the graph. Note that all code elements are included in the diagram, even if they are collapsed and are not visible at this time.
182-
183-
Select "Copy to PlantUml class diagram" from the Export menu.
184-
185-
![](Documentation/Images/export-uml-class-diagram.png)
186-
187-
188-
189-
The PlantUml syntax is copied to the clipboard. You can use any online editor to render it.
190-
191-
192-
193-
![](Documentation/Images/example-uml.png)
239+
---
194240

195-
## Other languages
241+
## Other Languages
196242

197-
The tool is written for C#, but you can also import jdeps output for basic visualization of Java code.
243+
The tool is written for C#, but you can also import jdeps output for basic visualization of Java code.
198244

199245
```
200246
jdeps.exe -verbose:class <bin-folder1> <bin-folder2>... >jdeps.txt
@@ -213,16 +259,16 @@ Please take note of the following issues:
213259
## Thank you
214260

215261
- The beautiful **images** in the user interface are <a href="https://de.freepik.com/search">Images from juicy_fish on Freepik</a>.
216-
You can find the direct link to the collection here: [Icon-Portfolio des Autors Juicy_fish | Freepik](https://de.freepik.com/autor/juicy-fish/icons)
217-
- The dependency graphs are created using the **"Automatic Graph Layout" package"**.
218-
MSAGL was developed in Microsoft by Lev Nachmanson, Sergey Pupyrev, Tim Dwyer, Ted Hart, and Roman Prutkin:
219-
https://github.com/microsoft/automatic-graph-layout
262+
You can find the direct link to the collection here: [Icon-Portfolio des Autors Juicy_fish | Freepik](https://de.freepik.com/autor/juicy-fish/icons)
263+
- The dependency graphs are created using the **"Automatic Graph Layout" package"**.
264+
MSAGL was developed in Microsoft by Lev Nachmanson, Sergey Pupyrev, Tim Dwyer, Ted Hart, and Roman Prutkin:
265+
https://github.com/microsoft/automatic-graph-layout
220266
- Drag and drop functionality is provided by the **gong-wpf-dragdrop** library.
221-
Copyright (c) Jan Karger, Steven Kirk and Contributors. Licensed under BSD-3-Clause.
222-
https://github.com/punker76/gong-wpf-dragdrop
267+
Copyright (c) Jan Karger, Steven Kirk and Contributors. Licensed under BSD-3-Clause.
268+
https://github.com/punker76/gong-wpf-dragdrop
223269
- Markdown rendering in the AI Advisor window is powered by **Markdig.Wpf** and **Markdig**.
224-
Copyright (c) Nicolas Musset and Alexandre Mutel. Licensed under BSD-2-Clause.
225-
https://github.com/Kryptos-FR/markdig.wpf / https://github.com/xoofx/markdig
270+
Copyright (c) Nicolas Musset and Alexandre Mutel. Licensed under BSD-2-Clause.
271+
https://github.com/Kryptos-FR/markdig.wpf / https://github.com/xoofx/markdig
226272

227273
For complete third-party license information, see the [ThirdPartyNotices](ThirdPartyNotices/) folder.
228274

@@ -236,7 +282,7 @@ This project is licensed under the GPL-3.0 License.
236282

237283
**Note:** Versions prior to v0.9.0 were released under the MIT License.
238284

239-
### What this means for you:
285+
### What this means for you
240286

241287
- ✅ Use it freely in your projects (even commercial)
242288
- ✅ Modify and improve it

0 commit comments

Comments
 (0)