PacktPublishing / C-Sharp-Data-Structures-and-Algorithms---Second-Edition

C# Data Structures and Algorithms - Second Edition by Packt Publishing
MIT License
31 stars 24 forks source link

Chapter03\SortingAlgorithms project doesn't compile due to mistakes in SelectionSort.cs #3

Open iankode opened 6 months ago

iankode commented 6 months ago

After downloading the companion code from Pack for the "C# Data Structures and Algorithms - Second Edition" [ISBN 9781803248271] https://www.packtpub.com/product/c-data-structures-and-algorithms-second-edition/9781803248271 Download code from GitHub that redirects to the common repository https://github.com/PacktPublishing/C-Sharp-Data-Structures-and-Algorithms---Second-Edition/tree/main

but unfortunately not all the code samples actually compile! This Issue reports failures within Chapter03\SortingAlgorithms project

Severity    Code    Description Project File    Line    Suppression State
Error   CS0118  'SelectionSort' is a namespace but is used like a type  03-SortingAlgorithms    F:\MarcinJ\Chapter03\SortingAlgorithms\Program.cs   9   Active

Warning CS7022  The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point.   03-SortingAlgorithms    F:\MarcinJ\Chapter03\SortingAlgorithms\SelectionSort.cs 34  Active

In SelectionSort.cs just prior to class definition has a spurious definition of AbstractSort this conflicts with the correct definition in AbstractSort.cs

Likewise the SelectionSort.cs also contains a spurious Program class (and static void Main entry point) that VS sensibly ignores with CS7022 warning, and the CSC implies the SVM for the actual top-level Program.cs

Because the class definition lacks the public assessor class SelectionSort : AbstractSort the Program tries to bind to the namespace instead and raises CS0260 error

Easy to make public public class SelectionSort : AbstractSort but [to be equivalent to other *.cs files] also better to suppress the local block namespace as already defaulted in .csproj by <RootNamespace>_03_SortingAlgorithms</RootNamespace>

I will now raise a PR hoping that Packt and author Dr Marcin Jamro will agree [to the benefit of subsequent subscribers] (I'm also hoping that each of these PRs will merit Packt awarding me an extra Credit to offset my time & effort!)

BTW this PR builds on my earlier PR #2 (Issue #1) so I hope that Packt & Marcin have already accepted that.

marcinjamro commented 6 months ago

Hello,

As I mentioned recently, the publisher modified the files I sent to them and uploaded the wrong version to the repository. Immediately after receiving the information from you, I contacted the publisher regarding this problem. It seems that the appropriate version of the files is currently already in the repository and there should be no problems with building the solution. I would be very grateful if you could check if everything is working fine and thanks again for reporting the problem!

If you have any questions or problems, I will be happy to help. The easiest way to contact me directly is via the contact details on my website, i.e. https://marcin.com :-)

Have a nice day! Marcin