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

Add DiagnosticsClientConnector to support creating a DiagnosticsClient from a diagnostic port #5073

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xoofx
Copy link
Member

@xoofx xoofx commented Dec 2, 2024

Followup of #5070 that introduced a non-viable approach (Comment #5070 (comment))

This PR adds DiagnosticsClientConnector that is IAsyncDisposable and offers the method FromDiagnosticPort.

@xoofx
Copy link
Member Author

xoofx commented Dec 2, 2024

I will try to add a test if this fix is accepted.

Question: Where should I add it in Microsoft.Diagnostics.NETCore.Client.UnitTests, new class or existing test?

@jander-msft
Copy link
Member

This introduces a breaking change at compile time for those that have the CA2000 or CA2213 rules enabled. These are commonly enabled. This change would force everyone who have these rules enabled to dispose the client, regardless of if the disposal is really necessary.

This also will be problematic for tools that use the ReverseDiagnosticServer for more than one connection or more than one process at the same time e.g. dotnet-monitor.

IIRC, the original intent of the client is for it to be transiently used and should not manage the state of other components. It should be useable and then "tossable" without affecting the state of the server component.

Finally, I'm not a proponent of having unused files within classes like this because it creates ambiguity throughout the class as to whether it being null or not is valid for invocations of any of the methods. It will potentially lead to other bugs down the road as more changes are added that may depend on the field.

I would recommend revisiting the design of the convenience method that was added rather than changing the behavior of the client. I'm not on the .NET Diagnostics team, so I don't have the ultimate say on these changes. However, I do work on a partner team that relies heavily on this library for the tools that we build e.g. dotnet-monitor.

@xoofx
Copy link
Member Author

xoofx commented Dec 2, 2024

I would recommend revisiting the design of the convenience method that was added rather than changing the behavior of the client. I'm not on the .NET Diagnostics team, so I don't have the ultimate say on these changes. However, I do work on a partner team that relies heavily on this library for the tools that we build e.g. dotnet-monitor.

So, with your knowledge, based on your usage, and if you didn't have access to the internals, what would you propose? 🙂

@xoofx xoofx force-pushed the fix-diagnostic-port branch from 6a918b2 to b5046ef Compare December 2, 2024 21:47
@xoofx xoofx changed the title Add DisposeAsync to DiagnosticClient to support disposing the reversed server Add DiagnosticClientConnector to support creating a DiagnosticClient from a diagnostic port Dec 2, 2024
@xoofx xoofx changed the title Add DiagnosticClientConnector to support creating a DiagnosticClient from a diagnostic port Add DiagnosticsClientConnector to support creating a DiagnosticsClient from a diagnostic port Dec 2, 2024
@xoofx
Copy link
Member Author

xoofx commented Dec 2, 2024

I have changed the design from the original PR and added an entire new class DiagnosticsClientConnector separate from DiagnosticsClient that mitigate the issue with the disposal of the reversed server.

@mikem8361
Copy link
Member

@jander-msft What do you think of his last changes?

Copy link
Member

@hoyosjs hoyosjs left a comment

Choose a reason for hiding this comment

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

This makes more sense to me. It decouples reverse server lifetime from the client as @jander-msft had requested.

@hoyosjs
Copy link
Member

hoyosjs commented Dec 12, 2024

@jander-msft do you have any more feedback? Otherwise I'll get this in this week

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.

4 participants