I am having a hard time tracking down how this error happens with this code. I keep getting an index was outside the bounds but not sure how that happens when the array doesnt get modified or accessed at the 1050 line of code. Any thoughts?
Code
private List GetColumnHeaders(List rules, AppDivisionTeamSettingsModel divisionSettings, bool showPoolPoints, bool showPlayed)
{
if (showPlayed)
{
rules.Insert(0, TieBreakerRuleType.Played);
}
if (showPoolPoints)
{
rules.Insert(0, TieBreakerRuleType.Points);
}
var filteredRules = rules.Where(s => divisionSettings.ShowTies || s != TieBreakerRuleType.Ties).ToList(); // Getting Index was outside the bounds of the array also, dont know why 1050
// Add ToList Because Of Unknown Error Happening (Collection was modified; enumeration operation may not execute.)
return filteredRules
.Select(r => AppStandingsColumnModel.GetPoolRuleAbbreviation(r, divisionSettings.ScoringType, divisionSettings.ContestType, divisionSettings.Sport))
.Select(t => new AppStandingsHeaderModel(t)).ToList();
}
Exception
Error in Path :/api/v2/app/standings
Raw Url :/api/v2/app/standings?aid=com.exposure.684&s=1&r=31&b=6.5.1&v=6.5.1&t=eyvrVgSJKENhnfAg6ucOKU:APA91bGj3fr6hDDzRUoSWHv38sCwmRwZzgLXXOgwLXCE1eNVBhmI-F_YslBvpbfSpoiBbLABq8ULb92E96dw-4wbCVm3r79qOC-DmnesWG7P6g2245Opmsg&did=1073261&eid=232868
Message :Index was outside the bounds of the array.
Source :mscorlib
Stack Trace : at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Tournaments.Services.Api.App.AppDivisionsService.GetColumnHeaders(List`1 rules, AppDivisionTeamSettingsModel divisionSettings, Boolean showPoolPoints, Boolean showPlayed) in E:\Projects\Tournaments.Services\Api\App\AppDivisionsService.cs:line 1050
at Tournaments.Services.Api.App.AppDivisionsService.GetStandings(AppStandingsRequest request) in E:\Projects\Tournaments.Services\Api\App\AppDivisionsService.cs:line 923
at Tournaments.Controllers.Api.App.AppStandingsController.Get(AppStandingsRequest request) in E:\Controllers\Api\App\AppStandingsController.cs:line 43