Skip to content

Commit

Permalink
Ran dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Jan 31, 2025
1 parent 3235b78 commit 9fcb861
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Foundatio.Parsers.SqlQueries.Extensions;

internal static class EnumerableExtensions {
internal static class EnumerableExtensions
{
public delegate void ElementAction<in T>(T element, ElementInfo info);

public static void ForEach<T>(this IEnumerable<T> elements, ElementAction<T> action)
Expand All @@ -22,9 +23,11 @@ public static void ForEach<T>(this IEnumerable<T> elements, ElementAction<T> act
}
}

public struct ElementInfo {
public struct ElementInfo
{
public ElementInfo(int index, bool isFirst, bool isLast)
: this() {
: this()
{
Index = index;
IsFirst = isFirst;
IsLast = isLast;
Expand Down
13 changes: 7 additions & 6 deletions src/Foundatio.Parsers.SqlQueries/Extensions/SqlNodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Foundatio.Parsers.LuceneQueries.Extensions;
using Foundatio.Parsers.LuceneQueries.Nodes;
using Foundatio.Parsers.SqlQueries.Visitors;
using Microsoft.Extensions.Primitives;

namespace Foundatio.Parsers.SqlQueries.Extensions;

Expand Down Expand Up @@ -150,7 +149,7 @@ public static string ToDynamicLinqString(this TermNode node, ISqlQueryVisitorCon

context.SearchTokenizer.Invoke(searchTerm);
if (searchTerm.Tokens == null)
searchTerm.Tokens = [ searchTerm.Term ];
searchTerm.Tokens = [searchTerm.Term];
else
searchTerm.Tokens = searchTerm.Tokens.Select(t => !String.IsNullOrWhiteSpace(t) ? t : "@__NOMATCH__").ToList();
}
Expand All @@ -177,7 +176,8 @@ public static string ToDynamicLinqString(this TermNode node, ISqlQueryVisitorCon
}
else if (searchTerm.Operator == SqlSearchOperator.Contains)
{
tokens.ForEach((token, i) => {
tokens.ForEach((token, i) =>
{
builder.Append(i.IsFirst ? "(" : " OR ");
builder.Append(fieldPrefix);
builder.Append(kvp.Key.Name);
Expand All @@ -191,7 +191,8 @@ public static string ToDynamicLinqString(this TermNode node, ISqlQueryVisitorCon
}
else if (searchTerm.Operator == SqlSearchOperator.StartsWith)
{
tokens.ForEach((token, i) => {
tokens.ForEach((token, i) =>
{
builder.Append(i.IsFirst ? "(" : " OR ");
builder.Append(fieldPrefix);
builder.Append(kvp.Key.Name);
Expand Down Expand Up @@ -323,10 +324,10 @@ public static string ToDynamicLinqString(this IQueryNode node, ISqlQueryVisitorC
public static EntityFieldInfo GetFieldInfo(List<EntityFieldInfo> fields, string field)
{
if (fields == null)
return new EntityFieldInfo { Name = field, FullName = field};
return new EntityFieldInfo { Name = field, FullName = field };

return fields.FirstOrDefault(f => f.FullName.Equals(field, StringComparison.OrdinalIgnoreCase)) ??
new EntityFieldInfo { Name = field, FullName = field};
new EntityFieldInfo { Name = field, FullName = field };
}

private static void AppendField(StringBuilder builder, EntityFieldInfo field, string term)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
using System.Diagnostics;
using System.Text;
using Foundatio.Parsers.LuceneQueries.Visitors;
using Foundatio.Parsers.SqlQueries.Extensions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Primitives;

namespace Foundatio.Parsers.SqlQueries.Visitors;

Expand Down Expand Up @@ -69,7 +67,8 @@ public override bool Equals(object obj)

var prefix = new StringBuilder();
var suffix = new StringBuilder();
foreach (var field in fieldTree) {
foreach (var field in fieldTree)
{
if (field.IsCollection)
{
prefix.Append($"{field.Name}.Any(");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public void CanHandleDateRange()
#else
var tracer = NullTracer.Instance;
#endif
var sut = new LuceneQueryParser {
var sut = new LuceneQueryParser
{
Tracer = tracer
};
string query = "mydate:[now/d TO now/d+30d/d]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public async Task CanGenerateSql()
Assert.Equal("John Doe", employee.FullName);
}

public static string? TryGetNationalNumber(string phoneNumber, string regionCode = "US")
public static string TryGetNationalNumber(string phoneNumber, string regionCode = "US")
{
var phoneNumberUtil = PhoneNumberUtil.GetInstance();
try
Expand Down

0 comments on commit 9fcb861

Please sign in to comment.