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

Event.Copy should do a deep copy #149

Open
posics opened this issue Oct 3, 2016 · 5 comments
Open

Event.Copy should do a deep copy #149

posics opened this issue Oct 3, 2016 · 5 comments
Labels

Comments

@posics
Copy link

posics commented Oct 3, 2016

If I do
var tmpEvent = permanentEvent.Copy();
var newStart = new CalDateTime(blabla);
tmpEvent.Start = newStart;

then permanentEvent.Start has also changed to newStart. Shouldn't IEvent.Copy() do a deep copy and return a new instance with all things copied over, not just references?

I am doing all this because permanentEvent.getOccurrences(startTime, endTime) is returning occurences with just the start time set correctly and duration 0 (I see no end time anyway) and I need to calculate end and duration for each occurrence manually by creating a new event and copying stuff from permanentEvent. If getOccurrences() worked fine then I wouldn't have spotted this oddity.
Or maybe it's the lack of documentation that is confusing me. Can we have that documentation please?

@rianjs rianjs changed the title Event.Copy<IEvent>() weirdness Event.Copy should do a deep copy Oct 3, 2016
@rianjs
Copy link
Collaborator

rianjs commented Oct 3, 2016

Yep, sounds like a bug. I may have introduced it when I was evaluating all the usages of Copy in ical a few months ago. (Or maybe I didn't, and it's always been there.)

@KotM
Copy link

KotM commented Oct 23, 2017

Hi @rianjs ,

could you please explain why this bug was closed? I tried to do an event copy (want to create an Exception from a recurrent event), but this is not actual copy, because changing the event field (e.g. Summary) also changes the parent fields value as well.

        var parentEvent = new Event();
        parentEvent.Start = new CalDateTime(2015, 1, 1);
        parentEvent.Summary = "parent summary";

        var copy = parentEvent.Copy<Event>();

        copy.Start = new CalDateTime(2016, 1, 1);
        copy.Summary = "not parent summary";

        Assert.AreNotEqual(parentEvent.Start, copy.Start); // fails!
        Assert.AreNotEqual(parentEvent.Summary, copy.Summary); // fails!

I have no other possibility to create copy of new event except serialize/deserialize, but it is poor performance.

@rianjs
Copy link
Collaborator

rianjs commented Oct 23, 2017

It isn’t closed.

@KotM
Copy link

KotM commented Oct 23, 2017

Sorry for misunderstanding, very latest "Duplicate property DESCRIPTION" at the end of the list has confused me a bit. :)

So, do you have any plans and estimations for fixing this issue?

Or maybe you can propose another workaround except mentioned above serialize/deserialize approach?

Thank you in advance.

@rianjs
Copy link
Collaborator

rianjs commented Oct 23, 2017

So, do you have any plans and estimations for fixing this issue?

No.

Or maybe you can propose another workaround except mentioned above serialize/deserialize approach?

That's what we do today, hundreds of VCALENDARs and VEVENTs at a time, often as part of a click handler because it's fast enough, especially if you're working with collections AsParallel().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants