Thursday, May 26, 2016

buildshell

[moss][4hrs] slower progress today. Late start. Added a rudimentary build shell, and some basic logging and arg parsing features. It's cool to be able to run unittest from the build shell and see a bunch of stuff getting tested--even cooler when unittest will run the more interesting serialization unit tests that live in my core dll.

edit: I will be off tomorrow and Monday.

Wednesday, May 25, 2016

housekeeping

[moss][6hrs] Got unittest harness up and running. It uses reflection to scan a known set of assemblies for participating static methods, and then calls the methods. It then does all the normal stuff with the results (displaying success/fail with pretty colors, displays any exceptions that occured). It also tracks execution time. My ambition is to have the unittest module keep a local record of execution times (for tests that signaled that their times were "interesting", and not highly random or something), and then warn if that time changed by more than some % delta. 

Still building the house I want to live in...

Tuesday, May 24, 2016

serialization layer + housekeeping

[serialization][3hrs] Finished support for Dictionaries. Integrated a nuget package that does deep (reflection based) comparison of arbitrary objects to see if they are value-equal. Used that to add some tests of some very hairy compound containers. 

[environment][2.5hrs] Started putting together project directory. Ported over serialization from its test project. serialization will be the first feature, and a testground for exercising some of the facilities of the project: unit testing, code validation, and the core mosstool for doing things like updating the TypeMap. 

Monday, May 23, 2016

serialization layer

[moss][9hrs] Wow, the day just flew by. I'm enjoying the pleasant illusion of rapid progress. I wrote a whole great steaming mess of code, anyway.

notes from today's CL.

1) BinTag helper methods to facilitate making a BinTag directly from a Type
2) Added Primitive flag to BinTag to make error-cases better.
3) ContainerSerializers. Add support for:
   a. Stack (requires custom writer that reverses order)
   b. Arrays
   c. Nested containers (required whole new methods for recursively writing all the
      BinTags necessary to fully specify a type and then read them back.
4) Primitive/Container Serializers initialization flow entrusted to TypeMap.
   This feels better.
5) Removed createType from SerializableType as it was not that interesting. On as side-note
   container deserialization now presizes to correct capacity!
6) SerializableType now remembers the short name of its source Assembly in file state.
   It uses this in concert with the new TypeMap assembly cache to locate the Type
   at runtime. This turned out to be harder than I thought. Type.GetType requires a
   fully qualified Assembly name (unless in the local assembly or mscorlib). But the
   FQAN has the version embedded in it! I would like to follow semantic versioning rules,
   which means this string will change a lot. My solution is to store only the short
   assembly name, and then search all assemblies for the assembly that matches it (whatever
   the version is).
7) Removed initalizeAssemblyState from TypeMap. I've rethought the flows for TypeMap
   initialization. When creating ex-niliho, you call initializeFromAssemblies, and
   pass in an array of Assemblies to scan for participating types. When updating,
   you will call updateFromAssemblies, which will take both the TypeMap file and
   the Assemblies array. When using at Runtime, you will initialize via initializeFromFile,
   which will take a parameter specifying whether runtime state is mandatory.

Sunday, May 22, 2016

serialization layer

[1hr] Wrote up engineering design goals for MOSS, as well as user experience goals for a hypothetical game that might sit on top of MOSS.

[3hrs] Got container serialization working for Lists. All other Collections should follow trivially. I think a new method-pair will be necessary for conventional C# arrays. Then associative containers, and I'll be done with this part. The hard bit was of course coercing the C# type system to not complain about all the vague things I was doing. For instance, I had:

object entry = Serializers.deserializeInternal( i_reader ); // i_reader is a BinaryReader
container.Add( entry); // container is a dynamic created via reflection.

This doesn't fly. The runtime can figure out that the List indeed has an Add method, but it's detecting as Add<int>, and you can't pass an Object to Add<int>, even if the Object happens to be an int. I don't think there's any general way to do a cast like:

Type someType = object.GetType();
(someType)object;

Solution? Make entry also be dynamic. Duh. Just keep making things dynamic until it works. Should have thought of that immediately.