Skip to content
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

Add BigInteger to ToBencodexValue() #159

Merged

Conversation

Projects
None yet
3 participants
@earlbread
Copy link
Member

commented Mar 28, 2019

  • Added BigInteger to ToBencodexValue.

@earlbread earlbread self-assigned this Mar 28, 2019

@earlbread earlbread requested review from dahlia and longfin Mar 28, 2019

@@ -115,6 +122,7 @@ protected Person(SerializationInfo info, StreamingContext context)
.ToList();
Secret = info.GetString("Secret");
IsStudent = info.GetBoolean("IsStudent");
Assets = (BigInteger)info.GetValue("Assets", typeof(BigInteger));

This comment has been minimized.

Copy link
@longfin

longfin Mar 28, 2019

Member

We already have GetValue<T>(), so you can use it.

@codecov

This comment has been minimized.

Copy link

commented Mar 28, 2019

Codecov Report

Merging #159 into master will decrease coverage by 2.9%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #159      +/-   ##
==========================================
- Coverage   87.06%   84.16%   -2.91%     
==========================================
  Files          69       69              
  Lines        3163     3164       +1     
==========================================
- Hits         2754     2663      -91     
- Misses        409      501      +92
Impacted Files Coverage Δ
Libplanet/Serialization/BencodexFormatter.cs 81.91% <100%> (+0.19%) ⬆️
Libplanet/Net/IceServer.cs 0% <0%> (-100%) ⬇️
Libplanet/Net/IceServerException.cs 0% <0%> (-100%) ⬇️
Libplanet/Net/NetworkStreamProxy.cs 0% <0%> (-80.77%) ⬇️
Libplanet/Net/Swarm.cs 83.75% <0%> (-4.66%) ⬇️
@earlbread

This comment has been minimized.

Copy link
Member Author

commented Mar 28, 2019

I added a commit. Please take a look. @dahlia @longfin

@@ -109,12 +116,12 @@ protected Person(SerializationInfo info, StreamingContext context)
{
Name = info.GetString("Name");
Age = (int)info.GetInt64("Age");
Names =
((List<object>)info.GetValue("Names", typeof(List<object>)))
Names = info.GetValue<List<object>>("Names")

This comment has been minimized.

Copy link
@dahlia

dahlia Mar 28, 2019

Member

Is this change intended? The previous code looks rather proper.

This comment has been minimized.

Copy link
@earlbread

earlbread Mar 28, 2019

Author Member

I thought info.GetValue<List<object>>("Names") is better than ((List<object>)info.GetValue("Names", typeof(List<object>))). Do you think previous one is better?

This comment has been minimized.

Copy link
@dahlia

dahlia Mar 28, 2019

Member

I thought it is not like better or worse, but just it's unlikely to be compiled. If the type checker passes I don't mind then.

This comment has been minimized.

Copy link
@dahlia

dahlia Mar 28, 2019

Member

To elaborate, the changed version looks like trying to putting a List<object> value into List<string> property, which C#'s type checker does not allow AFAIK.

This comment has been minimized.

Copy link
@earlbread

earlbread Mar 28, 2019

Author Member

There is more code below:

.Select(s => (string)s)
.ToList();

So I think it will pass the type checker.

This comment has been minimized.

Copy link
@dahlia

dahlia Mar 28, 2019

Member

Ah, make sense.

@dahlia

dahlia approved these changes Mar 28, 2019

@earlbread earlbread merged commit 85106b0 into planetarium:master Mar 28, 2019

5 checks passed

Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
changelog This contains self-describing changelog.
Details
codecov/patch 100% of diff hit (target 87.06%)
Details
codecov/project Absolute coverage decreased by -2.9% but relative coverage increased by +12.93% compared to 39821e4
Details

@earlbread earlbread deleted the earlbread:add-biginteger-bencodex-formatter branch Mar 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.