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

Implemented missing Journal constructor so Initialize method is called. #310

Merged
merged 5 commits into from
Sep 19, 2017

Conversation

HitTheDrum
Copy link

If not intended, the constructor of the Journal class was missing and its Initialize() Method was not called which led to "Component: null" object when instantiated.

@rianjs
Copy link
Owner

rianjs commented Aug 19, 2017

Can you get rid of Initialize(), and move that logic to the constructor?

And then implement the change in net-core as well?

- Prevented multiple passes while extrapolating
- Extended setter logic, so that duration is adjusted when end changes (and vice versa)
@HitTheDrum
Copy link
Author

HitTheDrum commented Aug 20, 2017

Initialize(): Initialize() is also called in OnDeserializing. However atm Initialize() is a one-liner (Name = Components.Journal;). Would you still prefer to move the logic to both (constructor and OnDeserializing) or keep it in the existing Initialize() method? Or just remove from OnDeserializing as this should not be necessary?

net-core: no problem! I will adjust it then too.

@rianjs
Copy link
Owner

rianjs commented Aug 20, 2017

Initialize(): Initialize() is also called in OnDeserializing. However atm Initialize() is a one-liner (Name = Components.Journal;). Would you still prefer to move the logic to both (constructor and OnDeserializing) or keep it in the existing Initialize() method? Or just remove from OnDeserializing as this should not be necessary?

I think it's safe to move it to the constructor. It's just setting properties, and by rights, this is a constant property for the type. In fact, it could probably be real const. In the meantime, though, the constructor is fine.

HitTheDrum added 2 commits August 23, 2017 01:54
This reverts commit 2971e35.
Reason: Not intended for current pull request.
…" object when instantiated.

- Removed redundant OnDeserializing().
@HitTheDrum
Copy link
Author

Moved Initialize() logic to constructor and removed reduntant OnDeserializing() in

  • .\ical.net-master\net-core\Ical.Net\Ical.Net\Components\Journal.cs
  • .\ical.net-master\v2\ical.NET\Components\Journal.cs
    (Please just ignore rev 2971e35 (reverted with 3aaf539) as it was not intended for this pull request)

Copy link
Owner

@rianjs rianjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this solve a problem you have? I.e., do you need me to publish a nuget package version that incorporates these change?

If so, can you:

  • Update the readme.md file, and explain quickly what problem was solved with these changes.
  • Bump the minor version in the respective nuspec files in v2 and net-core?

else if (Duration == default(TimeSpan) && DtStart != null && DtEnd != null)
{
Duration = DtEnd.Subtract(DtStart);
if (propertyName == nameof(DtEnd))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces for conditionals.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

}
else if (DtStart == null && Duration != default(TimeSpan) && DtEnd != null)
{
DtStart = DtEnd.Subtract(Duration);
}
else if (/*Duration == default(TimeSpan) && */ DtStart != null && DtEnd != null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit commented-out code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood!

/// <summary>
/// Flag to check if ExtrapolaTimes is currently invoking to prevent multi extrapolating
/// </summary>
private bool _isExtrapolating;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this solve a problem that you have a test case for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open another Pull Request incl. description to separate this from the current request.

{
Name = Components.Journal;
}

protected override bool EvaluationIncludesReferenceDate => true;

protected override void OnDeserializing(StreamingContext context)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall that deleting these overrides can cause subtle problems, so I think these should be put back.

I'm sorry my other comment was unclear: I meant delete the call to Initialize() from this method, moving that logic to the constructor, which you've done. Can you put back this override? Then it will be ready to merge.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted removal of OnDeserializing()
(see 7a3f471)

@rianjs rianjs merged commit 2b1a176 into rianjs:master Sep 19, 2017
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.

2 participants