Skip to content

Commit cb476b5

Browse files
Update test targets to supported .NET versions (#85)
* Update test targets to supported .NET versions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refresh TypeDescriptor cache when attributes change Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Migrate solution file to slnx Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 708584e commit cb476b5

10 files changed

Lines changed: 51 additions & 87 deletions

File tree

.github/workflows/_build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
- name: Install .NET SDK
2020
uses: actions/setup-dotnet@v4
2121
with:
22-
dotnet-version: 6.0.x
22+
dotnet-version: |
23+
8.0.x
24+
9.0.x
25+
10.0.x
2326
global-json-file: "./global.json"
2427

2528
- name: Restore dependencies

MiniValidation.sln

Lines changed: 0 additions & 75 deletions
This file was deleted.

MiniValidation.slnx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Solution>
2+
<Folder Name="/samples/">
3+
<Project Path="samples/Samples.Console/Samples.Console.csproj" />
4+
<Project Path="samples/Samples.Web/Samples.Web.csproj" />
5+
</Folder>
6+
<Folder Name="/Solution Items/">
7+
<File Path="Directory.Build.props" />
8+
<File Path="Directory.Packages.props" />
9+
<File Path="global.json" />
10+
<File Path="LICENSE" />
11+
<File Path="README.md" />
12+
<File Path="ThirdPartyNotices.txt" />
13+
</Folder>
14+
<Folder Name="/src/">
15+
<File Path="src/Directory.Build.props" />
16+
<Project Path="src/MiniValidation/MiniValidation.csproj" />
17+
</Folder>
18+
<Folder Name="/tests/">
19+
<Project Path="tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj" />
20+
<Project Path="tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj" />
21+
</Folder>
22+
</Solution>

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "10.0.100",
44
"rollForward": "latestFeature"
55
}
6-
}
6+
}

samples/Samples.Console/Samples.Console.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

samples/Samples.Web/Samples.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>

src/MiniValidation/MiniValidation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>A minimalist validation library built atop the existing validation features in .NET's `System.ComponentModel.DataAnnotations` namespace.</Description>
5-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
5+
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
66
<PackageTags>ComponentModel DataAnnotations validation</PackageTags>
77
<PackageReadmeFile>README.md</PackageReadmeFile>
88
<LangVersion>10.0</LangVersion>

src/MiniValidation/TypeDetailsCache.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,35 @@ internal class TypeDetailsCache
1414
private static readonly PropertyDetails[] _emptyPropertyDetails = Array.Empty<PropertyDetails>();
1515
private readonly ConcurrentDictionary<Type, (PropertyDetails[] Properties, bool RequiresAsync)> _cache = new();
1616

17+
public TypeDetailsCache()
18+
{
19+
TypeDescriptor.Refreshed += args =>
20+
{
21+
if (args.TypeChanged is { } type)
22+
{
23+
_cache.TryRemove(type, out _);
24+
}
25+
else
26+
{
27+
_cache.Clear();
28+
}
29+
};
30+
}
31+
1732
public (PropertyDetails[] Properties, bool RequiresAsync) Get(Type? type)
1833
{
1934
if (type is null)
2035
{
2136
return (_emptyPropertyDetails, false);
2237
}
2338

24-
if (!_cache.ContainsKey(type))
39+
(PropertyDetails[] Properties, bool RequiresAsync) details;
40+
while (!_cache.TryGetValue(type, out details))
2541
{
2642
Visit(type);
2743
}
2844

29-
return _cache[type];
45+
return details;
3046
}
3147

3248
private void Visit(Type type)

tests/MiniValidation.Benchmarks/MiniValidation.Benchmarks.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
6-
<TargetFrameworks Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">net471;net6.0;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
76
<ImplicitUsings>enable</ImplicitUsings>
87
<Nullable>enable</Nullable>
98
<LangVersion>10</LangVersion>

tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
5-
<TargetFrameworks Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">net471;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
65
<LangVersion>10.0</LangVersion>
76
<Nullable>enable</Nullable>
87
<ImplicitUsings>enable</ImplicitUsings>

0 commit comments

Comments
 (0)