From dbaff1df3f0b2a64e1f77f69eb6938c68be915f9 Mon Sep 17 00:00:00 2001 From: Dan Espinosa <30415120+danespinosa@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:41:31 -0800 Subject: [PATCH] validate that providers are > 0 to provide clear error when using Diagnostics Client (#4411) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit validate that providers are > 0 otherwise START Failed 0x80131384 get…s thrown and it's not clear what the issue is. The current behavior when an empty list of providers is provided is to throw START Failed 0x80131384 (BadEncoding) and that doesn't make it very clear about what the issue is. This PR proposes validating the number of providers so developers know that they should be providing 1 provider at least. Before: image After: image Co-authored-by: Daniel Espinosa --- .../DiagnosticsClient/EventPipeSessionConfiguration.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSessionConfiguration.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSessionConfiguration.cs index d4884b650..8f3f3b2b7 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSessionConfiguration.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSessionConfiguration.cs @@ -53,11 +53,16 @@ namespace Microsoft.Diagnostics.NETCore.Client throw new ArgumentNullException(nameof(providers)); }; + _providers = new List(providers); + if (_providers.Count == 0) + { + throw new ArgumentException("At least one provider must be specified."); + }; + CircularBufferSizeInMB = circularBufferSizeMB; Format = format; RequestRundown = requestRundown; RequestStackwalk = requestStackwalk; - _providers = new List(providers); } /// -- 2.34.1