-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve self referencing types. #244
Conversation
Problem Scrooge currently doesn't support self-referencing types. This is useful for a number of cases. Solution Change the type resolver's scope to include the current type. Add unit tests. Result Self-referencing types no longer result in TypeNotFoundException. This should resolve #243 and partially resolve #160. This change doesn't yet support recursive types which is needed to fully resolve #160. This should be a backward compatible change since all the thrift files that are resolved correctly now will continue to get resolved correctly. One caveat though is that we don't enforce the self-reference type to be optional or collection type. We just depend on the generated language's compiler to enforce that (i.e. we expect that compiler to generate an error if a self-referencing type is specified as required).
@pinsri thanks! the change seems small enough. regardless, i'm nervous! to alleviate my paranoia, can you add 2 more tests? first where you add a self-reference to one of the IDLs under thanks again. |
let me try. thanks. |
Current coverage is 27.27% (diff: 100%)
|
LGTM |
…finition. Also fix a bug in GoldFileTest.scala's diff calculation code where if genStr is a prefix of expected, line 108 (getStr(i)) will generate OutOfBoundsException (since the diff is after the genStr string). .
Added 2 more tests. Adding to gold file input took way way more time than I expected. I eventually hacked up GoldFileTest.scala to print the full path of the generated file and not delete the temp directory and copied those files back (with some cleanup needed as well). Is there some simpler way to generate gold outputs that I'm missing? |
Thanks @pinsri. Yeah, the gold file test is a pain. When I've done it in the past, I thought it logged the new output to stdout (see https://github.com/twitter/scrooge/blob/develop/scrooge-generator-tests/src/test/scala/com/twitter/scrooge/goldfile/GoldFileTest.scala#L115-L128). Maybe that wasn't working? |
It was outputting to stdout, but copy pasting introduced unnecessary spaces On Sep 21, 2016 10:31 AM, "Kevin Oliver" [email protected] wrote:
|
@kevinoliver : does the PR look ok to you now? |
@pinsri yep! working on getting it merged in right now. thanks for the patch. |
Great, thanks for your review, @kevinoliver |
Also, do you know when the next release is going to be? |
We are targeting the beginning of October for the next release. |
Got this merged and it should show up on the |
@mosesn @kevinoliver Is the release going to be this week? Thanks. |
@pinsri Yep, looking very likely. There is one OSS issue we are trying to get sorted out before hand. |
Problem
Scrooge currently doesn't support self-referencing types. This is useful for a number of cases.
Solution
Change the type resolver's scope to include the current type. Add unit tests. Updated gold file and test.thrift to include a self-referencing type. Fixed a bug in GoldFileTest.scala's diff calculation code where if genStr is a prefix of expected, line 108 (getStr(i)) will generate OutOfBoundsException (since the diff is after the genStr string).
Result
Self-referencing types no longer result in TypeNotFoundException. This should resolve #243 and partially resolve #160. This change doesn't yet support recursive types which is needed to fully resolve #160.
This should be a backward compatible change since all the thrift files that are resolved correctly now will continue to get resolved correctly.
One caveat though is that we don't enforce the self-reference type to be optional or collection type. We just depend on the generated language's compiler to enforce that (i.e. we expect that compiler to generate an error if a self-referencing type is specified as required).