diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs index 79331dbefa..700e44ac4b 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs +++ b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs @@ -19,10 +19,12 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Reflection; using ICSharpCode.Reporting; using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; using ICSharpCode.CodeQuality.Engine.Dom; namespace ICSharpCode.CodeQuality.Reporting @@ -46,6 +48,11 @@ namespace ICSharpCode.CodeQuality.Reporting var reportingFactory = new ReportingFactory(); var reportCreator = reportingFactory.ReportCreator (stream,newList); ReportSettings = reportingFactory.ReportModel.ReportSettings; + var groupColumn = (GroupColumn)ReportSettings.GroupColumnsCollection[0]; + groupColumn.GroupSortColumn = new SortColumn() { + ColumnName = "ReferenceCount", + SortDirection = ListSortDirection.Ascending + }; reportCreator.BuildExportList(); return reportCreator; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs index 38fd148e90..eed7ca2ad0 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs @@ -143,8 +143,13 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling IEnumerable> GroupInternal () { + PropertyDescriptor sortProperty = null; var groupProperty = listProperties.Find(reportSettings.GroupColumnsCollection[0].ColumnName,true); - var sortProperty = listProperties.Find("Randomint",true); + var groupColumn = (GroupColumn)reportSettings.GroupColumnsCollection[0]; + + if (groupColumn.GroupSortColumn != null) { + sortProperty = listProperties.Find(groupColumn.GroupSortColumn.ColumnName,true); + } IEnumerable> groupedList; if (sortProperty == null) { groupedList = baseList.GroupBy(a => a.GetType().GetProperty(groupProperty.Name).GetValue(a, null)).OrderBy(c => c.Key); @@ -155,7 +160,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling return groupedList; } - #endregion public void Bind() @@ -167,8 +171,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling } } - #region Fill + #region Fill public void Fill (List collection, object current) { Current = current; diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs index 2b0905d95e..3c913fadf7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs @@ -43,6 +43,6 @@ namespace ICSharpCode.Reporting.Items public int GroupLevel {get;private set;} - + public SortColumn GroupSortColumn {get;set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs index f7436f5df5..fbfaef24ea 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs @@ -46,6 +46,34 @@ namespace ICSharpCode.Reporting.Test.DataSource } + [Test] + public void GroupbyOneColumnSortSubList () { + var rs = new ReportSettings(); + var gc = new GroupColumn() { + ColumnName ="GroupItem", + SortDirection = ListSortDirection.Ascending, + GroupSortColumn = new SortColumn() { + ColumnName = "Randomint", + SortDirection = ListSortDirection.Ascending + } + }; + rs.GroupColumnsCollection.Add(gc); + var collectionSource = new CollectionDataSource (list,rs); + collectionSource.Bind(); + var testKey = String.Empty; + var testSubKey = -1; + var groupedList = collectionSource.GroupedList; + foreach (var element in groupedList) { + Assert.That(element.Key,Is.GreaterThan(testKey)); + testKey = element.Key.ToString(); + foreach (Contributor sub in element) { + Assert.That(sub.RandomInt,Is.GreaterThanOrEqualTo(testSubKey)); + testSubKey = sub.RandomInt; + } + testSubKey = -1; + } + } + [Test] public void GroupbyOneColumn () { @@ -53,6 +81,12 @@ namespace ICSharpCode.Reporting.Test.DataSource rs.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); var collectionSource = new CollectionDataSource (list,rs); collectionSource.Bind(); + var testKey = String.Empty; + var groupedList = collectionSource.GroupedList; + foreach (var element in groupedList) { + Assert.That(element.Key,Is.GreaterThan(testKey)); + testKey = element.Key.ToString(); + } }