From: Sung Yoon Whang Date: Tue, 30 Apr 2019 09:14:06 +0000 (-0700) Subject: Ignore any provider specified via --profile option if they are already specified... X-Git-Tag: submit/tizen/20190813.035844~6^2^2~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35dcb6de9e8296121e80654c83338fa09b6e0a6f;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Ignore any provider specified via --profile option if they are already specified with --providers option (#224) --- diff --git a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs index 48316f947..4361d5b64 100644 --- a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs +++ b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs @@ -45,8 +45,35 @@ namespace Microsoft.Diagnostics.Tools.Trace throw new ArgumentException($"Invalid profile name: {profile}"); var providerCollection = Extensions.ToProviders(providers); + var profileProviders = new List(); + + // If user defined a different key/level on the same provider via --providers option that was specified via --profile option, + // --providers option takes precedence. Go through the list of providers specified and only add it if it wasn't specified + // via --providers options. if (selectedProfile.Providers != null) - providerCollection.AddRange(selectedProfile.Providers); + { + foreach (Provider selectedProfileProvider in selectedProfile.Providers) + { + bool shouldAdd = true; + + foreach (Provider providerCollectionProvider in providerCollection) + { + if (providerCollectionProvider.Name.Equals(selectedProfileProvider.Name)) + { + shouldAdd = false; + break; + } + } + + if (shouldAdd) + { + profileProviders.Add(selectedProfileProvider); + } + } + } + + providerCollection.AddRange(profileProviders); + if (providerCollection.Count <= 0) throw new ArgumentException("No providers were specified to start a trace.");