fix: handling of empty packages sequence #1195
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The call to .First() was throwing exemption if the sequence contains no elements. In the call stack it's being hidden within the .ToDictionary since the methods are chained.
Related issue
TT: P119178698
Description
See project file here: https://github.com/neerajhanda/AspNetCore.BookStore/blob/master/src/AspNetCore.Bookstore.Web/AspNetCore.Bookstore.Web.csproj
Error: PortingAssistant.Client.PortingProjectFile.PortingProjectFileHandler: Error while creating project file for {projectfile} - System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at CTA.Rules.ProjectFile.ProjectFileCreator.<>c.b__30_1(XElement d)
at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Lookup
2.Create(IEnumerable1 source, Func
2 keySelector, IEqualityComparer1 comparer) at System.Linq.GroupedEnumerable
2.GetEnumerator()at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityComparer`1 comparer)at CTA.Rules.ProjectFile.ProjectFileCreator.UpdatePackageReferences()
at CTA.Rules.ProjectFile.ProjectFileCreator.CreateContents()
Supplemental testing
Add two unit tests that step through the new code to verify the functionality.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.