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

IDISP0004 false positive for DiagnosticSource.StartActivity #484

Open
Bouke opened this issue Apr 20, 2023 · 0 comments
Open

IDISP0004 false positive for DiagnosticSource.StartActivity #484

Bouke opened this issue Apr 20, 2023 · 0 comments

Comments

@Bouke
Copy link
Contributor

Bouke commented Apr 20, 2023

DiagnosticSource.StartActivity returns the activity instance that was passed as an argument. The analyzer suggests to also dispose the returned activity, however it is already being disposed with the using on the first line:

using var activity = new Activity("Do work");
activity.SetParentId(parentId);diagnosticSource.StartActivity(activity, new { work });

However with a pattern like the following, we should still raise IDISP0004 as expected:

diagnosticSource.StartActivity(new Activity("Do work"), new { work });
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

No branches or pull requests

1 participant