Skip to content

WIP Update prime factors to use longs#1310

Closed
robkeim wants to merge 1 commit intoexercism:masterfrom
robkeim:update-prime-factors
Closed

WIP Update prime factors to use longs#1310
robkeim wants to merge 1 commit intoexercism:masterfrom
robkeim:update-prime-factors

Conversation

@robkeim
Copy link
Copy Markdown
Contributor

@robkeim robkeim commented Aug 17, 2019

This change causes all of the ints to be treated as longs throughout the rest of the exercises. I left the other exercises out of this WIP PR so it makes it easier to see what changes I made.

@ErikSchierboom do you have an idea what I'm doing wrong?

Fixes #1309

@ErikSchierboom
Copy link
Copy Markdown
Member

@robkeim You're not really doing anything wrong, it's just that JSON.net by default will deserialize numbers to a long, as some numbers might not fit into a int.

Now what to do about this. There are several options I feel:

  1. At the places where a long is needed, we render it as a long string instead of relying on the automatic rendering (which has an effect on all exercises).
  2. We could plug a custom JsonConverter into our deserialization, which correctly identifies if a value should actually be converted to an integer instead of a long. I have some experience with this, so I can help here.

I think the second one is a little bit nicer, but also a bit more work. I'm happy to help here though. What do you think?

@robkeim
Copy link
Copy Markdown
Contributor Author

robkeim commented Aug 18, 2019

I'm also in favor of the second solution. I poked around a bit and tried to understand how the deserialization works, but I don't see where/how we can add a custom JsonConverter to parse integer values correctly.

I'm not sure what's the best way to proceed here. Did you want to try to make the change or did you want to try to explain to me where the change needs to be made and then have me do it? Either way works for me.

@ErikSchierboom
Copy link
Copy Markdown
Member

Did you want to try to make the change [...]

I think this is probably the easiest option. I'll let you know when I have anything for you to work with!

@robkeim
Copy link
Copy Markdown
Contributor Author

robkeim commented Aug 18, 2019

Sounds good, if there's anything I can do let me know!

@ErikSchierboom
Copy link
Copy Markdown
Member

@robkeim See PR #1311 for a fix for the long issue!

@robkeim
Copy link
Copy Markdown
Contributor Author

robkeim commented Aug 19, 2019

Great thanks @ErikSchierboom! I'll go ahead and close PR and review the other one.

@robkeim robkeim closed this Aug 19, 2019
@robkeim robkeim deleted the update-prime-factors branch August 19, 2019 20:53
ErikSchierboom pushed a commit to ErikSchierboom/csharp that referenced this pull request Jan 15, 2021
slight amendment to wording, sorry if these are annoying!
ErikSchierboom pushed a commit to ErikSchierboom/csharp that referenced this pull request Jan 21, 2021
slight amendment to wording, sorry if these are annoying!
ErikSchierboom pushed a commit to ErikSchierboom/csharp that referenced this pull request Jan 26, 2021
slight amendment to wording, sorry if these are annoying!
ErikSchierboom pushed a commit to ErikSchierboom/csharp that referenced this pull request Jan 27, 2021
slight amendment to wording, sorry if these are annoying!
ErikSchierboom pushed a commit to ErikSchierboom/csharp that referenced this pull request Jan 28, 2021
slight amendment to wording, sorry if these are annoying!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inherent flaw in PrimeFactor exercise

2 participants