Hide COM objects behind API #1697
Labels
enhancement
Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope.
technical-debt
This makes development harder or is leftover from a PullRequest. Needs to be adressed at some point.
Milestone
I'm not sure if an issue is the right place for this so if it isn't, feel free to close it.
How about we create our own object model for the COM objects we work with (VBProject, VBComponent, ...). This way we could deal with all the oddities of COM in one place and the rest of the codebase gets to deal with "normal" classes without having to bother with COM exceptions and the like. E.g. on load we translate the VBProject+VBComponents into our own object model, similar to an ORM I suppose.
If we have to get the current state we simply refresh the object. Manipulating code, exporting a module and the like could be hidden behind their interfaces, they in turn could use this new structure to get the component, do the change and then quickly get rid of the component again.
This also has the advantage that we don't have to deal with VBProjects etc. in our unit tests. The mocks would get easier. It also has the advantage that we automatically work with snapshots (right now you can cause a parser error if you change the code while it is parsing, because the parser doesn't actually work with a snapshot).
Any thoughts on this?
Edit: This could also be the first step towards making the vba compiler independent of the VBE, allowing it to be used anywhere, e.g. for writing web applications in VBA.
The text was updated successfully, but these errors were encountered: