Comments (8)
That's exactly what I'm doing now 😉
from sourcery.
Hi @bejar37. Can you provide an example of your enum?
from sourcery.
sure, just tried with this:
enum IntOrString: AutoEnumDecodable {
case s(string: String)
case i(int: Int)
}
from sourcery.
There is clearly an issue with detecting enum rawValue type. Currently parser assumes that the first type after ":" is a RawType, which is wrong when you just conform to protocol. Will try to fix that.
from sourcery.
Ah, that seems reasonable! I wouldn't mind doing:
enum IntOrString {
case s(string: String)
case i(int: Int)
}
extension IntOrString: AutoEnumEncodable { }
But this doesn't work either. That's probably the same as #35 ?
from sourcery.
I'm afraid even with #35 fixed we need to make some fixes for that problem too. I'm currently looking for solutions.
from sourcery.
I think if we waited with rawType resolution until uniqueTypes
gets called then we can resolve this because we can identify whether a type is a protocol, class, struct etc. what do you think @ilyapuchka ?
from sourcery.
@ilyapuchka @krzysztofzablocki I'm still seeing this issue using 0.16.1. I have protocol MyAutoCellType
in a framework that my app target is linked to, and enum MyTestEnum
in my app target. MyAutoCellType
only gets recognized by Sourcery templates if it's not the first conformance declared on a enum (or, if I temporarily move MyAutoCellType
into my app target itself, this issue goes away, but I need to avoid that option).
For example, Sourcery sees the MyAutoCellType
conformance here:
enum MyTestEnum: Equatable, MyAutoCellType {
// sourcery: cellType = "MyTableViewCell"
case test
}
and here:
enum MyTestEnum: String, MyAutoCellType {
// sourcery: cellType = "MyTableViewCell"
case test
}
but not here:
enum MyTestEnum: MyAutoCellType {
// sourcery: cellType = "MyTableViewCell"
case test
}
and not here:
enum MyTestEnum: MyAutoCellType, Equatable {
// sourcery: cellType = "MyTableViewCell"
case test
}
I verified this by adding the following dump to my template. With the first two examples, the dump has inheritedTypes = ["MyAutoCellType"]
, but with the last two, inheritedTypes
doesn't contain "MyAutoCellType".
{% for type in types.enums where type.localName == "MyTestEnum" %}
// {{ type }}
{% endfor %}
I did find that declaring the protocol conformance on an extension (i.e. extension MyTestEnum: MyAutoCellType
) gets Sourcery to recognize the conformance. So given that there are at least two workarounds for this problem (either putting another declaration in front of your custom protocol; or using an extension), it might not be a high-priority bug, but FYI that it's still out there.
from sourcery.
Related Issues (20)
- Sourcery crashes on \r\n (a.k.a. DOS- or Windows-style) line-endings HOT 1
- Failed to link file HOT 2
- [Question] Using Sourcery In Swift Package Executable HOT 4
- Errors when running unit tests HOT 2
- Get protocols that are implemented by the Element type of an array
- Some unit tests are executed for too long HOT 4
- Not able to build GraphQL target - Command PhaseScriptExecution failed with a nonzero exit code HOT 2
- SPM Installation, Sourcery Pro clarification HOT 3
- Xcode fails to find Sourcery. Shows Sourcery not installed error HOT 2
- Use .xcfilelist file as sources list file
- Protocol compositions in EJS templates
- 2.0.3 release was not completed HOT 1
- Crash in ParserResultsComposed.resolveType(typeName:containingType:) HOT 2
- Version 2.0.3 has significant performance issues HOT 16
- Linux Support: from experimental to 100% 🚀
- Mintfile issue when a new version of Sourcery is released HOT 9
- Issue when running sourcery from binary HOT 18
- Automate homebrew releases HOT 3
- XCLocalSwiftPackageReference is not supported HOT 6
- All releases/podspecs after 2.0.2 haven't been pushed to cocoapods HOT 2
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 sourcery.