[generator] initial unit test support and refactoring #282
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.
Context: https://github.com/grendello/JavaBindingGenerator
@grendello has an initial prototype of a "re-imagined"
generator. Ourcurrent goal is to refactor the current
generatorand slowly migratethe existing code to look something like the new one. It obviously is
going to take a while, so we need to do this in a fashion where we can
keep things working while making changes over time. Eventually we may
get to a place where we can import @grendello's existing project to be
used within
generator.The high-level changes we should first adopt from the new
generator:Java.Interop.Bindings.Syntaxhierarchy @grendello came up withapi.xmlparsing and the codegeneration
have currently, which are in fact "integration" tests
allow us to move
generatorforward into the futureThis PR is the first step in achieving this, here is a breakdown of the
changes:
Integration-TestsfolderUnit-Testsfolder if they are indeed unittests
[assembly: InternalsVisibleTo("generator-Tests")]will need to beadded to
generatorso that we can write unit tests againstinternalclasses and methods
StreamWriter sware changed toTextWriter writerasneeded. This allows us to use a
StringWriterin unit testsclass handles, class invoker handles, and fields
generator-Testsproject.Once the existing code is reasonably under unit test, these types can
completely go away as we switch the object model over to POCOs.
Fieldhave been moved to theCodeGeneratorbase class. This allows us to getFieldcloser to aPOCO.
Parameteris nowinternalso it can beinstantiated from unit tests
JavaInteropCodeGeneratorTestsandXamarinAndroidCodeGeneratorTests, unit tests within take around 1ms,so we can add as many of these as we like
CodeGenerator.ContextTypeare being refactored during themigration, as it seems to be a code smell. While writing each unit test,
I could easily discover the
ContextTypesstack usage becauseexceptions are thrown. Hopefully, we can remove
ContextTypecompletelyas refactoring continues, and just pass the required value through an
additional parameter.
NOTE: in this PR, I've (hopefully) not altered the output of
generator. I have noticed a few bugs/oddities in the output, but planto fix these in future PRs after we have these tests.
Miscellaneous changes:
<Service />MSBuilditem, I'm not sure what this is for, but it is a hassle to keep
discarding it