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

Setting own ProductId or Version has no effect #531

Open
akordowski opened this issue Oct 2, 2021 · 8 comments · May be fixed by #748
Open

Setting own ProductId or Version has no effect #531

akordowski opened this issue Oct 2, 2021 · 8 comments · May be fixed by #748
Labels

Comments

@akordowski
Copy link

Setting a own ProductId or Version on the Calendar has no effect. The ProductId and Version properties are replaced on the serialization with the library meta data.

var calendar = new Calendar
{
    ProductId = "MyCalendarTool",
    Version ="1.0"
};

https://github.com/rianjs/ical.net/blob/6c03c42bd9e040622ffaa240be856dc531a20823/src/Ical.Net/Serialization/CalendarSerializer.cs#L25-L38

@axunonb axunonb closed this as completed Oct 13, 2024
@akordowski
Copy link
Author

@axunonb Closing without any comment on this? Can you say if it is a bug or do I make something wrong? If it is a bug is it fixed, will be it fixed or don't? Thank you in advance.

@axunonb
Copy link
Collaborator

axunonb commented Oct 14, 2024

We closed the issue after 3 years of inactivity.
As the ProductId has a setter, it could be expected, that changing would have an effect - which is not the case.
If you'd like to contribute a PR this is more than welcome.

@axunonb axunonb reopened this Oct 14, 2024
@akordowski
Copy link
Author

So the Version and ProductId properties are meant not to be changed? They should be then only getters, right?

@axunonb
Copy link
Collaborator

axunonb commented Oct 14, 2024

Correct. To clean up, we could make ProductId to only have a getter, or to process the value set correctly (ensure the specification)
We'd prefer the 2nd option, and a PR is appreciated.

@akordowski
Copy link
Author

I would rather prefer to be able to override the properties with my own values. If the properties are not overridden then the library default values could be used. The specification don't states that it cannot be set to user values. At the moment it is an limitation by the library. What do you think?

@axunonb
Copy link
Collaborator

axunonb commented Oct 15, 2024

Changing the ProductId to a RFC-compliant value is fine.
With Version you are prone to get issues with client apps. They usually expect 2.0. So we won't open this to be changed. See LibraryMetadata.Version

@akordowski
Copy link
Author

akordowski commented Oct 15, 2024

With Version you are prone to get issues with client apps. They usually expect 2.0. So we won't open this to be changed.

Ok, that makes sense. Then the Version property should be a getter with the default value.

Changing the ProductId to a RFC-compliant value is fine.

So it would be ok for you if the property could be set to a custom value?

@axunonb
Copy link
Collaborator

axunonb commented Mar 6, 2025

@minichma As there was no PR submitted by @akordowski I'll do that today.
I can't see a reason why changing the PRODID should be excluded, as the serialized string can be changed anyway.
TBD: I'd include the FileVersion dynamically, instead of using a fixed version literal (currently 4.0).

@axunonb axunonb added bug and removed help wanted labels Mar 6, 2025
axunonb added a commit to axunonb/ical.net that referenced this issue Mar 6, 2025
Issue: `Calendar` has setters for `ProductId` and `Version` which are overridden with fixed values when serializing.

- Update the default `PRODID` property `LibraryMetadata.ProdId` to include the ical.net assembly version. Example: "PRODID:-//github.com/ical-org/ical.net//NONSGML ical.net 5.4.3//EN"
- Modified `CalendarSerializer.SerializeToString` so that the `ProdId` or `Version` set by users do not get overridden
- Add an xmldoc description about the purpose of `ProdId` and `Version`, and about the risks when modified

Resolves ical-org#531
@axunonb axunonb linked a pull request Mar 6, 2025 that will close this issue
axunonb added a commit to axunonb/ical.net that referenced this issue Mar 6, 2025
Issue: `Calendar` has setters for `ProductId` and `Version` which are overridden with fixed values when serializing.

- When creating a new `Calendar` instance, `ProductId` and `Version` contain default values
- When Deserializing an iCalendar, `ProductId` and `Version` will be taken from the input
- `ProductId` and `Version` can be overridden by user code. An attempt to set as an empty string will throw.
- Update the default `PRODID` property `LibraryMetadata.ProdId` to include the ical.net assembly version. Example: "PRODID:-//github.com/ical-org/ical.net//NONSGML ical.net 5.4.3//EN"
- Modified `CalendarSerializer.SerializeToString` so that the `ProdId` or `Version` set by users do not get overridden
- Add an xmldoc description about the purpose of `ProdId` and `Version`, and about the risks when modified
- Add unit tests

Resolves ical-org#531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants