From fc8642bbb264d436dedde31ac3648537b4d048c1 Mon Sep 17 00:00:00 2001 From: martintmk <103487740+martintmk@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:02:44 +0200 Subject: [PATCH] Hide validation APIs (#1490) --- src/Polly.Core/PublicAPI.Unshipped.txt | 5 ----- src/Polly.Core/ResiliencePipelineBuilderBase.cs | 3 +-- src/Polly.Core/ResilienceValidationContext.cs | 6 +++--- src/Polly.Extensions/Polly.Extensions.csproj | 2 ++ .../TelemetryResiliencePipelineBuilderExtensions.cs | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Polly.Core/PublicAPI.Unshipped.txt b/src/Polly.Core/PublicAPI.Unshipped.txt index 361554e91c8..3c0a29a56b2 100644 --- a/src/Polly.Core/PublicAPI.Unshipped.txt +++ b/src/Polly.Core/PublicAPI.Unshipped.txt @@ -261,7 +261,6 @@ Polly.ResiliencePipelineBuilderBase.Name.get -> string? Polly.ResiliencePipelineBuilderBase.Name.set -> void Polly.ResiliencePipelineBuilderBase.TelemetryListener.get -> Polly.Telemetry.TelemetryListener? Polly.ResiliencePipelineBuilderBase.TelemetryListener.set -> void -Polly.ResiliencePipelineBuilderBase.Validator.get -> System.Action! Polly.ResiliencePipelineBuilderExtensions Polly.ResilienceProperties Polly.ResilienceProperties.GetValue(Polly.ResiliencePropertyKey key, TValue defaultValue) -> TValue @@ -281,10 +280,6 @@ Polly.ResilienceStrategyOptions Polly.ResilienceStrategyOptions.Name.get -> string? Polly.ResilienceStrategyOptions.Name.set -> void Polly.ResilienceStrategyOptions.ResilienceStrategyOptions() -> void -Polly.ResilienceValidationContext -Polly.ResilienceValidationContext.Instance.get -> object! -Polly.ResilienceValidationContext.PrimaryMessage.get -> string! -Polly.ResilienceValidationContext.ResilienceValidationContext(object! instance, string! primaryMessage) -> void Polly.Retry.OnRetryArguments Polly.Retry.OnRetryArguments.AttemptNumber.get -> int Polly.Retry.OnRetryArguments.ExecutionTime.get -> System.TimeSpan diff --git a/src/Polly.Core/ResiliencePipelineBuilderBase.cs b/src/Polly.Core/ResiliencePipelineBuilderBase.cs index 8f1ae2d2ca2..125bc138fb3 100644 --- a/src/Polly.Core/ResiliencePipelineBuilderBase.cs +++ b/src/Polly.Core/ResiliencePipelineBuilderBase.cs @@ -85,8 +85,7 @@ private protected ResiliencePipelineBuilderBase(ResiliencePipelineBuilderBase ot /// The validator should throw when the validated instance is invalid. /// /// Thrown when the attempting to assign to this property. - [EditorBrowsable(EditorBrowsableState.Never)] - public Action Validator { get; private protected set; } = ValidationHelper.ValidateObject; + internal Action Validator { get; private protected set; } = ValidationHelper.ValidateObject; [RequiresUnreferencedCode(Constants.OptionsValidation)] internal void AddStrategyCore(Func factory, ResilienceStrategyOptions options) diff --git a/src/Polly.Core/ResilienceValidationContext.cs b/src/Polly.Core/ResilienceValidationContext.cs index 69cd86e411b..f0637027c62 100644 --- a/src/Polly.Core/ResilienceValidationContext.cs +++ b/src/Polly.Core/ResilienceValidationContext.cs @@ -3,7 +3,7 @@ /// /// The validation context that encapsulates parameters for the validation. /// -public sealed class ResilienceValidationContext +internal sealed class ResilienceValidationContext { /// /// Initializes a new instance of the class. @@ -12,8 +12,8 @@ public sealed class ResilienceValidationContext /// The primary validation message. public ResilienceValidationContext(object instance, string primaryMessage) { - Instance = Guard.NotNull(instance); - PrimaryMessage = Guard.NotNull(primaryMessage); + Instance = Polly.Utils.Guard.NotNull(instance); + PrimaryMessage = Polly.Utils.Guard.NotNull(primaryMessage); } /// diff --git a/src/Polly.Extensions/Polly.Extensions.csproj b/src/Polly.Extensions/Polly.Extensions.csproj index 17657df5f34..ab44edd4655 100644 --- a/src/Polly.Extensions/Polly.Extensions.csproj +++ b/src/Polly.Extensions/Polly.Extensions.csproj @@ -14,9 +14,11 @@ true + + diff --git a/src/Polly.Extensions/Telemetry/TelemetryResiliencePipelineBuilderExtensions.cs b/src/Polly.Extensions/Telemetry/TelemetryResiliencePipelineBuilderExtensions.cs index bf738ff1c8e..09cf5cfa435 100644 --- a/src/Polly.Extensions/Telemetry/TelemetryResiliencePipelineBuilderExtensions.cs +++ b/src/Polly.Extensions/Telemetry/TelemetryResiliencePipelineBuilderExtensions.cs @@ -50,7 +50,7 @@ public static TBuilder ConfigureTelemetry(this TBuilder builder, Telem Guard.NotNull(builder); Guard.NotNull(options); - builder.Validator(new(options, $"The '{nameof(TelemetryOptions)}' are invalid.")); + ValidationHelper.ValidateObject(new(options, $"The '{nameof(TelemetryOptions)}' are invalid.")); builder.TelemetryListener = new TelemetryListenerImpl(options); return builder;