Comments (10)
Generated code has something like this:
func resolveInjectablePerson() -> InjectablePerson {
return self.resolve(PersonType.self)! as! InjectablePerson
}
I think we don't need !
before as!
. The generated code can be:
func resolveInjectablePerson() -> InjectablePerson {
return self.resolve(PersonType.self) as! InjectablePerson
}
from swinject-codegen.
Generated code has something like this:
func resolveInjectablePerson(foo: AType, bar: BType, baz: String, qux: String) -> InjectablePerson {
return self.resolve(PersonType.self, arguments: (foo, bar, baz, qux))! as! InjectablePerson
}
I think it's more understandable if the first argument is labeled like this:
func resolveInjectablePerson(foo foo: AType, bar: BType, baz: String, qux: String) -> InjectablePerson {
return self.resolve(PersonType.self, arguments: (foo, bar, baz, qux))! as! InjectablePerson
}
Then you can use the function like this:
let p = container.resolveInjectablePerson(foo: someFoo, bar: someBar, baz: "some baz", qux: "some qux")
from swinject-codegen.
Generated code has something like this:
extension Resolvable {
func registerInjectablePerson(registerClosure: (resolver: ResolverType) -> (InjectablePerson)) -> ServiceEntry<PersonType> {
return (self as! Container).register(PersonType.self, factory: registerClosure)
}
}
It uses (self as! Container)
, which expects the Resolvable
instance must be Container
type. I think it's more understandable to extend Container
type for registration methods. (Resolution methods can stay in the extension of Resolvable
.)
from swinject-codegen.
we can bind the current version to swinject < 2.0.0, then update the generated code, release a new version and depend on swinject >= 2.0.0.
I do not see any necessary migrations, as the code will simply be replaced.
from swinject-codegen.
@Lutzifer plz let me know when the code is ready for review.
from swinject-codegen.
This can be done, I do not have any open improvements/todos concerning the generated code atm
from swinject-codegen.
I'll try reviewing in this weekend.
from swinject-codegen.
I wrote three suggestions⬆️ What do you think about them?
from swinject-codegen.
we had an issue with (self as! Container) in an earlier version of the code, but it seems to have vanished :-)
from swinject-codegen.
@Lutzifer FYI: I'll rename Resolvable
to ResolverType
in Swinject 2.0.0.
Swinject/Swinject#90
Swinject/Swinject#87
CodeGen also needs migration to Swinject 2.0.0 later, but for now we can work on Swinject 1.x.
from swinject-codegen.
Related Issues (20)
- Use STDIN/STDOUT if -i/-o are not specified HOT 2
- update example code in readme HOT 2
- Release v0.5.0 HOT 2
- Naming consistency of YAML keys HOT 4
- ADD_DEPENDENCY syntax HOT 13
- Sort scripts into subdirectories HOT 1
- Use Pull Requests to Test Automatically before Merging into master HOT 2
- rename Resolvable to ResolverType when switching to Swinject 2.0.0. HOT 1
- ruby code style HOT 2
- Re-Write the Readme to get rid of the "issue" and "proposal" style
- Write release notes to be informative
- trailing semicolon leads to defective code
- replace all non a-zA-Z characters in name field with _
- Add information how to use typed arrays and dictionaries to Readme
- mention CodeGen in Swinject Readme HOT 2
- Leaving out component leads to wrong code
- Add a description to the project HOT 2
- Is there any way how to use Swinject's Object Scopes with CodeGen? HOT 1
- Update for Swift 3.0 HOT 1
- add @discardableResult to avoid xcode warnings when registering
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swinject-codegen.