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

Obsolete ILocalClock.LocalNowAsync #16752

Merged
merged 6 commits into from
Sep 18, 2024
Merged

Obsolete ILocalClock.LocalNowAsync #16752

merged 6 commits into from
Sep 18, 2024

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Sep 18, 2024

Fixes #16751

I'm not sure why we added an async property which was the first time I saw it in my life. @rjpowers10 could you please try to reproduce in this PR

/// <summary>
/// Gets the time for the local time zone.
/// </summary>
Task<DateTimeOffset> LocalNowAsync { get; }

Task<DateTimeOffset> GetLocalNowAsync();
Copy link
Member

@MikeAlhayek MikeAlhayek Sep 18, 2024

Choose a reason for hiding this comment

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

This introduces a breaking change. To avoid having a breaking change so this instead

Task<DateTimeOffset> LocalNowAsync { get; }

Task<DateTimeOffset> GetLocalNowAsync()
    => LocalNowAsync ;

Copy link
Member Author

Choose a reason for hiding this comment

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

Why it's a breaking change? the value still comes from the new implementation, right?

Copy link
Member

Choose a reason for hiding this comment

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

It's for when you have an existing alternative implementation. Should be rare but can happen: Then, with Mike's code, no change is needed, only when we remove LocalNowAsync.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why I used error before to let the compiler complains whenever we use it

Copy link
Member

Choose a reason for hiding this comment

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

That's why I used error before to let the compiler complains whenever we use it

this will break people. So we have to avoid it. Doing my suggestion then no breaking change because in the interface we provide the default implementation. In your implementation, you can change the default behavior found in the interface.

@Piedone
Copy link
Member

Piedone commented Sep 18, 2024

Addresses #16751 isn't understood by GitHub. Please use Fixes #16751 or some of the other magic words to connect PRs to issues.

Copy link
Member

@MikeAlhayek MikeAlhayek left a comment

Choose a reason for hiding this comment

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

Fixed the build

@Piedone Piedone merged commit dd03cf8 into main Sep 18, 2024
16 checks passed
@Piedone Piedone deleted the hishamco/local-clock branch September 18, 2024 22:11
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.

ILocalClock.LocalNowAsync causes a VSTHRD003 code analysis warning
3 participants