Skip to content

Commit

Permalink
warnings as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Nov 21, 2024
1 parent f4d9f72 commit 06f9795
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ jobs:
8.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.9
uses: gittools/actions/gitversion/setup@v3.0.3
with:
versionSpec: '5.x'
versionSpec: '6.x'

- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.9
uses: gittools/actions/gitversion/execute@v3.0.3

- name: Install dependencies
run: dotnet restore ${{ env.Solution_File }}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
Expand Down
16 changes: 7 additions & 9 deletions src/Examine.Benchmarks/ConcurrentAcquireBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Lucene.Net.Analysis;
Expand Down Expand Up @@ -46,13 +47,13 @@ public override void Setup()
[GlobalCleanup]
public override void TearDown()
{
_searcherManager.Dispose();
_writer.Dispose();
_indexDir.Dispose();
_searcherManager?.Dispose();
_writer?.Dispose();
_indexDir?.Dispose();

base.TearDown();

System.IO.Directory.Delete(_tempBasePath, true);
System.IO.Directory.Delete(_tempBasePath!, true);
}

[Params(1, 15, 30, 100)]
Expand All @@ -65,10 +66,7 @@ public async Task SimpleMultiThreadLoop()

for (var i = 0; i < ThreadCount; i++)
{
tasks.Add(new Task(() =>
{
var i = 0;
}));
tasks.Add(new Task(() => Debug.Write(i)));
}

foreach (var task in tasks)
Expand All @@ -88,7 +86,7 @@ public async Task TestAcquireThreadContention()
{
tasks.Add(new Task(() =>
{
var searcher = _searcherManager.Acquire();
var searcher = _searcherManager!.Acquire();
try
{
if (searcher.IndexReader.RefCount > (ThreadCount + 1))
Expand Down
26 changes: 13 additions & 13 deletions src/Examine.Benchmarks/ConcurrentSearchBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public override void Setup()
{
base.Setup();

_logger = LoggerFactory.CreateLogger<ConcurrentSearchBenchmarks>();
_logger = LoggerFactory!.CreateLogger<ConcurrentSearchBenchmarks>();
_tempBasePath = Path.Combine(Path.GetTempPath(), "ExamineTests");

// indexer for examine
Expand All @@ -187,14 +187,14 @@ public override void Setup()
[GlobalCleanup]
public override void TearDown()
{
_indexer.Dispose();
_searcherManager.Dispose();
_writer.Dispose();
_indexDir.Dispose();
_indexer?.Dispose();
_searcherManager?.Dispose();
_writer?.Dispose();
_indexDir?.Dispose();

base.TearDown();

System.IO.Directory.Delete(_tempBasePath, true);
System.IO.Directory.Delete(_tempBasePath!, true);
}

[Params(1, 50, 100)]
Expand All @@ -213,14 +213,14 @@ public async Task ExamineStandard()
tasks.Add(new Task(() =>
{
// always resolve the searcher from the indexer
var searcher = _indexer.Searcher;
var searcher = _indexer!.Searcher;

var query = searcher.CreateQuery("content").Field("nodeName", "location".MultipleCharacterWildcard());
var results = query.Execute(QueryOptions.SkipTake(0, MaxResults));

// enumerate (forces the result to execute)
var logOutput = "ThreadID: " + Thread.CurrentThread.ManagedThreadId + ", Results: " + string.Join(',', results.Select(x => $"{x.Id}-{x.Values.Count}-{x.Score}").ToArray());
_logger.LogDebug(logOutput);
_logger!.LogDebug(logOutput);
}));
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public async Task LuceneAcquireAlways()

// enumerate (forces the result to execute)
var logOutput = "ThreadID: " + Thread.CurrentThread.ManagedThreadId + ", Results: " + string.Join(',', results.Select(x => $"{x.Id}-{x.Values.Count}-{x.Score}").ToArray());
_logger.LogDebug(logOutput);
_logger!.LogDebug(logOutput);
}));
}

Expand Down Expand Up @@ -390,7 +390,7 @@ public async Task LuceneAcquireAlwaysWithLock()

// enumerate (forces the result to execute)
var logOutput = "ThreadID: " + Thread.CurrentThread.ManagedThreadId + ", Results: " + string.Join(',', results.Select(x => $"{x.Id}-{x.Values.Count}-{x.Score}").ToArray());
_logger.LogDebug(logOutput);
_logger!.LogDebug(logOutput);
}
}));
}
Expand All @@ -408,7 +408,7 @@ public async Task LuceneAcquireOnce()
{
var tasks = new List<Task>();

var searcher = _searcherManager.Acquire();
var searcher = _searcherManager!.Acquire();

try
{
Expand Down Expand Up @@ -444,7 +444,7 @@ public async Task LuceneAcquireOnce()

// enumerate (forces the result to execute)
var logOutput = "ThreadID: " + Thread.CurrentThread.ManagedThreadId + ", Results: " + string.Join(',', results.Select(x => $"{x.Id}-{x.Values.Count}-{x.Score}").ToArray());
_logger.LogDebug(logOutput);
_logger!.LogDebug(logOutput);
}));
}

Expand Down Expand Up @@ -504,7 +504,7 @@ public async Task LuceneSortedDocIds()

// enumerate (forces the result to execute)
var logOutput = "ThreadID: " + Thread.CurrentThread.ManagedThreadId + ", Results: " + string.Join(',', results.Select(x => $"{x.Id}-{x.Values.Count}-{x.Score}").ToArray());
_logger.LogDebug(logOutput);
_logger!.LogDebug(logOutput);
}));
}

Expand Down
2 changes: 2 additions & 0 deletions src/Examine.Benchmarks/Examine.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<!-- Will be imported when running different Nuget targeted benchmarks -->
<PackageReference Condition="$(LocalBuild) == 'false'" Include="Examine" Version="3.0.1" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Examine.Benchmarks/ExamineBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public virtual void Setup()
LoggerFactory.CreateLogger(typeof(ExamineBaseTest)).LogDebug("Initializing test");
}

public virtual void TearDown() => LoggerFactory.Dispose();
public virtual void TearDown() => LoggerFactory!.Dispose();

public TestIndex GetTestIndex(
Directory d,
Expand All @@ -31,7 +31,7 @@ public TestIndex GetTestIndex(
double nrtTargetMinStaleSec = 1,
bool nrtEnabled = true)
=> new TestIndex(
LoggerFactory,
LoggerFactory!,
Mock.Of<IOptionsMonitor<LuceneDirectoryIndexOptions>>(x => x.Get(TestIndex.TestIndexName) == new LuceneDirectoryIndexOptions
{
FieldDefinitions = fieldDefinitions,
Expand Down
2 changes: 1 addition & 1 deletion src/Examine.Benchmarks/IndexVersionComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Setup()
{
base.Setup();

_logger = LoggerFactory.CreateLogger<IndexVersionComparison>();
_logger = LoggerFactory!.CreateLogger<IndexVersionComparison>();
_tempBasePath = Path.Combine(Path.GetTempPath(), "ExamineTests");
_indexer = InitTools.InitializeIndex(this, _tempBasePath, _analyzer, out _);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Examine.Benchmarks/SearchVersionComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Setup()
{
base.Setup();

_logger = LoggerFactory.CreateLogger<SearchVersionComparison>();
_logger = LoggerFactory!.CreateLogger<SearchVersionComparison>();
_tempBasePath = Path.Combine(Path.GetTempPath(), "ExamineTests");
_indexer = InitTools.InitializeIndex(this, _tempBasePath, _analyzer, out _);
_indexer!.IndexItems(_valueSets);
Expand Down
1 change: 0 additions & 1 deletion src/Examine.Core/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Examine.FieldDefinitionTypes.Integer = "int" -> string
const Examine.FieldDefinitionTypes.InvariantCultureIgnoreCase = "invariantcultureignorecase" -> string
const Examine.FieldDefinitionTypes.Long = "long" -> string
const Examine.FieldDefinitionTypes.Raw = "raw" -> string
const Examine.Search.QueryOptions.DefaultMaxResults = 500 -> int
Examine.BaseIndexProvider
Examine.BaseIndexProvider.BaseIndexProvider(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, string name, Microsoft.Extensions.Options.IOptionsMonitor<Examine.IndexOptions> indexOptions) -> void
Examine.BaseIndexProvider.DeleteFromIndex(System.Collections.Generic.IEnumerable<string> itemIds) -> void
Expand Down
1 change: 0 additions & 1 deletion src/Examine.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
const Examine.Search.QueryOptions.AbsoluteMaxResults = 10000 -> int
const Examine.Search.QueryOptions.DefaultMaxResults = 100 -> int
static Examine.SearchExtensions.Escape(this string s, float boost) -> Examine.Search.IExamineValue
1 change: 1 addition & 0 deletions src/Examine.Host/Examine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/Examine.Lucene/Providers/LuceneIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ internal LuceneIndex(
private ControlledRealTimeReopenThread<IndexSearcher> _nrtReopenThread;
private readonly ILogger<LuceneIndex> _logger;
private readonly Lazy<Directory> _directory;
#if FULLDEBUG
private readonly FileStream _logOutput;
#endif
private bool _disposedValue;
private readonly IndexCommiter _committer;

Expand Down Expand Up @@ -1360,9 +1362,9 @@ protected virtual void Dispose(bool disposing)
}

_cancellationTokenSource.Dispose();

#if FULLDEBUG
_logOutput?.Close();

#endif
_fieldAnalyzer?.Dispose();
if (!object.ReferenceEquals(_fieldAnalyzer, DefaultAnalyzer))
{
Expand Down
2 changes: 0 additions & 2 deletions src/Examine.Lucene/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ Examine.Lucene.Search.LuceneSearchResult.LuceneSearchResult(string id, float sco
Examine.Lucene.Search.LuceneSearchResult.ShardIndex.get -> int
Examine.Lucene.Search.LuceneSearchResults
Examine.Lucene.Search.LuceneSearchResults.GetEnumerator() -> System.Collections.Generic.IEnumerator<Examine.ISearchResult>
Examine.Lucene.Search.LuceneSearchResults.LuceneSearchResults(System.Collections.Generic.IReadOnlyCollection<Examine.ISearchResult> results, int totalItemCount) -> void
Examine.Lucene.Search.LuceneSearchResults.TotalItemCount.get -> long
Examine.Lucene.Search.MultiSearchContext
Examine.Lucene.Search.MultiSearchContext.GetFieldValueType(string fieldName) -> Examine.Lucene.Indexing.IIndexFieldValueType
Expand Down Expand Up @@ -436,4 +435,3 @@ virtual Examine.Lucene.Search.LuceneSearchQuery.OrderBy(params Examine.Search.So
virtual Examine.Lucene.Search.LuceneSearchQuery.OrderByDescending(params Examine.Search.SortableField[] fields) -> Examine.Search.IBooleanOperation
virtual Examine.Lucene.Search.LuceneSearchQueryBase.GetFieldInternalQuery(string fieldName, Examine.Search.IExamineValue fieldValue, bool useQueryParser) -> Lucene.Net.Search.Query
virtual Examine.Lucene.Search.MultiSearchSearcherReference.Dispose(bool disposing) -> void
virtual Examine.Lucene.Search.SearcherReference.Dispose(bool disposing) -> void
7 changes: 4 additions & 3 deletions src/Examine.Lucene/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Examine.Lucene.LuceneIndexOptions.NrtTargetMaxStaleSec.set -> void
Examine.Lucene.LuceneIndexOptions.NrtTargetMinStaleSec.get -> double
Examine.Lucene.LuceneIndexOptions.NrtTargetMinStaleSec.set -> void
Examine.Lucene.Providers.LuceneSearcher.LuceneSearcher(string name, Lucene.Net.Search.SearcherManager searcherManager, Lucene.Net.Analysis.Analyzer analyzer, Examine.Lucene.FieldValueTypeCollection fieldValueTypeCollection, bool isNrt) -> void
Examine.Lucene.Providers.LuceneSearcher.MaybeRefresh() -> bool
Examine.Lucene.Providers.LuceneSearcher.MaybeRefreshBlocking() -> void
Examine.Lucene.Search.LuceneSearchResults.LuceneSearchResults(System.Collections.Generic.IReadOnlyCollection<Examine.ISearchResult> results, int totalItemCount, float maxScore, Examine.Lucene.Search.SearchAfterOptions searchAfterOptions) -> void
Examine.Lucene.Search.LuceneSearchResults.MaxScore.get -> float
Examine.Lucene.Search.LuceneSearchResults.SearchAfter.get -> Examine.Lucene.Search.SearchAfterOptions
Examine.Lucene.Search.SearchContext.SearchContext(Lucene.Net.Search.SearcherManager searcherManager, Examine.Lucene.FieldValueTypeCollection fieldValueTypeCollection, bool isNrt) -> void
Examine.Lucene.Search.SearcherReference.SearcherReference() -> void
virtual Examine.Lucene.Providers.LuceneIndex.UpdateLuceneDocument(Lucene.Net.Index.Term term, Lucene.Net.Documents.Document doc) -> long?
static Examine.Lucene.Search.LuceneSearchExtensions.ExecuteWithLucene(this Examine.Search.IQueryExecutor queryExecutor, Examine.Search.QueryOptions options = null) -> Examine.Lucene.Search.ILuceneSearchResults
virtual Examine.Lucene.Providers.LuceneIndex.UpdateLuceneDocument(Lucene.Net.Index.Term term, Lucene.Net.Documents.Document doc) -> long?
14 changes: 9 additions & 5 deletions src/Examine.Lucene/Search/CustomMultiFieldQueryParser.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Core;
using Lucene.Net.QueryParsers;
using Lucene.Net.QueryParsers.Classic;
using Lucene.Net.Search;
using Lucene.Net.Util;
Expand Down Expand Up @@ -30,7 +29,9 @@ public CustomMultiFieldQueryParser(LuceneVersion matchVersion, string[] fields,
public virtual Query GetFuzzyQueryInternal(string field, string termStr, float minSimilarity)
{
if (string.IsNullOrWhiteSpace(termStr))
{
throw new System.ArgumentException($"'{nameof(termStr)}' cannot be null or whitespace", nameof(termStr));
}

return GetFuzzyQuery(field, termStr, minSimilarity);
}
Expand All @@ -51,15 +52,14 @@ public virtual Query GetFuzzyQueryInternal(string field, string termStr, float m
///
/// TODO: We could go further and override the field query and check if it is a numeric field, if so then we can automatically generate a numeric range query for the single digit too.
/// </remarks>
protected override Query GetRangeQuery(string field, string part1, string part2, bool startInclusive, bool endInclusive)
{
return base.GetRangeQuery(field, part1, part2, startInclusive, endInclusive);
}
protected override Query GetRangeQuery(string field, string part1, string part2, bool startInclusive, bool endInclusive) => base.GetRangeQuery(field, part1, part2, startInclusive, endInclusive);

public virtual Query GetWildcardQueryInternal(string field, string termStr)
{
if (string.IsNullOrWhiteSpace(termStr))
{
throw new ArgumentException($"'{nameof(termStr)}' cannot be null or whitespace", nameof(termStr));
}

return GetWildcardQuery(field, termStr);
}
Expand All @@ -74,15 +74,19 @@ public virtual Query GetWildcardQueryInternal(string field, string termStr)
public virtual Query GetProximityQueryInternal(string field, string queryText, int slop)
{
if (string.IsNullOrWhiteSpace(queryText))
{
throw new ArgumentException($"'{nameof(queryText)}' cannot be null or whitespace", nameof(queryText));
}

return GetFieldQuery(field, queryText, slop);
}

public Query GetFieldQueryInternal(string field, string queryText)
{
if (string.IsNullOrWhiteSpace(queryText))
{
throw new ArgumentException($"'{nameof(queryText)}' cannot be null or whitespace", nameof(queryText));
}

var query = GetFieldQuery(field, queryText, false);

Expand Down
Loading

0 comments on commit 06f9795

Please sign in to comment.