Skip to content

Commit 7d09528

Browse files
committed
net8-10
1 parent 078f106 commit 7d09528

File tree

10 files changed

+70
-16
lines changed

10 files changed

+70
-16
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<ItemGroup>
3-
<PackageVersion Include="BenchmarkDotNet" Version="0.15.4" />
3+
<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
44
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
55
<PrivateAssets>all</PrivateAssets>
66
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

benchmarks/HydraScript.Benchmarks/GeneratedRegexContainer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ namespace HydraScript.Benchmarks;
66

77
internal sealed partial class GeneratedRegexContainer : IGeneratedRegexContainer
88
{
9+
#if NET10_0
910
[GeneratedRegex(PatternContainer.Value, RegexOptions.Compiled)]
1011
public static partial Regex Regex { get; }
12+
#else
13+
[GeneratedRegex(PatternContainer.Value, RegexOptions.Compiled)]
14+
public static partial Regex GetRegex();
15+
16+
public static Regex Regex { get; } = GetRegex();
17+
#endif
1118
}

benchmarks/HydraScript.Benchmarks/InvokeBenchmark.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
using System.Diagnostics.CodeAnalysis;
21
using BenchmarkDotNet.Attributes;
32
using BenchmarkDotNet.Jobs;
4-
using BenchmarkDotNet.Running;
5-
using HydraScript.Benchmarks;
63
using HydraScript.Infrastructure;
74
using Microsoft.Extensions.DependencyInjection;
85
using Microsoft.Extensions.Logging;
96
using Microsoft.Extensions.Logging.Abstractions;
107
using Microsoft.Extensions.Options;
118

12-
[assembly: ExcludeFromCodeCoverage]
9+
namespace HydraScript.Benchmarks;
1310

14-
BenchmarkRunner.Run<InvokeBenchmark>();
15-
16-
[SimpleJob(RuntimeMoniker.Net90)]
17-
[SimpleJob(RuntimeMoniker.NativeAot90)]
11+
[SimpleJob(RuntimeMoniker.Net80)]
12+
[SimpleJob(RuntimeMoniker.Net10_0, baseline: true)]
1813
[MemoryDiagnoser]
1914
public class InvokeBenchmark
2015
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using BenchmarkDotNet.Running;
3+
using HydraScript.Benchmarks;
4+
5+
[assembly: ExcludeFromCodeCoverage]
6+
7+
BenchmarkRunner.Run<InvokeBenchmark>();

src/Application/HydraScript.Application.StaticAnalysis/Impl/FunctionWithUndefinedReturnStorage.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,59 @@ namespace HydraScript.Application.StaticAnalysis.Impl;
66

77
internal class FunctionWithUndefinedReturnStorage : IFunctionWithUndefinedReturnStorage
88
{
9+
#if NET10_0
910
private readonly OrderedDictionary<FunctionSymbolId, FunctionDeclaration> _declarations = [];
11+
#else
12+
private readonly Dictionary<FunctionSymbolId, FunctionDeclaration> _declarations = [];
13+
private readonly Dictionary<FunctionSymbolId, int> _keysWithOrder = [];
14+
#endif
1015

11-
public void Save(FunctionSymbol symbol, FunctionDeclaration declaration) =>
16+
public void Save(FunctionSymbol symbol, FunctionDeclaration declaration)
17+
{
1218
_declarations[symbol.Id] = declaration;
19+
#if NET10_0
20+
#else
21+
_keysWithOrder[symbol.Id] = _declarations.Count;
22+
#endif
23+
}
1324

1425
public FunctionDeclaration Get(FunctionSymbol symbol)
1526
{
1627
if (!_declarations.Remove(symbol.Id, out var declaration))
1728
throw new InvalidOperationException(message: $"Cannot get {symbol} that has not been saved");
18-
29+
#if NET10_0
30+
#else
31+
_keysWithOrder.Remove(symbol.Id);
32+
#endif
1933
return declaration;
2034
}
2135

22-
public void RemoveIfPresent(FunctionSymbol symbol) => _declarations.Remove(symbol.Id);
36+
public void RemoveIfPresent(FunctionSymbol symbol)
37+
{
38+
_declarations.Remove(symbol.Id);
39+
#if NET10_0
40+
#else
41+
_keysWithOrder.Remove(symbol.Id);
42+
#endif
43+
}
2344

2445
public IEnumerable<FunctionDeclaration> Flush()
2546
{
47+
#if NET10_0
2648
IReadOnlyList<FunctionSymbolId> keys = _declarations.Keys;
2749
while (keys.Count > 0)
2850
{
2951
yield return _declarations[keys[0]];
3052
_declarations.Remove(keys[0]);
3153
}
54+
#else
55+
return _declarations.OrderBy(kvp => _keysWithOrder[kvp.Key])
56+
.Select(x =>
57+
{
58+
_declarations.Remove(x.Key);
59+
_keysWithOrder.Remove(x.Key);
60+
return x.Value;
61+
});
62+
#endif
3263
}
3364
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
</PropertyGroup>
66

77
</Project>

src/HydraScript/GeneratedRegexContainer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ namespace HydraScript;
66

77
public sealed partial class GeneratedRegexContainer : IGeneratedRegexContainer
88
{
9+
#if NET10_0
910
[GeneratedRegex(PatternContainer.Value, RegexOptions.Compiled)]
1011
public static partial Regex Regex { get; }
12+
#else
13+
[GeneratedRegex(PatternContainer.Value, RegexOptions.Compiled)]
14+
public static partial Regex GetRegex();
15+
16+
public static Regex Regex { get; } = GetRegex();
17+
#endif
1118
}

src/Infrastructure/HydraScript.Infrastructure.LexerRegexGenerator/HydraScript.Infrastructure.LexerRegexGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
55
<IsRoslynComponent>true</IsRoslynComponent>
6-
<TargetFramework>netstandard2.0</TargetFramework>
6+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
77
</PropertyGroup>
88

99
<ItemGroup>

tests/HydraScript.UnitTests/Domain/FrontEnd/DummyContainer.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ namespace HydraScript.UnitTests.Domain.FrontEnd;
55

66
public partial class DummyContainer : IGeneratedRegexContainer
77
{
8-
[GeneratedRegex(TokenInput.Pattern)]
8+
#if NET10_0
9+
[GeneratedRegex(TokenInput.Pattern, RegexOptions.Compiled)]
910
public static partial Regex Regex { get; }
11+
#else
12+
[GeneratedRegex(TokenInput.Pattern, RegexOptions.Compiled)]
13+
public static partial Regex GetRegex();
14+
15+
public static Regex Regex { get; } = GetRegex();
16+
#endif
1017
}

0 commit comments

Comments
 (0)