Skip to content

Open Question: What is the general solution for handling optional dependencies in project? #2

Open
@amirebrahimi

Description

@amirebrahimi

After having a lengthy discussion with Lukasz P here at Unity I figured I'd write some of my notes down to capture ideas that could improve CCU or invalidate its need.

Here are some possible paths to explore:

  • Make use of the CompilationPipeline (requires 2017.3 or later).
  • Use wrapper classes around optional dependencies that bind methods, properties, fields, etc. using Reflection.
  • Have a gist/snippet of code that dependencies could have to register themselves with AutoLOD (and possibly use Cecil to inject interface usage back into the assembly; otherwise automagical detection of method signatures would likely be required).
  • Have optional dependency C# code with a separate extension that won't compile automatically under Unity and then use the CSharpCodeProvider or Editor.CompileCSharp (similar to what EditorVR does for a test) to create that assembly/code and either load in dynamically (and have in a temp folder) or move the assembly into the project.
  • Similar to the above, name the C# file to have a separate extension and then name back when a dependency is detected; This is not likely a good solution as it would not work if the package was immutable.
  • When PackMan releases for dev use, potentially move off dependent code into another package that can depend on the optional dependency. Then, a user could select which packages they wanted to include alongside the main package (hopefully, there would be a good way to show these associated packages in the UI).
  • This would require some changes to Unity, but a toggle in metadata for a C# file could exist for whether it gets compiled or not, similar to VS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions