tentenponce / KoinGraph

Graph generator for android projects using Koin
MIT License
15 stars 1 forks source link

Graph module with scope #8

Closed mibaldi closed 5 years ago

mibaldi commented 5 years ago

I use also injection with scope in activities like this: image the tool support this type of annotation?

tentenponce commented 5 years ago

This is noted, will also support this. Thanks.

mibaldi commented 5 years ago

i used recent version and scope is not supported

tentenponce commented 5 years ago

I've tested the exact format (base on your screenshot) and add tests:

Here's the sample format that KoinGraph trying to parse:

single { ComponentA(get(), get()) }
      single { ComponentB() }
      factory { FactoryA(get(), get()) }
      factory { FactoryB() } 
      viewModel { ViewModelA(get(), get(), get(), get()) }
      viewModel { ViewModelB() }
      scope(named<Activity>()) {
        scoped { ScopeA() }
        scoped { ScopeB() }
      }

And here's the expected output: ['ComponentA', 'ComponentB', 'FactoryA', 'FactoryB', 'ViewModelA', 'ViewModelB', 'ScopeA', 'ScopeB']

Full test: https://github.com/tentenponce/KoinGraph/blob/master/test/domain/DependencyReaderHelperTest.js

How exactly the bug behave?

mibaldi commented 5 years ago

The scope that I don't see are those that have parameters in body. image

image

only i see router and use case, not the presenter. I try with one little project with the same struct and it works image image

mibaldi commented 5 years ago

Hi, i try with another example and i found the error, when i use one Activity extend of on BaseActivity like this : class BaseMvpActivity<V, T : BaseMvpPresenter<V>>() : AppCompatActivity() the tool not work correctly. but if i change to class BaseMvpActivity<V>() : AppCompatActivity() works

tentenponce commented 5 years ago

I will have a look on this, this will surely help.

tentenponce commented 5 years ago

Hi, KoinGraph still works fine even the class has generics on it. I've created tests for it:

https://github.com/tentenponce/KoinGraph/pull/11/files#diff-13bc62182156aa4b3f2e463c77513f9e

Can you share your ProfilePresenter class?

mibaldi commented 5 years ago

https://gist.github.com/mibaldi/5b3390b5a745edc698a7d57ad6f9a61e isn't my original profilepresenter but is the same case

tentenponce commented 5 years ago

Fixed on https://github.com/tentenponce/KoinGraph/pull/11.

Problem is with the ClassCastHelper, it returns true even the class is parameter instead of extension or interface. Tests included on ClassCastHelperTest.