diff --git a/MiniValidationPlus.sln b/MiniValidationPlus.sln index 577eec1..4dfd465 100644 --- a/MiniValidationPlus.sln +++ b/MiniValidationPlus.sln @@ -8,7 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{751FE268-A79 src\Directory.Build.props = src\Directory.Build.props EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidation", "src\MiniValidation\MiniValidation.csproj", "{60C03B53-10AC-4D37-BA95-7EEFE2FC61FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidationPlus", "src\MiniValidationPlus\MiniValidationPlus.csproj", "{60C03B53-10AC-4D37-BA95-7EEFE2FC61FC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{BF473532-A97B-4CEE-9673-9D4B57D8C1C4}" EndProject @@ -18,7 +18,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Web", "samples\Samp EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4CF82AD1-D050-422E-99D5-454AE28D6A11}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidation.UnitTests", "tests\MiniValidation.UnitTests\MiniValidation.UnitTests.csproj", "{4D247E44-6CF5-4A15-A2D3-09E40753874B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidationPlus.UnitTests", "tests\MiniValidationPlus.UnitTests\MiniValidationPlus.UnitTests.csproj", "{4D247E44-6CF5-4A15-A2D3-09E40753874B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CDE0DB87-BF92-4F36-B305-B73CE116DD45}" ProjectSection(SolutionItems) = preProject @@ -30,7 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ThirdPartyNotices.txt = ThirdPartyNotices.txt EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidation.Benchmarks", "tests\MiniValidation.Benchmarks\MiniValidation.Benchmarks.csproj", "{AFA1AA61-E230-48C8-B12B-6561E2124210}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniValidationPlus.Benchmarks", "tests\MiniValidationPlus.Benchmarks\MiniValidationPlus.Benchmarks.csproj", "{AFA1AA61-E230-48C8-B12B-6561E2124210}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/samples/Samples.Console/Program.cs b/samples/Samples.Console/Program.cs index 0e9212d..7900954 100644 --- a/samples/Samples.Console/Program.cs +++ b/samples/Samples.Console/Program.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations; -using MiniValidation; +using MiniValidationPlus; var nameAndCategory = args.Length > 0 ? args[0] : null; diff --git a/samples/Samples.Console/Samples.Console.csproj b/samples/Samples.Console/Samples.Console.csproj index 92b9057..ccf1e94 100644 --- a/samples/Samples.Console/Samples.Console.csproj +++ b/samples/Samples.Console/Samples.Console.csproj @@ -7,7 +7,7 @@ - + diff --git a/samples/Samples.Web/Program.cs b/samples/Samples.Web/Program.cs index 68bedb0..a202ad6 100644 --- a/samples/Samples.Web/Program.cs +++ b/samples/Samples.Web/Program.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Http.HttpResults; -using MiniValidation; +using MiniValidationPlus; var builder = WebApplication.CreateBuilder(args); diff --git a/samples/Samples.Web/Samples.Web.csproj b/samples/Samples.Web/Samples.Web.csproj index 7190ba0..bb98e6a 100644 --- a/samples/Samples.Web/Samples.Web.csproj +++ b/samples/Samples.Web/Samples.Web.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/MiniValidation/AdaptiveCapacityDictionary.cs b/src/MiniValidationPlus/AdaptiveCapacityDictionary.cs similarity index 99% rename from src/MiniValidation/AdaptiveCapacityDictionary.cs rename to src/MiniValidationPlus/AdaptiveCapacityDictionary.cs index 7777d70..6a40417 100644 --- a/src/MiniValidation/AdaptiveCapacityDictionary.cs +++ b/src/MiniValidationPlus/AdaptiveCapacityDictionary.cs @@ -10,7 +10,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace MiniValidation; +namespace MiniValidationPlus; /// /// An type to hold a small amount of items (10 or less in the common case). diff --git a/src/MiniValidation/IAsyncValidatableObject.cs b/src/MiniValidationPlus/IAsyncValidatableObject.cs similarity index 95% rename from src/MiniValidation/IAsyncValidatableObject.cs rename to src/MiniValidationPlus/IAsyncValidatableObject.cs index 2fde10e..3bedc3f 100644 --- a/src/MiniValidation/IAsyncValidatableObject.cs +++ b/src/MiniValidationPlus/IAsyncValidatableObject.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; -namespace MiniValidation; +namespace MiniValidationPlus; /// /// Provides a way for an object to be validated asynchronously. diff --git a/src/MiniValidation/IsExternalInit.cs b/src/MiniValidationPlus/IsExternalInit.cs similarity index 100% rename from src/MiniValidation/IsExternalInit.cs rename to src/MiniValidationPlus/IsExternalInit.cs diff --git a/src/MiniValidation/MiniValidation.csproj b/src/MiniValidationPlus/MiniValidationPlus.csproj similarity index 100% rename from src/MiniValidation/MiniValidation.csproj rename to src/MiniValidationPlus/MiniValidationPlus.csproj diff --git a/src/MiniValidation/MiniValidator.cs b/src/MiniValidationPlus/MiniValidator.cs similarity index 99% rename from src/MiniValidation/MiniValidator.cs rename to src/MiniValidationPlus/MiniValidator.cs index c1fea2e..5b3dcfd 100644 --- a/src/MiniValidation/MiniValidator.cs +++ b/src/MiniValidationPlus/MiniValidator.cs @@ -7,7 +7,7 @@ using System.Runtime.CompilerServices; using System.Threading.Tasks; -namespace MiniValidation; +namespace MiniValidationPlus; /// /// Contains methods and properties for performing validation operations with on objects whos properties diff --git a/src/MiniValidation/NonNullablePropertyHelper.cs b/src/MiniValidationPlus/NonNullablePropertyHelper.cs similarity index 97% rename from src/MiniValidation/NonNullablePropertyHelper.cs rename to src/MiniValidationPlus/NonNullablePropertyHelper.cs index 6305fea..7475280 100644 --- a/src/MiniValidation/NonNullablePropertyHelper.cs +++ b/src/MiniValidationPlus/NonNullablePropertyHelper.cs @@ -2,7 +2,7 @@ using System.Reflection; -namespace MiniValidation +namespace MiniValidationPlus { /// /// Helper for non-nullable reference types. diff --git a/src/MiniValidation/NotNullWhenAttribute.cs b/src/MiniValidationPlus/NotNullWhenAttribute.cs similarity index 100% rename from src/MiniValidation/NotNullWhenAttribute.cs rename to src/MiniValidationPlus/NotNullWhenAttribute.cs diff --git a/src/MiniValidation/PropertyHelper.cs b/src/MiniValidationPlus/PropertyHelper.cs similarity index 99% rename from src/MiniValidation/PropertyHelper.cs rename to src/MiniValidationPlus/PropertyHelper.cs index 74a1e90..297d3e6 100644 --- a/src/MiniValidation/PropertyHelper.cs +++ b/src/MiniValidationPlus/PropertyHelper.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.Reflection; -namespace MiniValidation +namespace MiniValidationPlus { internal static class PropertyHelper { diff --git a/src/MiniValidation/SkipRecursionAttribute.cs b/src/MiniValidationPlus/SkipRecursionAttribute.cs similarity index 94% rename from src/MiniValidation/SkipRecursionAttribute.cs rename to src/MiniValidationPlus/SkipRecursionAttribute.cs index 3e4287a..5c58462 100644 --- a/src/MiniValidation/SkipRecursionAttribute.cs +++ b/src/MiniValidationPlus/SkipRecursionAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace MiniValidation; +namespace MiniValidationPlus; /// /// Indicates that a property should be ignored during recursive validation when using diff --git a/src/MiniValidation/TypeDetailsCache.cs b/src/MiniValidationPlus/TypeDetailsCache.cs similarity index 98% rename from src/MiniValidation/TypeDetailsCache.cs rename to src/MiniValidationPlus/TypeDetailsCache.cs index 34095b9..d2e0cdd 100644 --- a/src/MiniValidation/TypeDetailsCache.cs +++ b/src/MiniValidationPlus/TypeDetailsCache.cs @@ -9,15 +9,12 @@ using System.Reflection; using System.Threading; -namespace MiniValidation; +namespace MiniValidationPlus; internal class TypeDetailsCache { private static readonly PropertyDetails[] _emptyPropertyDetails = Array.Empty(); private readonly ConcurrentDictionary _cache = new(); -#if NET6_0_OR_GREATER - private NonNullablePropertyHelper _nonNullablePropertyHelper = new(); -#endif public (PropertyDetails[] Properties, bool RequiresAsync) Get(Type? type) { @@ -82,6 +79,10 @@ private void Visit(Type type, HashSet visited, ref bool requiresAsync) var hasPropertiesOfOwnType = false; var hasValidatableProperties = false; +#if NET6_0_OR_GREATER + var nonNullablePropertyHelper = new NonNullablePropertyHelper(); +#endif + foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy)) { if (property.GetIndexParameters().Length > 0) @@ -94,7 +95,7 @@ private void Visit(Type type, HashSet visited, ref bool requiresAsync) validationAttributes ??= Array.Empty(); #if NET6_0_OR_GREATER - var isNonNullableReferenceType = _nonNullablePropertyHelper.IsNonNullableReferenceType(property); + var isNonNullableReferenceType = nonNullablePropertyHelper.IsNonNullableReferenceType(property); #else var isNonNullableReferenceType = false; #endif diff --git a/tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj b/tests/MiniValidationPlus.Benchmarks/MiniValidationPlus.Benchmarks.csproj similarity index 84% rename from tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj rename to tests/MiniValidationPlus.Benchmarks/MiniValidationPlus.Benchmarks.csproj index e142f3c..16c3464 100644 --- a/tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj +++ b/tests/MiniValidationPlus.Benchmarks/MiniValidationPlus.Benchmarks.csproj @@ -14,7 +14,7 @@ - + diff --git a/tests/MiniValidation.Benchmarks/Program.cs b/tests/MiniValidationPlus.Benchmarks/Program.cs similarity index 99% rename from tests/MiniValidation.Benchmarks/Program.cs rename to tests/MiniValidationPlus.Benchmarks/Program.cs index c67b6a5..8af0479 100644 --- a/tests/MiniValidation.Benchmarks/Program.cs +++ b/tests/MiniValidationPlus.Benchmarks/Program.cs @@ -2,7 +2,7 @@ using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Running; -using MiniValidation; +using MiniValidationPlus; BenchmarkRunner.Run(); diff --git a/tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj b/tests/MiniValidationPlus.UnitTests/MiniValidationPlus.UnitTests.csproj similarity index 89% rename from tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj rename to tests/MiniValidationPlus.UnitTests/MiniValidationPlus.UnitTests.csproj index 0e7f43a..8b21214 100644 --- a/tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj +++ b/tests/MiniValidationPlus.UnitTests/MiniValidationPlus.UnitTests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/tests/MiniValidation.UnitTests/NonNullablePropertyHelperTests.cs b/tests/MiniValidationPlus.UnitTests/NonNullablePropertyHelperTests.cs similarity index 98% rename from tests/MiniValidation.UnitTests/NonNullablePropertyHelperTests.cs rename to tests/MiniValidationPlus.UnitTests/NonNullablePropertyHelperTests.cs index 41c22c9..e1bc02b 100644 --- a/tests/MiniValidation.UnitTests/NonNullablePropertyHelperTests.cs +++ b/tests/MiniValidationPlus.UnitTests/NonNullablePropertyHelperTests.cs @@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; -namespace MiniValidation.UnitTests; +namespace MiniValidationPlus.UnitTests; public class NonNullablePropertyHelperTests { diff --git a/tests/MiniValidation.UnitTests/Recursion.cs b/tests/MiniValidationPlus.UnitTests/Recursion.cs similarity index 99% rename from tests/MiniValidation.UnitTests/Recursion.cs rename to tests/MiniValidationPlus.UnitTests/Recursion.cs index 88bfc98..72be3a9 100644 --- a/tests/MiniValidation.UnitTests/Recursion.cs +++ b/tests/MiniValidationPlus.UnitTests/Recursion.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace MiniValidation.UnitTests; +namespace MiniValidationPlus.UnitTests; public class Recursion { diff --git a/tests/MiniValidation.UnitTests/TestTypes.cs b/tests/MiniValidationPlus.UnitTests/TestTypes.cs similarity index 99% rename from tests/MiniValidation.UnitTests/TestTypes.cs rename to tests/MiniValidationPlus.UnitTests/TestTypes.cs index b8d057a..5291b7f 100644 --- a/tests/MiniValidation.UnitTests/TestTypes.cs +++ b/tests/MiniValidationPlus.UnitTests/TestTypes.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace MiniValidation.UnitTests; +namespace MiniValidationPlus.UnitTests; class TestType { diff --git a/tests/MiniValidation.UnitTests/TryValidate.cs b/tests/MiniValidationPlus.UnitTests/TryValidate.cs similarity index 99% rename from tests/MiniValidation.UnitTests/TryValidate.cs rename to tests/MiniValidationPlus.UnitTests/TryValidate.cs index e6fad0d..013551c 100644 --- a/tests/MiniValidation.UnitTests/TryValidate.cs +++ b/tests/MiniValidationPlus.UnitTests/TryValidate.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; -namespace MiniValidation.UnitTests; +namespace MiniValidationPlus.UnitTests; public class TryValidate { diff --git a/tests/MiniValidation.UnitTests/TypeDescriptorExtensions.cs b/tests/MiniValidationPlus.UnitTests/TypeDescriptorExtensions.cs similarity index 98% rename from tests/MiniValidation.UnitTests/TypeDescriptorExtensions.cs rename to tests/MiniValidationPlus.UnitTests/TypeDescriptorExtensions.cs index 325bcf8..108217d 100644 --- a/tests/MiniValidation.UnitTests/TypeDescriptorExtensions.cs +++ b/tests/MiniValidationPlus.UnitTests/TypeDescriptorExtensions.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace MiniValidation.UnitTests +namespace MiniValidationPlus.UnitTests { internal static class TypeDescriptorExtensions {