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 missing option validation #4260

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Options;

namespace Microsoft.Extensions.Telemetry.Latency;

[OptionsValidator]
internal sealed partial class LatencyContextRegistrationOptionsValidator : IValidateOptions<LatencyContextRegistrationOptions>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options.Validation;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.Telemetry.Latency;
Expand Down Expand Up @@ -79,7 +80,7 @@ private static void CheckNames(string[] names)

private static void ConfigureOption(this IServiceCollection services, Action<LatencyContextRegistrationOptions> action)
{
_ = services.AddOptions<LatencyContextRegistrationOptions>();
_ = services.AddValidatedOptions<LatencyContextRegistrationOptions, LatencyContextRegistrationOptionsValidator>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the options type to be public at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

I asked Ananth for feedback on that. Maybe we should hide it, we'll see what he ssys.

Copy link
Member Author

Choose a reason for hiding this comment

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

He's OOF, so it'll take a while. We can address this in a separate PR.

_ = services.Configure(action);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ToBeRemoved\Options.ValidateOnStart\Options.ValidateOnStart.csproj" />
joperezr marked this conversation as resolved.
Show resolved Hide resolved
<ProjectReference Include="..\Microsoft.Extensions.Compliance.Abstractions\Microsoft.Extensions.Compliance.Abstractions.csproj" />
</ItemGroup>

Expand Down Expand Up @@ -52,6 +53,6 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleToTest Include="$(AssemblyName).Tests"/>
<InternalsVisibleToTest Include="$(AssemblyName).Tests" />
</ItemGroup>
</Project>
Loading