diff --git a/.editorconfig b/.editorconfig index f72d504..fa46e28 100644 --- a/.editorconfig +++ b/.editorconfig @@ -140,7 +140,9 @@ csharp_space_between_square_brackets = false ## Suppressions for ILSpy coding style # IDE2002:Consecutive braces must not have blank line between them -dotnet_diagnostic.IDE2002.severity = warning +dotnet_diagnostic.IDE2002.severity = none +# IDE2003: Blank line required between block and subsequent statement # dotnet_diagnostic.IDE2003.severity = error -dotnet_style_allow_statement_immediately_after_block_experimental = false:warning +dotnet_style_allow_statement_immediately_after_block_experimental = false:none +dotnet_diagnostic.IDE2003.severity = none diff --git a/ILSpy.Core/Search/SearchPane.xaml.cs b/ILSpy.Core/Search/SearchPane.xaml.cs index 58b1406..93eebcb 100644 --- a/ILSpy.Core/Search/SearchPane.xaml.cs +++ b/ILSpy.Core/Search/SearchPane.xaml.cs @@ -48,9 +48,9 @@ public partial class SearchPane : UserControl, IPane static SearchPane instance; RunningSearch currentSearch; bool runSearchOnNextShow; - DispatcherTimer updateResultTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(2D) }; + DispatcherTimer updateResultTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(2D) }; - public ObservableCollection Results { get; } = new ObservableCollection(); + public ObservableCollection Results { get; } = new ObservableCollection(); public static SearchPane Instance { get { @@ -67,30 +67,30 @@ public SearchPane() { InitializeComponent(); searchModeComboBox.ItemsSource = new []{ - new { Image = Images.Library, Name = "Types and Members" }, - new { Image = Images.Class, Name = "Type" }, - new { Image = Images.Property, Name = "Member" }, - new { Image = Images.Method, Name = "Method" }, - new { Image = Images.Field, Name = "Field" }, - new { Image = Images.Property, Name = "Property" }, - new { Image = Images.Event, Name = "Event" }, - new { Image = Images.Literal, Name = "Constant" }, - new { Image = Images.Library, Name = "Metadata Token" } - }; + new { Image = Images.Library, Name = "Types and Members" }, + new { Image = Images.Class, Name = "Type" }, + new { Image = Images.Property, Name = "Member" }, + new { Image = Images.Method, Name = "Method" }, + new { Image = Images.Field, Name = "Field" }, + new { Image = Images.Property, Name = "Property" }, + new { Image = Images.Event, Name = "Event" }, + new { Image = Images.Literal, Name = "Constant" }, + new { Image = Images.Library, Name = "Metadata Token" } + }; ContextMenuProvider.Add(listBox); MainWindow.Instance.CurrentAssemblyListChanged += MainWindow_Instance_CurrentAssemblyListChanged; MainWindow.Instance.SessionSettings.FilterSettings.PropertyChanged += FilterSettings_PropertyChanged; - // This starts empty search right away, so do at the end (we're still in ctor) - searchModeComboBox.SelectedIndex = (int)MainWindow.Instance.SessionSettings.SelectedSearchMode; + // This starts empty search right away, so do at the end (we're still in ctor) + searchModeComboBox.SelectedIndex = (int)MainWindow.Instance.SessionSettings.SelectedSearchMode; searchModeComboBox.SelectionChanged += (sender, e) => MainWindow.Instance.SessionSettings.SelectedSearchMode = (Search.SearchMode)searchModeComboBox.SelectedIndex; - updateResultTimer.Tick += UpdateResults; + updateResultTimer.Tick += UpdateResults; - this.DataContext = new DataGridCollectionView(Results); - } + this.DataContext = new DataGridCollectionView(Results); + } - void MainWindow_Instance_CurrentAssemblyListChanged(object sender, NotifyCollectionChangedEventArgs e) + void MainWindow_Instance_CurrentAssemblyListChanged(object sender, NotifyCollectionChangedEventArgs e) { if (VisualRoot != null) { StartSearch(this.SearchTerm); @@ -122,43 +122,37 @@ public void Show() StartSearch(this.SearchTerm); } } - Dispatcher.UIThread.InvokeAsync( - new Action( - delegate { - searchBox.Focus(); - //searchBox.SelectAll(); - searchBox.SelectionStart = 0; - searchBox.SelectionEnd = searchBox.Text?.Length ?? 0; - }), - DispatcherPriority.Background); - updateResultTimer.Start(); - } - - public static readonly StyledProperty SearchTermProperty = - AvaloniaProperty.Register("SearchTerm", string.Empty, notifying: OnSearchTermChanged); - - ////public static readonly StyledProperty FooProperty = - //// AvaloniaProperty.Register("Foo", "default", - //// inherits: true, - //// //// defaultBindingMode: BindingMode.OneWay, - //// validate: null, - //// coerce: null, - //// notifying: OnSearchTermChanged); - - public string SearchTerm { + Dispatcher.UIThread.InvokeAsync( + new Action( + delegate { + searchBox.Focus(); + //searchBox.SelectAll(); + searchBox.SelectionStart = 0; + searchBox.SelectionEnd = searchBox.Text?.Length ?? 0; + }), + DispatcherPriority.Background); + updateResultTimer.Start(); + } + + public static readonly StyledProperty SearchTermProperty = + AvaloniaProperty.Register("SearchTerm", string.Empty); + + public string SearchTerm { get { return GetValue(SearchTermProperty) ?? string.Empty; } set { SetValue(SearchTermProperty, value ?? string.Empty); } } - static void OnSearchTermChanged(AvaloniaObject o, bool changed) - { - if (changed) - { - ((SearchPane)o).StartSearch(o.GetValue(SearchTermProperty)); - } - } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + if (change.Property == SearchTermProperty) + { + ((SearchPane)change.Sender).StartSearch(change.Sender.GetValue(SearchTermProperty)); + } + + base.OnPropertyChanged(change); + } - void SearchModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + void SearchModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { MainWindow.Instance.SessionSettings.SelectedSearchMode = (SearchMode)searchModeComboBox.SelectedIndex; StartSearch(this.SearchTerm); @@ -167,8 +161,8 @@ void SearchModeComboBox_SelectionChanged(object sender, SelectionChangedEventArg void IPane.Closed() { this.SearchTerm = string.Empty; - updateResultTimer.Stop(); - } + updateResultTimer.Stop(); + } void ListBox_MouseDoubleClick(object sender, RoutedEventArgs e) { @@ -207,7 +201,7 @@ void SearchBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Down && Results.Count > 0) { e.Handled = true; - // TODO: movefocus + // TODO: movefocus //listBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); listBox.SelectedIndex = 0; } @@ -305,46 +299,46 @@ public RunningSearch(LoadedAssembly[] assemblies, string searchTerm, SearchMode this.apiVisibility = apiVisibility; } - static IEnumerable Split(string str, Func controller) - { - int nextPiece = 0; - for (int c = 0; c < str.Length; c++) - { - if (controller(str[c])) - { - yield return str.Substring(nextPiece, c - nextPiece); - nextPiece = c + 1; - } - } - - yield return str.Substring(nextPiece); - } - - static string TrimMatchingQuotes(string input, char quote) - { - input = input.Trim(); - if (input.Length >= 2 && input[0] == quote && input[input.Length-1] == quote) - { - return input.Substring(1, input.Length - 2); - } - return input; - } - - string[] CommandLineToArgumentArray(string commandLine) - { - bool inQuotes = false; - - return Split(commandLine, c => - { - if (c == '\"') - { - inQuotes = !inQuotes; - } - return !inQuotes && c == ' '; - }).Select(arg => TrimMatchingQuotes(arg, '\"')) - .Where(arg => !string.IsNullOrEmpty(arg)) - .ToArray(); - } + static IEnumerable Split(string str, Func controller) + { + int nextPiece = 0; + for (int c = 0; c < str.Length; c++) + { + if (controller(str[c])) + { + yield return str.Substring(nextPiece, c - nextPiece); + nextPiece = c + 1; + } + } + + yield return str.Substring(nextPiece); + } + + static string TrimMatchingQuotes(string input, char quote) + { + input = input.Trim(); + if (input.Length >= 2 && input[0] == quote && input[input.Length-1] == quote) + { + return input.Substring(1, input.Length - 2); + } + return input; + } + + string[] CommandLineToArgumentArray(string commandLine) + { + bool inQuotes = false; + + return Split(commandLine, c => + { + if (c == '\"') + { + inQuotes = !inQuotes; + } + return !inQuotes && c == ' '; + }).Select(arg => TrimMatchingQuotes(arg, '\"')) + .Where(arg => !string.IsNullOrEmpty(arg)) + .ToArray(); + } public void Cancel() { @@ -434,21 +428,21 @@ AbstractSearchStrategy GetSearchStrategy() public sealed class SearchResult : IMemberTreeNode { public static readonly System.Collections.Generic.IComparer Comparer = new SearchResultComparer(); - + public IEntity Member { get; set; } public float Fitness { get; set; } - + public string Location { get; set; } public string Name { get; set; } public object ToolTip { get; set; } public Bitmap Image { get; set; } public Bitmap LocationImage { get; set; } - + public override string ToString() { return Name; } - + class SearchResultComparer : System.Collections.Generic.IComparer { public int Compare(SearchResult x, SearchResult y)