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

Allow event monitoring to ignore failing event accessors #1954

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from

Conversation

apazureck
Copy link

@apazureck apazureck commented Jul 11, 2022

Added options to event monitor and added option to suprress exceptions on event accessors.

Closes #1948

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

Moved methods config options to event monitor options
@apazureck apazureck changed the title Draft Removed event monitor builder Draft: Removed event monitor builder Jul 11, 2022
@apazureck apazureck changed the title Draft: Removed event monitor builder [WIP] Event Monitor Options Jul 12, 2022
@apazureck apazureck changed the title [WIP] Event Monitor Options Event Monitor Options Jul 12, 2022
@coveralls
Copy link

coveralls commented Jul 12, 2022

Pull Request Test Coverage Report for Build 2823614045

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 30 of 30 (100.0%) changed or added relevant lines in 3 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+1.0%) to 96.643%

Files with Coverage Reduction New Missed Lines %
Src/FluentAssertions/AssertionExtensions.cs 1 95.68%
Src/FluentAssertions/Events/EventMonitor.cs 4 92.78%
Totals Coverage Status
Change from base Build 2822953981: 1.0%
Covered Lines: 12331
Relevant Lines: 12599

💛 - Coveralls

docs/_pages/eventmonitoring.md Outdated Show resolved Hide resolved
docs/_pages/eventmonitoring.md Outdated Show resolved Hide resolved
docs/_pages/releases.md Outdated Show resolved Hide resolved
Src/FluentAssertions/Events/EventMonitorOptions.cs Outdated Show resolved Hide resolved
Src/FluentAssertions/Events/EventMonitorOptions.cs Outdated Show resolved Hide resolved
Src/FluentAssertions/Events/EventMonitorOptions.cs Outdated Show resolved Hide resolved
Tests/FluentAssertions.Specs/Events/EventMonitorSpecs.cs Outdated Show resolved Hide resolved
Tests/FluentAssertions.Specs/Events/EventMonitorSpecs.cs Outdated Show resolved Hide resolved
Tests/FluentAssertions.Specs/Events/EventMonitorSpecs.cs Outdated Show resolved Hide resolved
Tests/FluentAssertions.Specs/Events/EventMonitorSpecs.cs Outdated Show resolved Hide resolved
@jnyrup
Copy link
Member

jnyrup commented Jul 13, 2022

Btw, I'm AFK for a week from today. I'll continue reviewing once I'm back.

@apazureck
Copy link
Author

Hi,

Quick question: I did changes on my fork and pushed it. Sadly github does not seem to detect them in this PR. Do you know how I can update the PR?

@dennisdoomen
Copy link
Member

Are these not your changes?

image

@apazureck
Copy link
Author

Ah ok... odd. This did not show up, that's why I was a bit confused (hadn't used github in some time...)

Src/FluentAssertions/Events/EventMonitor.cs Outdated Show resolved Hide resolved
Src/FluentAssertions/Events/EventMonitor.cs Outdated Show resolved Hide resolved
Src/FluentAssertions/AssertionExtensions.cs Outdated Show resolved Hide resolved
Src/FluentAssertions/Events/EventMonitor.cs Outdated Show resolved Hide resolved
Tests/FluentAssertions.Specs/Events/EventAssertionSpecs.cs Outdated Show resolved Hide resolved
@jnyrup jnyrup added the feature label Jul 24, 2022
docs/_pages/releases.md Outdated Show resolved Hide resolved
@dennisdoomen dennisdoomen requested a review from jnyrup July 11, 2023 14:06
docs/_pages/eventmonitoring.md Outdated Show resolved Hide resolved
docs/_pages/eventmonitoring.md Outdated Show resolved Hide resolved
@IT-VBFK
Copy link
Contributor

IT-VBFK commented Jul 14, 2023

And API-checks..

@dennisdoomen
Copy link
Member

@apazureck any change you will finish this PR?

@IT-VBFK
Copy link
Contributor

IT-VBFK commented Aug 23, 2023

Would this go into 6.12 if someone finishes it?

@apazureck
Copy link
Author

Hi,

I will fix the stuff until Friday. Thought it was OK and already finished.

@github-actions
Copy link

github-actions bot commented Aug 25, 2023

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

apazureck and others added 2 commits August 25, 2023 21:52
Co-authored-by: IT-VBFK <49762557+IT-VBFK@users.noreply.github.com>
@apazureck apazureck requested a review from jnyrup August 25, 2023 19:54
@IT-VBFK
Copy link
Contributor

IT-VBFK commented Aug 26, 2023

Can you also take care of the remaining qodana issues?

@apazureck
Copy link
Author

Can you also take care of the remaining qodana issues?

Hi,

Yes, I am on it. But the job took so long to run I went to bed yesterday.

public event EventHandler RemoveFailingEvent;
}

[SuppressMessage("Usage", "CA1801:Check Unused Parameter", Justification = "This is on purpose for testing.")]
Copy link
Member

Choose a reason for hiding this comment

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

What parameter is unused?
I didn't get a warning when removing this.

@@ -7,31 +7,13 @@ sidebar:
nav: "sidebar"
---

## 7.0 Alpha 1
Copy link
Member

Choose a reason for hiding this comment

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

Something went wrong here 🙃

Comment on lines 918 to +928
public static IMonitor<T> Monitor<T>(this T eventSource, Func<DateTime> utcNow = null)
{
return new EventMonitor<T>(eventSource, utcNow ?? (() => DateTime.UtcNow));
var options = new EventMonitorOptions();

if (utcNow is not null)
{
options.ConfigureTimestampProvider(utcNow);
}

return new EventMonitor<T>(eventSource, options);
}
Copy link
Member

Choose a reason for hiding this comment

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

Now that we're open to change the existing API, we could remove Func<DateTime> utcNow = null, such that this becomes.

public static IMonitor<T> Monitor<T>(this T eventSource) =>
    new EventMonitor<T>(eventSource, new EventMonitorOptions());

For testing we still have the internal ConfigureTimestampProvider.

@dennisdoomen What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

For testing we still have the internal ConfigureTimestampProvider.

What's that?

Copy link
Member

Choose a reason for hiding this comment

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

EventMonitorOptions.ConfigureTimestampProvider.

In #625 the Func<DateTime> utcNow = null was added, but I suspect it wasn't meant for public use, but merely a necessity for testing.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, you're right. That would no longer be necessary.

Copy link
Author

@apazureck apazureck Aug 28, 2023

Choose a reason for hiding this comment

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

Do you have a workflow for obsolete methods? Should it be tagged obsolete first with the remark it will be removed in the next version? Then people have some time, if they are using it for some reason.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's how we normally do it. But last week, the develop branch is used for the next major version, so we're fine to introduce well-argumented breaking changes in that branch.

Copy link
Author

Choose a reason for hiding this comment

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

I removed the utcnow. I handed down the options to the eventrecorder, as otherwise the late changed reference on the timestamp provider would not be used. The events are subscribed when the constructor is called. Please check if it is conform to your other code and let me know, if it you like another approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

In #625 the Func utcNow = null was added, but I suspect it wasn't meant for public use, but merely a necessity for testing.

We should mention this in the docs as well :)

Co-authored-by: IT-VBFK <49762557+IT-VBFK@users.noreply.github.com>
@dennisdoomen
Copy link
Member

You'll need to rebase your changes on develop to resolve the conflicts.

@IT-VBFK
Copy link
Contributor

IT-VBFK commented Oct 27, 2023

Ping

@apazureck
Copy link
Author

Thanks for the reminder, I thought it was already finished. I can tend to this on the upcoming weekend and hope it will pass then.

@ITaluone
Copy link
Contributor

Pong

@ITaluone
Copy link
Contributor

@apazureck Do you have a plan on finishing this?

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 this pull request may close these issues.

Exceptions in event accessors fail tests when using .Monitor()
6 participants