Skip to content

Commit 814b684

Browse files
committed
Cleanup build
1 parent ef5794d commit 814b684

File tree

20 files changed

+265
-191
lines changed

20 files changed

+265
-191
lines changed

benchmarks/Foundatio.LuceneQueryParser.Benchmarks/Benchmarks.cs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BenchmarkDotNet.Attributes;
22
using Foundatio.LuceneQueryParser.Ast;
3-
using Foundatio.LuceneQueryParser.Visitors;
3+
using Foundatio.Parsers.LuceneQueries.Visitors;
4+
using OldParser = Foundatio.Parsers.LuceneQueries;
45

56
namespace Foundatio.LuceneQueryParser.Benchmarks;
67

@@ -23,6 +24,13 @@ public class Benchmarks
2324
private QueryStringBuilder _builder = null!;
2425
private QueryNodeVisitor _visitor = null!;
2526

27+
// Foundatio.Parsers objects for comparison
28+
private OldParser.LuceneQueryParser _oldParser = null!;
29+
private OldParser.Nodes.IQueryNode _oldSimpleNode = null!;
30+
private OldParser.Nodes.IQueryNode _oldFieldNode = null!;
31+
private OldParser.Nodes.IQueryNode _oldComplexNode = null!;
32+
private GenerateQueryVisitor _oldGenerateVisitor = null!;
33+
2634
[GlobalSetup]
2735
public void Setup()
2836
{
@@ -31,6 +39,13 @@ public void Setup()
3139
_complexDoc = LuceneQuery.Parse(ComplexQuery).Document;
3240
_builder = new QueryStringBuilder(256);
3341
_visitor = new NoOpVisitor();
42+
43+
// Setup Foundatio.Parsers
44+
_oldParser = new OldParser.LuceneQueryParser();
45+
_oldSimpleNode = _oldParser.Parse(SimpleQuery);
46+
_oldFieldNode = _oldParser.Parse(FieldQuery);
47+
_oldComplexNode = _oldParser.Parse(ComplexQuery);
48+
_oldGenerateVisitor = new GenerateQueryVisitor();
3449
}
3550

3651
#region Parsing
@@ -44,6 +59,15 @@ public void Setup()
4459
[Benchmark]
4560
public LuceneParseResult Parse_Complex() => LuceneQuery.Parse(ComplexQuery);
4661

62+
[Benchmark(Baseline = true)]
63+
public OldParser.Nodes.IQueryNode Parse_Simple_Old() => _oldParser.Parse(SimpleQuery);
64+
65+
[Benchmark]
66+
public OldParser.Nodes.IQueryNode Parse_Field_Old() => _oldParser.Parse(FieldQuery);
67+
68+
[Benchmark]
69+
public OldParser.Nodes.IQueryNode Parse_Complex_Old() => _oldParser.Parse(ComplexQuery);
70+
4771
#endregion
4872

4973
#region Query String Building
@@ -54,6 +78,12 @@ public void Setup()
5478
[Benchmark]
5579
public string Build_Complex() => _builder.Visit(_complexDoc);
5680

81+
[Benchmark]
82+
public async Task<string> Build_Simple_Old() => await _oldGenerateVisitor.AcceptAsync(_oldSimpleNode, null);
83+
84+
[Benchmark]
85+
public async Task<string> Build_Complex_Old() => await _oldGenerateVisitor.AcceptAsync(_oldComplexNode, null);
86+
5787
#endregion
5888

5989
#region Round-Trip (Parse + Build)
@@ -72,14 +102,28 @@ public string RoundTrip_Complex()
72102
return _builder.Visit(result.Document);
73103
}
74104

105+
[Benchmark]
106+
public async Task<string> RoundTrip_Field_Old()
107+
{
108+
var node = _oldParser.Parse(FieldQuery);
109+
return await _oldGenerateVisitor.AcceptAsync(node, null);
110+
}
111+
112+
[Benchmark]
113+
public async Task<string> RoundTrip_Complex_Old()
114+
{
115+
var node = _oldParser.Parse(ComplexQuery);
116+
return await _oldGenerateVisitor.AcceptAsync(node, null);
117+
}
118+
75119
#endregion
76120

77121
#region Visitor Traversal
78122

79123
[Benchmark]
80124
public async Task<QueryNode> Visit_Complex()
81125
{
82-
var context = new QueryVisitorContext();
126+
var context = new Foundatio.LuceneQueryParser.Visitors.QueryVisitorContext();
83127
return await _visitor.AcceptAsync(_complexDoc, context);
84128
}
85129

benchmarks/Foundatio.LuceneQueryParser.Benchmarks/Foundatio.LuceneQueryParser.Benchmarks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
13+
<PackageReference Include="Foundatio.Parsers.LuceneQueries" Version="7.*" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

build/Foundatio.snk

596 Bytes
Binary file not shown.

build/common.props

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
5+
<Product>Foundatio</Product>
6+
<Description>Pluggable foundation blocks for building distributed apps.</Description>
7+
<PackageProjectUrl>https://github.com/FoundatioFx/Foundatio.LuceneQueryParser</PackageProjectUrl>
8+
<PackageReleaseNotes>https://github.com/FoundatioFx/Foundatio.LuceneQueryParser/releases</PackageReleaseNotes>
9+
<PackageTags>Queue;Messaging;Message;Bus;ServiceBus;Locking;Lock;Distributed;File;Storage;Blob;Jobs;Metrics;Stats;Azure;Redis;StatsD;Amazon;AWS;S3;broker;Logging;Log</PackageTags>
10+
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
11+
<MinVerTagPrefix>v</MinVerTagPrefix>
12+
13+
<Copyright>Copyright (c) 2025 Foundatio. All rights reserved.</Copyright>
14+
<Authors>FoundatioFx</Authors>
15+
<ImplicitUsings>enable</ImplicitUsings>
16+
<Nullable>enable</Nullable>
17+
<NoWarn>$(NoWarn);CS1591;NU1701</NoWarn>
18+
<WarningsAsErrors>true</WarningsAsErrors>
19+
<LangVersion>latest</LangVersion>
20+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
21+
<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
22+
<PackageIcon>foundatio-icon.png</PackageIcon>
23+
<PackageReadmeFile>README.md</PackageReadmeFile>
24+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
25+
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
26+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
28+
<DebugType>embedded</DebugType>
29+
</PropertyGroup>
30+
31+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
32+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
33+
</PropertyGroup>
34+
35+
<PropertyGroup Label="Signing">
36+
<SignAssembly>true</SignAssembly>
37+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Foundatio.snk</AssemblyOriginatorKeyFile>
38+
</PropertyGroup>
39+
40+
<ItemGroup>
41+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
42+
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
43+
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All" />
44+
</ItemGroup>
45+
46+
<ItemGroup>
47+
<None Include="../../build/foundatio-icon.png" Pack="true" PackagePath="$(PackageIcon)" />
48+
<None Include="../../README.md" Pack="true" PackagePath="$(PackageReadmeFile)" />
49+
</ItemGroup>
50+
51+
</Project>

build/foundatio-icon.png

21.8 KB
Loading

src/Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="..\build\common.props" />
3+
</Project>

src/Foundatio.LuceneQueryParser.EntityFramework/Foundatio.LuceneQueryParser.EntityFramework.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
8-
93
<ItemGroup>
104
<ProjectReference Include="..\Foundatio.LuceneQueryParser\Foundatio.LuceneQueryParser.csproj" />
115
</ItemGroup>

src/Foundatio.LuceneQueryParser/Ast/RangeNode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class RangeNode : QueryNode
88
private ReadOnlyMemory<char> _field;
99
private ReadOnlyMemory<char> _min;
1010
private ReadOnlyMemory<char> _max;
11-
11+
1212
/// <summary>
1313
/// The field name as a memory slice (zero allocation).
1414
/// </summary>
@@ -17,7 +17,7 @@ public ReadOnlyMemory<char> FieldMemory
1717
get => _field;
1818
set => _field = value;
1919
}
20-
20+
2121
/// <summary>
2222
/// The field name (optional, may be set at FieldQueryNode level).
2323
/// Use FieldMemory for zero-allocation access.
@@ -36,7 +36,7 @@ public ReadOnlyMemory<char> MinMemory
3636
get => _min;
3737
set => _min = value;
3838
}
39-
39+
4040
/// <summary>
4141
/// The lower bound of the range (null for unbounded).
4242
/// Use MinMemory for zero-allocation access.
@@ -55,7 +55,7 @@ public ReadOnlyMemory<char> MaxMemory
5555
get => _max;
5656
set => _max = value;
5757
}
58-
58+
5959
/// <summary>
6060
/// The upper bound of the range (null for unbounded).
6161
/// Use MaxMemory for zero-allocation access.
@@ -82,7 +82,7 @@ public string? Max
8282
public float? Boost { get; set; }
8383

8484
/// <summary>
85-
/// The operator used for short-form ranges (>, >=, <, <=).
85+
/// The operator used for short-form ranges (&gt;, &gt;=, &lt;, &lt;=).
8686
/// </summary>
8787
public RangeOperator? Operator { get; set; }
8888
}
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
8-
93
</Project>

src/Foundatio.LuceneQueryParser/LuceneParser.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public LuceneParser(List<Token> tokens)
3131
_tokens = tokens ?? throw new ArgumentNullException(nameof(tokens));
3232
_position = 0;
3333
}
34-
34+
3535
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3636
private static bool SpanEquals(ReadOnlySpan<char> a, ReadOnlySpan<char> b)
3737
=> a.SequenceEqual(b);
38-
38+
3939
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4040
private static bool SpanEqualsIgnoreCase(ReadOnlySpan<char> a, ReadOnlySpan<char> b)
4141
=> a.Equals(b, StringComparison.OrdinalIgnoreCase);
42-
42+
4343
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4444
private static bool IsStar(ReadOnlySpan<char> span)
4545
=> span.Length == 1 && span[0] == '*';
@@ -93,7 +93,7 @@ public QueryDocument Parse()
9393
return multiTerm;
9494
}
9595
}
96-
96+
9797
return ParseOrQuery();
9898
}
9999

@@ -145,7 +145,7 @@ public QueryDocument Parse()
145145
{
146146
clauses.Add(new BooleanClause { Query = right, Occur = Occur.Should, Operator = BooleanOperator.Implicit });
147147
}
148-
148+
149149
// If no progress was made, break to avoid infinite loop
150150
if (_position == positionBeforeParse)
151151
{
@@ -221,7 +221,7 @@ public QueryDocument Parse()
221221
{
222222
clauses.Add(new BooleanClause { Query = right, Occur = Occur.Must, Operator = BooleanOperator.Implicit });
223223
}
224-
224+
225225
// If no progress was made, break to avoid infinite loop
226226
if (_position == positionBeforeParse)
227227
{
@@ -361,7 +361,7 @@ private GroupNode ParseGroup()
361361
SkipWhitespace();
362362

363363
QueryNode? innerQuery;
364-
364+
365365
if (!SplitOnWhitespace)
366366
{
367367
// Try to parse as MultiTerm first (consecutive simple terms without operators)
@@ -482,17 +482,17 @@ private GroupNode ParseGroup()
482482
StartColumn = startToken.Column
483483
};
484484
}
485-
485+
486486
[MethodImpl(MethodImplOptions.AggressiveInlining)]
487487
private static ReadOnlyMemory<char> BuildCombinedText(List<ReadOnlyMemory<char>> terms)
488488
{
489489
if (terms.Count == 1)
490490
return terms[0];
491-
491+
492492
int totalLength = terms.Count - 1; // spaces
493493
foreach (var term in terms)
494494
totalLength += term.Length;
495-
495+
496496
var chars = new char[totalLength];
497497
int pos = 0;
498498
for (int i = 0; i < terms.Count; i++)
@@ -919,7 +919,7 @@ private RangeNode ParseRange()
919919
StartLine = startToken.Line,
920920
StartColumn = startToken.Column
921921
};
922-
922+
923923
// Set min/max, treating * as unbounded
924924
if (min.HasValue && !IsStar(min.Value.Span))
925925
node.MinMemory = min.Value;
@@ -958,7 +958,7 @@ private RangeNode ParseRange()
958958
}
959959

960960
/// <summary>
961-
/// Parses a short-form range query (>, >=, <, <=).
961+
/// Parses a short-form range query (&gt;, &gt;=, &lt;, &lt;=).
962962
/// </summary>
963963
private RangeNode ParseShortRange()
964964
{
@@ -1077,7 +1077,7 @@ private int ParseFuzzyDistance()
10771077
private static ReadOnlyMemory<char> UnescapeTerm(ReadOnlyMemory<char> term)
10781078
{
10791079
var span = term.Span;
1080-
1080+
10811081
// Fast path: no backslash means no escaping needed
10821082
if (span.IndexOf('\\') < 0)
10831083
return term;

0 commit comments

Comments
 (0)