Skip to content
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
5 changes: 4 additions & 1 deletion .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: |
8.0.x
9.0.x
10.0.x
global-json-file: "./global.json"

- name: Restore dependencies
Expand Down
75 changes: 0 additions & 75 deletions MiniValidation.sln

This file was deleted.

22 changes: 22 additions & 0 deletions MiniValidation.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Solution>
<Folder Name="/samples/">
<Project Path="samples/Samples.Console/Samples.Console.csproj" />
<Project Path="samples/Samples.Web/Samples.Web.csproj" />
</Folder>
<Folder Name="/Solution Items/">
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
<File Path="global.json" />
<File Path="LICENSE" />
<File Path="README.md" />
<File Path="ThirdPartyNotices.txt" />
</Folder>
<Folder Name="/src/">
<File Path="src/Directory.Build.props" />
<Project Path="src/MiniValidation/MiniValidation.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj" />
<Project Path="tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj" />
</Folder>
</Solution>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "10.0.100",
"rollForward": "latestFeature"
}
}
}
2 changes: 1 addition & 1 deletion samples/Samples.Console/Samples.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/Samples.Web/Samples.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MiniValidation/MiniValidation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A minimalist validation library built atop the existing validation features in .NET's `System.ComponentModel.DataAnnotations` namespace.</Description>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<PackageTags>ComponentModel DataAnnotations validation</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>10.0</LangVersion>
Expand Down
20 changes: 18 additions & 2 deletions src/MiniValidation/TypeDetailsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,35 @@ internal class TypeDetailsCache
private static readonly PropertyDetails[] _emptyPropertyDetails = Array.Empty<PropertyDetails>();
private readonly ConcurrentDictionary<Type, (PropertyDetails[] Properties, bool RequiresAsync)> _cache = new();

public TypeDetailsCache()
{
TypeDescriptor.Refreshed += args =>
{
if (args.TypeChanged is { } type)
{
_cache.TryRemove(type, out _);
}
else
{
_cache.Clear();
}
};
}

public (PropertyDetails[] Properties, bool RequiresAsync) Get(Type? type)
{
if (type is null)
{
return (_emptyPropertyDetails, false);
}

if (!_cache.ContainsKey(type))
(PropertyDetails[] Properties, bool RequiresAsync) details;
while (!_cache.TryGetValue(type, out details))
{
Visit(type);
}

return _cache[type];
return details;
}

private void Visit(Type type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">net471;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">net471;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Loading