sczerwinski / android-hilt Goto Github PK
View Code? Open in Web Editor NEWExtensions for Dagger Hilt
Home Page: https://czerwinski.it/projects/android-hilt/
License: Apache License 2.0
Extensions for Dagger Hilt
Home Page: https://czerwinski.it/projects/android-hilt/
License: Apache License 2.0
There is a new annotation @TestInstallIn
in Hilt 2.31-alpha.
Implement @TestFactoryMethod
annotation that work exactly like @FactoryMethod
, but generates modules annotated with @TestInstallIn
instead of @InstallIn
.
After implementing #191, check if possible to properly handle @FactoryMethod
in companion object
.
Currently, such a method requires a parameter of type [CLASS_NAME].Companion
.
Default component
should be SingletonComponent
:
annotation class BoundTo(
val supertype: KClass<*>,
val component: KClass<*> = SingletonComponent::class
)
Default supertype
should mean that the processor tries to infer the super type from reflection (if there is only one direct supertype).
For default supertype
, a new annotation will be introduced:
annotation class Bound(
val component: KClass<*> = SingletonComponent::class
)
To solve doubts it is interesting using discussions instead of issues
Deprecate BoundTo (and delete it at some point) and merge it into Bound
supertype can be nullable, and if null will behave as Bound
currently would.
Maybe I'm missing a reason why you made two distinct annotations
Investigate the possibility to make the annotation processor incremental.
@Bound
class Foo @Inject constructor() : Converter<TypeA, TypeB> { }
Caused by: java.lang.ClassCastException: com.squareup.javapoet.ParameterizedTypeName cannot be cast to com.squareup.javapoet.ClassName
at it.czerwinski.android.hilt.processor.model.BindingBuilder.build(BindingBuilder.kt:59)
at it.czerwinski.android.hilt.processor.HiltModulesGenerator.createBinding(HiltModulesGenerator.kt:76)
at it.czerwinski.android.hilt.processor.HiltModulesGenerator.createBindings(HiltModulesGenerator.kt:70)
at it.czerwinski.android.hilt.processor.HiltModulesGenerator.process(HiltModulesGenerator.kt:51)
Factory
class or object.create
method with @FactoryMethod
.The class/object is called Factory
and not imported.
The class/object should be imported to the generated code.
Will it use primary when it is released?
IMO it is a generic name which can lead to confusion (I don't know it is a standard in another frameworks). Is it planned to add a secondary
?
I think something like Injectable(...)
is more descriptive.
I have multi module project and inside module I have public interface
public interface UserRepository {
...
}
and internal implementation of this interface
@Bound
internal class UserRepositoryImpl @Inject constructor(): UserRepository {
...
}
With kapt processor It works fine because it's Java and it doesn't know about "internal" modifier:
@Module
@InstallIn(SingletonComponent.class)
public interface UserRepository_SingletonComponent_BindingsModule {
@Binds
@Singleton
@NonNull
UserRepository bindUserRepositoryImpl(@NonNull UserRepositoryImpl implementation);
}
But with ksp processor I'm receiving an error 'public' function exposes its 'internal' parameter type UserRepositoryImpl
:
@Module
@InstallIn(SingletonComponent::class)
public interface UserRepository_SingletonComponent_BindingsModule {
@Binds
public fun bindUserRepository(implementation: UserRepositoryImpl): UserRepository
}
Would be good if class that marked with annotation @Bound/@BoundTo has "internal" visibility modifier, than generated "*_BindingsModule" class would also have internal visibility modifier.
There is a new annotation @TestInstallIn
in Hilt 2.31-alpha.
Implement @TestBoundTo
and @TestBound
annotations that work exactly like @BoundTo
and @Bound
, but generate modules annotated with @TestInstallIn
instead of @InstallIn
.
Implement hilt-processor
as KSP processor (either in the same library, or as a separate hilt-processor-ksp
library).
The KSP processor should duplicate the functionality of the existing Kapt processor, but it should be managed by KSP instead.
Ticket for official KSP support for Hilt: https://issuetracker.google.com/issues/179057202
Build
Warning: No SupportedSourceVersion annotation found
HiltModulesGenerator
needs to override getSupportedSourceVersion
eg:
override fun getSupportedSourceVersion(): SourceVersion {
return SourceVersion.RELEASE_8
}
Not sure if this is something that should be done, maybe it's going too far.
Support for multibindings could be interesting
Equivalent of IntoMap
or IntoSet
eg:
@BoundIntoMap(component = ..., supertype = ...)
class Foo @Inject constructor(): Bar
Configure Dagger KSP in examples and tests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.