Browse Source

Search pane view with input, mode picker, result list

Replace the placeholder TextBlock with the real layout: a TextBox at
the top bound two-way to SearchPaneModel.SearchTerm (UpdateSourceTrigger
PropertyChanged so the orchestrator reacts on every keystroke once it
lands), a ComboBox bound to SearchModes / SelectedSearchMode, and a
ListBox that renders each SearchResult as three trimmed columns
(Name / Location / Assembly).

Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
03684a449d
  1. 76
      ILSpy.Tests/Search/SearchPaneViewTests.cs
  2. 33
      ILSpy/Search/SearchPane.axaml

76
ILSpy.Tests/Search/SearchPaneViewTests.cs

@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Headless.NUnit;
using AwesomeAssertions;
using ILSpy.AppEnv;
using ILSpy.Search;
using ILSpy.Views;
using NUnit.Framework;
namespace ICSharpCode.ILSpy.Tests.Search;
[TestFixture]
public class SearchPaneViewTests
{
[AvaloniaTest]
public async Task SearchPane_Hosts_The_Required_Three_Controls_For_Search_Input_Mode_And_Results()
{
// The pane's contract — used by every downstream commit in this series — is
// that the view exposes three named controls bound to the view-model: a TextBox
// for the query (SearchInput), a ComboBox for the mode picker (SearchModePicker),
// and a ListBox that renders incoming results (SearchResults).
var window = AppComposition.Current.GetExport<MainWindow>();
window.Show();
var pane = await window.WaitForComponent<SearchPane>();
var input = pane.FindControl<TextBox>("SearchInput");
((object?)input).Should().NotBeNull("the query TextBox is what the user types into");
var modePicker = pane.FindControl<ComboBox>("SearchModePicker");
((object?)modePicker).Should().NotBeNull("the mode picker drives which ILSpyX strategy runs");
modePicker!.ItemCount.Should().Be(12,
"the picker must populate from SearchPaneModel.SearchModes — twelve entries");
var results = pane.FindControl<ListBox>("SearchResults");
((object?)results).Should().NotBeNull("the results list is the binding sink for the streaming orchestrator");
}
[AvaloniaTest]
public async Task Typing_Into_The_Search_Input_Writes_Through_To_SearchTerm()
{
var window = AppComposition.Current.GetExport<MainWindow>();
window.Show();
var pane = await window.WaitForComponent<SearchPane>();
var vm = (SearchPaneModel)pane.DataContext!;
var input = pane.FindControl<TextBox>("SearchInput");
input!.Text = "Enumerable";
vm.SearchTerm.Should().Be("Enumerable",
"the TextBox is bound two-way to SearchPaneModel.SearchTerm");
}
}

33
ILSpy/Search/SearchPane.axaml

@ -6,7 +6,34 @@ @@ -6,7 +6,34 @@
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="200"
x:Class="ILSpy.Search.SearchPane"
x:DataType="search:SearchPaneModel">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="Gray" FontStyle="Italic"
Text="Search results will appear here." />
<Grid RowDefinitions="Auto,*" Margin="4">
<Grid Grid.Row="0" ColumnDefinitions="*,8,Auto" Margin="0,0,0,4">
<TextBox Grid.Column="0" Name="SearchInput"
PlaceholderText="Search…"
Text="{Binding SearchTerm, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<ComboBox Grid.Column="2" Name="SearchModePicker"
ItemsSource="{Binding SearchModes}"
SelectedItem="{Binding SelectedSearchMode, Mode=TwoWay}"
MinWidth="150">
<ComboBox.ItemTemplate>
<DataTemplate DataType="search:SearchModeEntry">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<ListBox Grid.Row="1" Name="SearchResults"
ItemsSource="{Binding Results}"
x:CompileBindings="False">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="*,8,Auto,8,Auto" Margin="2,1">
<TextBlock Grid.Column="0" Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{Binding Location}" Foreground="Gray" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="4" Text="{Binding Assembly}" Foreground="Gray" TextTrimming="CharacterEllipsis" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>

Loading…
Cancel
Save