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

Enable NRT for classes in namespace Ical.Net.Utility #706

Merged
merged 2 commits into from
Jan 26, 2025

Conversation

axunonb
Copy link
Collaborator

@axunonb axunonb commented Jan 25, 2025

No description provided.

@axunonb axunonb force-pushed the pr/nrt-for-ical-net-utility branch from ac4f5e0 to 6f91d5c Compare January 25, 2025 10:07
@axunonb axunonb requested a review from minichma January 25, 2025 10:09
public static DateTimeZone GetZone(string tzId, bool useLocalIfNotFound = true)
{
var exMsg = $"Unrecognized time zone id {tzId}";

if (string.IsNullOrWhiteSpace(tzId))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We removed the implicit usage of the local time zone in other parts, didn't we? Hope, this is the only one left.

@@ -634,7 +634,7 @@ public int CompareTo(IDateTime? dt)
public string ToString(string? format, IFormatProvider? formatProvider)
{
formatProvider ??= CultureInfo.InvariantCulture;
var dateTimeOffset = DateUtil.ToZonedDateTimeLeniently(Value, _tzId).ToDateTimeOffset();
var dateTimeOffset = DateUtil.ToZonedDateTimeLeniently(Value, _tzId ?? string.Empty).ToDateTimeOffset();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we handle floating separately? Not sure how the method behaves if we pass an empty string.

@@ -66,18 +62,21 @@ public static bool Equals<T>(IEnumerable<T> left, IEnumerable<T> right, bool ord
return left.SequenceEqual(right);
}

// No multiple enumerations
var rightArray = right as T[] ?? right.ToArray();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Eager iteration would only help if right/left would be generators, which doesn't seem to be the case in any of today's uses, otherwise it would rather add overhead.

}
catch (Exception)
{
//It's not possible to sort some collections of things (like Calendars) in any meaningful way. Properties can be null, and there's no natural
//ordering for the contents therein. In cases like that, the best we can do is treat them like sets, and compare them. We don't maintain
//fidelity with respect to duplicates, but it seems better than doing nothing
var leftSet = new HashSet<T>(left);
var rightSet = new HashSet<T>(right);
var leftSet = new HashSet<T>(leftArray);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this whole way of comparing isn't too helpful. We discussed this in another ticket, that Equals might not be too helpful for many of the types, e.g. Calendar. But that's a topic for a different PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I wanted to stick to NRT

@axunonb axunonb merged commit 4be1fd8 into ical-org:main Jan 26, 2025
2 checks passed
@axunonb axunonb deleted the pr/nrt-for-ical-net-utility branch January 26, 2025 22:33
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