Skip to content

Commit 283f2e2

Browse files
committed
fixed results sorting issue
1 parent ed7fd66 commit 283f2e2

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

RetailCoder.VBE/Inspections/CodeInspectionResultBase.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using Antlr4.Runtime;
45
using Rubberduck.Parsing;
@@ -82,6 +83,11 @@ public QualifiedSelection QualifiedSelection
8283

8384
public virtual CodeInspectionQuickFix DefaultQuickFix { get { return QuickFixes.FirstOrDefault(); } }
8485

86+
public int CompareTo(ICodeInspectionResult other)
87+
{
88+
return Inspection.CompareTo(other.Inspection);
89+
}
90+
8591
public override string ToString()
8692
{
8793
var module = QualifiedSelection.QualifiedName;
@@ -94,6 +100,11 @@ public override string ToString()
94100
QualifiedSelection.Selection.StartLine);
95101
}
96102

103+
public int CompareTo(object obj)
104+
{
105+
return CompareTo(obj as ICodeInspectionResult);
106+
}
107+
97108
public string ToCsvString()
98109
{
99110
var module = QualifiedSelection.QualifiedName;

RetailCoder.VBE/Inspections/ICodeInspectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Rubberduck.Inspections
77
{
8-
public interface ICodeInspectionResult
8+
public interface ICodeInspectionResult : IComparable<ICodeInspectionResult>, IComparable
99
{
1010
IEnumerable<CodeInspectionQuickFix> QuickFixes { get; }
1111
CodeInspectionQuickFix DefaultQuickFix { get; }

RetailCoder.VBE/Inspections/IInspection.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace Rubberduck.Inspections
45
{
56
/// <summary>
67
/// An interface that abstracts a runnable code inspection.
78
/// </summary>
8-
public interface IInspection : IInspectionModel
9+
public interface IInspection : IInspectionModel, IComparable<IInspection>, IComparable
910
{
1011
/// <summary>
1112
/// Runs code inspection on specified parse trees.

RetailCoder.VBE/Inspections/InspectionBase.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
34
using Rubberduck.Parsing.Symbols;
@@ -20,6 +21,7 @@ protected InspectionBase(RubberduckParserState state)
2021
public virtual string Name { get { return GetType().Name; } }
2122
public virtual CodeInspectionSeverity Severity { get; set; }
2223
public virtual string Meta { get { return InspectionsUI.ResourceManager.GetString(Name + "Meta"); } }
24+
// ReSharper disable once UnusedMember.Global: it's referenced in xaml
2325
public virtual string InspectionTypeName { get { return InspectionsUI.ResourceManager.GetString(InspectionType.ToString()); } }
2426
public virtual string AnnotationName { get { return Name.Replace("Inspection", string.Empty); } }
2527

@@ -32,5 +34,15 @@ protected virtual IEnumerable<Declaration> UserDeclarations
3234
{
3335
get { return State.AllUserDeclarations.Where(declaration => !declaration.IsInspectionDisabled(AnnotationName)); }
3436
}
37+
38+
public int CompareTo(IInspection other)
39+
{
40+
return string.Compare(InspectionType + Name, other.InspectionType + other.Name, StringComparison.Ordinal);
41+
}
42+
43+
public int CompareTo(object obj)
44+
{
45+
return CompareTo(obj as IInspection);
46+
}
3547
}
3648
}

RetailCoder.VBE/UI/CodeInspections/InspectionResultsControl.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:resx="clr-namespace:Rubberduck.UI"
88
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
99
xmlns:codeInspections="clr-namespace:Rubberduck.UI.CodeInspections"
10+
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
1011
mc:Ignorable="d"
1112
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance codeInspections:InspectionResultsViewModel}">
1213
<UserControl.Resources>
@@ -92,13 +93,19 @@
9293
<PropertyGroupDescription PropertyName="Inspection.InspectionTypeName" />
9394
<PropertyGroupDescription PropertyName="Inspection" />
9495
</CollectionViewSource.GroupDescriptions>
96+
<CollectionViewSource.SortDescriptions>
97+
<componentModel:SortDescription PropertyName="Inspection" />
98+
</CollectionViewSource.SortDescriptions>
9599
</CollectionViewSource>
96100

97101
<CollectionViewSource x:Key="CodeModuleGroupViewSource" Source="{Binding Results}">
98102
<CollectionViewSource.GroupDescriptions>
99103
<PropertyGroupDescription PropertyName="QualifiedSelection.QualifiedName" />
100104
<PropertyGroupDescription PropertyName="Inspection" />
101105
</CollectionViewSource.GroupDescriptions>
106+
<CollectionViewSource.SortDescriptions>
107+
<componentModel:SortDescription PropertyName="Inspection" />
108+
</CollectionViewSource.SortDescriptions>
102109
</CollectionViewSource>
103110

104111
<DataTemplate x:Key="InspectionResultTemplate"

0 commit comments

Comments
 (0)