Importing minimal set of classes from project A to project B
Project A has a class I need. But it depends on some other classes within the project. Is there a way to export the class with all dependencies within the project?
As I want to try it with a few versions of project A, I don't like the idea of manually copying files.
9 Replies
is there a reason you can't factor it out into a library that both projects reference?
What @Jimmacle suggests is the idiomatic and correct approach. Just make a third smaller library with the code in question. Clean, simple.
Project A is large. (different version of mapsui)
Sorry, I should have specified I do not own project A. It's different version of project A (mapsui) than project B already uses. Needed for single functionality. where we dont want to have the whole another version. basicly i want to make the smaller library but only for project B. I am wondering if there is a tool that can do that automatically?
If project A is not monolith core, but build with dynamic shared libraries (like in Linux, whenever you update dependencies, all packages receive this update) you can link and use only one specific part, but not entirely everything
If it is source available, you can link (or include source) A to B and let compiler trim unnecessary parts. All modern linkers and compilers can do this
And also I would like to ask you for more details. I personally got confused of what you exactly need
More details would help others understand your problem better
basically I am working on a project that uses mapsui for various things. now I need to add functionality (WFS 2.0 support) that was added in newer version of mapsui than we are using. updating the project to the new mapsui version is not an option (not my decision). So I wanted to extract the class I need (wfs provider) and its dependencies in a small package. but not include whole another mapsui version just to not use 99% of it.
1. Keep codebase with old mapsui lib
2. Make another project with new mapsui. Make wrappers on new functionality
3. Link your codebase to this wrapper
Is it correct? I don’t get why you are afraid of entire mapsui lib for wrapper project - it is just few MB on your disk
If you really need to save these MB, then include mapsui library codebase into wrapper project and let compiler trim unnecessary stuff
But in this case you need to handle its compilation within your wrapper
I would be fine with it. but i will be told to do it like this. Adding another project to the solution will not be ok as well i think. it consits of a very few projects
Then it is likely an impossible task
You can try to copy paste library source from their GitHub (or any other public repository) to your main project in solution to extend missing stuff, but there are problems:
- some licenses don’t allow it
- you gonna end up with recreating already existing functionality from this lib - that is not good engineering
ok, thanks. I guess at least for testing which version works the extra project method will work