voxeltycoon-community / voxel-tycoon-open-library

Community-made open-source library of functions made for making mods for the game Voxel Tycoon
GNU Affero General Public License v3.0
3 stars 2 forks source link

VTOLReflectionHelpers Expansion #21

Closed evertn closed 2 years ago

evertn commented 2 years ago

MemberNotFoundException (new)

(MemberNotFoundException.cs)

This exception will be thrown when a ReflectionHelpers-method tries to access a member which is not present. We added this exception to replace ArgumentException, which is very generic.

ReflectionException (new)

(ReflectionException.cs)

This is the base exception of all custom exceptions which get thrown while using reflection. All reflection based custom exceptions should inherit from this class.

ReflectionHelpers (new)

(ReflectionHelpers.cs)

This class replaces VTOLReflectionHelpers.

Completely redesigned the ReflectionHelpers-class. Methods are no longer using Harmony, this because while using Harmony we had no control over when an exception is thrown, and could not communicate to the user what went wrong. All method are now using reflection directly.

RelfectionHelpersTests (new)

(ReflectionHelpersTests (internal).cs) (ReflectionHelpersTests (external).cs)

This class replaces VTOLReflectionHelpersTests.

This class is divided over 2 files: ReflectionHelpersTests (internal).cs and ReflectionHelpersTests (external).cs.

ReflectionHelpersTests (internal).cs will hold the testing methods which will test the ReflectionHelpers-methods while using internally created test classes.

ReflectionHelpersTests (external).cs will hold the testing methods which will test the ReflectionHelpers-methods while using external Voxel Tycoon classes.

A couple of tests were failing, we decided to ignore the case and added an explanation what we think went wrong. It seems to be a very rare case and therefor we've decided to ignore the case.

The specific test is still there, it is just not executed (SetPropertyValue_EnsureNoBleeding_WhenGetAndSet()).

RequireLazyManagerAttribute (new)

(RequireLazyManagerAttribute.cs)

TypeMismatchException (new)

(TypeMismatchException.cs)

This exception will be thrown when a method returns a value which is not of the expected Type. This exception is ment to replace the ArgumentException, which is very generic.

VTOLReflectionHelpers (removed)

(VTOLReflectionHelpers.cs)

According to #28 the name of this class was up for change. Since everything in this class was going to be replaced anyway, we removed this class and created ReflectionHelpers.

VTOLReflectionHelpersTests (removed)

(VTOLReflectionHelpersTests.cs)

According to #28 the name of this class was up for change. Since everything in this class was going to be replaced anyway, we removed this class and created ReflectionHelpersTests.

Files

(.gitignore) (stryker-config.json) (Voxel Tycoon Open Library.csproj) (Voxel Tycoon Open Library.sln)

evertn commented 2 years ago

Added #28 to this PR. Once this PR is merged with the main branch, there are no classes left with the VTOL-prefix.