Fixes 2448 i dumper refactor#2460
Merged
erendrake merged 2 commits intoKSP-KOS:developfrom Mar 19, 2019
Merged
Conversation
This move will (in the next commit) allow types derived from GenericMessageQueue to be able to construct new instances of themselves from a static factory method, which they could not do before because they needed to pass in a new instance of the time provider when constructing. (Now the GenericMessageQueue constructs its own instance of the timeprovider from just knowing the timeprovider's subtype mentioned in the generics.) This may seem pointless, but it will be needed to make the next commit work.
Fixes KSP-KOS#2448: This refactor is described better by issue KSP-KOS#2448's comments, where I wrote down a detailed list of what I was doing before I did it. In a nutshell, previous to this refactor, classes implementing IDumper had a secret (unenforced) requirement to always have a default constructor or the serialiazation would fail to create the object on reading the file/message. That was because the algorithm used in reading was: 1 - create instance with default constructor. 2 - populate instance using LoadDump() call. Because interfaces cannot have static things in them, we couldn't do it properly by saying IDumper is a contract to create a single factory method that does both (1) and (2) at once. This refactor moves the logic to using a new static method called CreateFromDump() that does do (1) and (2) together, and the enforcement to confirm that you do indeed have such a method is done via reflection at runtime since the compiler cannot do it (C# is one of the almost-OOP languages that can't handle inheriting static things.) Once that refactor was done, then Geocoordinates started working, solving KSP-KOS#2448.
erendrake
approved these changes
Mar 19, 2019
Dunbaratu
added a commit
to Dunbaratu/KOS-1
that referenced
this pull request
Apr 28, 2019
The word "IKOSTargetable" was accidentally deleted from the declaration header of class BodyTarget by my PR KSP-KOS#2460. The SET TARGET command has a check to see if the value being set is an actual target object or just a string name that needs to be looked up. That check was based on seeing if the value could be cast to IKOSTargetable or not. When that was accidentally removed from BodyTarget's header, it broke that check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2448 - refactor serialization so geocoords work
Fixes #2448:
This refactor is described better by issue #2448's comments, where
I wrote down a detailed list of what I was doing before I did it.
In a nutshell, previous to this refactor, classes implementing
IDumper had a secret (unenforced) requirement to always have
a default constructor or the serialiazation would fail to
create the object on reading the file/message. That was
because the algorithm used in reading was:
Because interfaces cannot have static things in them, we
couldn't do it properly by saying IDumper is a contract
to create a single factory method that does both (1) and (2)
at once.
This refactor moves the logic to using a new static method
called CreateFromDump() that does do (1) and (2) together,
and the enforcement to confirm that you do indeed have
such a method is done via reflection at runtime since
the compiler cannot do it (C# is one of the almost-OOP
languages that can't handle inheriting static things.)
Once that refactor was done, then Geocoordinates started
working, solving #2448.