Achieves 100% XML doc coverage on non-trivial types with CS1591 enforcement via Directory.Build.props. Coverage by project: - Butter: from 6.5% to 100% (DTOs, enums, MIME types) - Lactose: from ~28% to 100% (controllers, services, repos, jobs, models) - MilkStream.Client: from ~29% to 100% (all frontend services) Uses <inheritdoc /> on repository implementations (interfaces already documented) and full <summary>/<param>/<returns> tags elsewhere. Enums include member-level docs.
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using Microsoft.Extensions.Options;
|
|
|
|
namespace Lactose.Configuration;
|
|
|
|
/// <summary>
|
|
/// Configures <see cref="SignKeyConfiguration"/> from the application configuration.
|
|
/// </summary>
|
|
public class SignKeyProvider(IConfiguration configuration) : IConfigureOptions<SignKeyConfiguration> {
|
|
|
|
const string SectionName = SignKeyConfiguration.SectionName+":Key";
|
|
/// <inheritdoc />
|
|
public void Configure(SignKeyConfiguration options) {
|
|
|
|
if (configuration[SectionName]!.Length <= 32 ) {
|
|
throw new Exception("SignKey:Key is not 256 bits long");
|
|
}
|
|
options.Key = configuration[SectionName] ?? throw new Exception("SignKey:Key is not set");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a configured <see cref="SignKeyConfiguration"/> instance.
|
|
/// </summary>
|
|
/// <returns>The configured signing key configuration.</returns>
|
|
public SignKeyConfiguration Get() {
|
|
var options = new SignKeyConfiguration();
|
|
this.Configure(options);
|
|
return options;
|
|
}
|
|
}
|