|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using Microsoft.AspNetCore.Http.Validation; |
| 5 | +using Microsoft.AspNetCore.Http.Validation.Generated; |
| 6 | +using Microsoft.Extensions.DependencyInjection; |
| 7 | +using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options; |
| 8 | +using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions; |
| 9 | +using Microsoft.Diagnostics.Monitoring.WebApi; |
| 10 | +using Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem; |
| 11 | + |
| 12 | +namespace Microsoft.Diagnostics.Tools.Monitor |
| 13 | +{ |
| 14 | + // The Validation source generator doesn't run for libraries that don't call AddValidation, |
| 15 | + // so we can't generate IValidatableInfo by using [ValidatableType] directly on types defined |
| 16 | + // in ProjectReferences. This is a workaround to force the generator running in this project to |
| 17 | + // generate IValidatableInfo for the referenced types. The containing class is not used otherwise. |
| 18 | + [ValidatableType] |
| 19 | + internal sealed class TestValidatableTypes |
| 20 | + { |
| 21 | + public required CollectionRuleOptions CollectionRuleOptions { get; init; } |
| 22 | + |
| 23 | + public required ExecuteOptions ExecuteOptions { get; init; } |
| 24 | + |
| 25 | + public required SetEnvironmentVariableOptions SetEnvironmentVariableOptions { get; init; } |
| 26 | + |
| 27 | + public required GetEnvironmentVariableOptions GetEnvironmentVariableOptions { get; init; } |
| 28 | + |
| 29 | + public required CollectTraceOptions CollectTraceOptions { get; init; } |
| 30 | + |
| 31 | + public required GlobalCounterOptions GlobalCounterOptions { get; init; } |
| 32 | + |
| 33 | + public required CollectGCDumpOptions CollectGCDumpOptions { get; init; } |
| 34 | + |
| 35 | + public required CollectLiveMetricsOptions CollectLiveMetricsOptions { get; init; } |
| 36 | + |
| 37 | + public required RootOptions RootOptions { get; init; } |
| 38 | + |
| 39 | + public required FileSystemEgressProviderOptions FileSystemEgressProviderOptions { get; init; } |
| 40 | + |
| 41 | + public required CollectDumpOptions CollectDumpOptions { get; init; } |
| 42 | + |
| 43 | + public required LoadProfilerOptions LoadProfilerOptions { get; init; } |
| 44 | + |
| 45 | + public static void AddValidation(IServiceCollection services) |
| 46 | + { |
| 47 | + GeneratedServiceCollectionExtensions.AddValidation(services); |
| 48 | + // services.AddValidation(); |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments