diff --git a/src/Libraries/L1/BaseOptions.cs b/src/Libraries/L1/BaseOptions.cs new file mode 100644 index 00000000000..112196235ac --- /dev/null +++ b/src/Libraries/L1/BaseOptions.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ValidationTest; + +public class BaseOptions +{ + [Timeout] + public int Prop1 { get; set; } +} diff --git a/src/Libraries/L1/BaseOptionsValidator.cs b/src/Libraries/L1/BaseOptionsValidator.cs new file mode 100644 index 00000000000..91a84a8583e --- /dev/null +++ b/src/Libraries/L1/BaseOptionsValidator.cs @@ -0,0 +1,12 @@ +// 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; +using Microsoft.Extensions.Options.Validation; + +namespace ValidationTest; + +[OptionsValidator] +internal sealed partial class BaseOptionsValidator : IValidateOptions +{ +} diff --git a/src/Libraries/L1/L1.csproj b/src/Libraries/L1/L1.csproj new file mode 100644 index 00000000000..08ca842d5de --- /dev/null +++ b/src/Libraries/L1/L1.csproj @@ -0,0 +1,15 @@ + + + true + true + + + + + + + + + + + diff --git a/src/Libraries/L1/L1.json b/src/Libraries/L1/L1.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/Libraries/L1/TimeoutAttribute.cs b/src/Libraries/L1/TimeoutAttribute.cs new file mode 100644 index 00000000000..ffc0abf255d --- /dev/null +++ b/src/Libraries/L1/TimeoutAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.ComponentModel.DataAnnotations; + +namespace ValidationTest; + +[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] +internal sealed class TimeoutAttribute : ValidationAttribute +{ + protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) + { + return ValidationResult.Success!; + } +} diff --git a/src/Libraries/L2/ExtOptions.cs b/src/Libraries/L2/ExtOptions.cs new file mode 100644 index 00000000000..297652e2b04 --- /dev/null +++ b/src/Libraries/L2/ExtOptions.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel.DataAnnotations; + +namespace ValidationTest; + +public class ExtOptions : BaseOptions +{ + [Range(0, 10)] + public int Prop2 { get; set; } +} diff --git a/src/Libraries/L2/ExtOptionsValidator.cs b/src/Libraries/L2/ExtOptionsValidator.cs new file mode 100644 index 00000000000..2ba0b917f23 --- /dev/null +++ b/src/Libraries/L2/ExtOptionsValidator.cs @@ -0,0 +1,12 @@ +// 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; +using Microsoft.Extensions.Options.Validation; + +namespace ValidationTest; + +[OptionsValidator] +internal sealed partial class ExtOptionsValidator : IValidateOptions +{ +} diff --git a/src/Libraries/L2/L2.csproj b/src/Libraries/L2/L2.csproj new file mode 100644 index 00000000000..57ce7f07463 --- /dev/null +++ b/src/Libraries/L2/L2.csproj @@ -0,0 +1,10 @@ + + + true + true + + + + + + diff --git a/src/Libraries/L2/L2.json b/src/Libraries/L2/L2.json new file mode 100644 index 00000000000..e69de29bb2d