Skip to content

Commit

Permalink
Merge pull request #349 from nzdev/v4/api
Browse files Browse the repository at this point in the history
Ensure V4 API, reduce warnings
  • Loading branch information
Shazwazza authored Sep 12, 2023
2 parents 0dffba6 + ce864b2 commit f2dc6e7
Show file tree
Hide file tree
Showing 86 changed files with 1,579 additions and 978 deletions.
71 changes: 45 additions & 26 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
csharp_indent_labels = no_change
csharp_using_directive_placement = outside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:warning
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = when_on_single_line:warning
csharp_style_expression_bodied_constructors = false:warning
csharp_style_expression_bodied_operators = when_on_single_line:warning
csharp_style_expression_bodied_properties = when_on_single_line:warning
csharp_style_expression_bodied_indexers = when_on_single_line:warning
csharp_style_expression_bodied_accessors = when_on_single_line:warning
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
csharp_style_expression_bodied_local_functions = when_on_single_line:warning
csharp_style_prefer_range_operator = false:warning

##########################################
# File Extension Settings
Expand Down Expand Up @@ -279,25 +296,25 @@ dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessib
dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const
dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning

# All public/protected/protected_internal static readonly fields must be PascalCase
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal
dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning

# No other public/protected/protected_internal fields are allowed
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal
dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error

##########################################
# StyleCop Field Naming Rules
Expand All @@ -312,8 +329,8 @@ dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning

# All static readonly fields must be PascalCase
# Ajusted to ignore private fields.
Expand All @@ -322,32 +339,32 @@ dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibi
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning

# No non-private instance fields are allowed
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error

# Local variables must be camelCase
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md
dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local
dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent

# This rule should never fire. However, it's included for at least two purposes:
# First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers.
# Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#).
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = *
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error


Expand All @@ -368,36 +385,36 @@ dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members
dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property
dotnet_naming_rule.element_rule.symbols = element_group
dotnet_naming_rule.element_rule.style = pascal_case_style
dotnet_naming_rule.element_rule.severity = warning
dotnet_naming_rule.element_rule.style = pascal_case_style
dotnet_naming_rule.element_rule.severity = warning

# Interfaces use PascalCase and are prefixed with uppercase 'I'
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
dotnet_naming_symbols.interface_group.applicable_kinds = interface
dotnet_naming_rule.interface_rule.symbols = interface_group
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
dotnet_naming_rule.interface_rule.severity = warning
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
dotnet_naming_rule.interface_rule.severity = warning

# Generics Type Parameters use PascalCase and are prefixed with uppercase 'T'
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter
dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group
dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style
dotnet_naming_rule.type_parameter_rule.severity = warning
dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style
dotnet_naming_rule.type_parameter_rule.severity = warning

# Function parameters use camelCase
# https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters
dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
dotnet_naming_rule.parameters_rule.symbols = parameters_group
dotnet_naming_rule.parameters_rule.style = camel_case_style
dotnet_naming_rule.parameters_rule.severity = warning
dotnet_naming_rule.parameters_rule.style = camel_case_style
dotnet_naming_rule.parameters_rule.severity = warning

# Private static fields use camelCase and start with s_
dotnet_naming_symbols.private_static_field_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_field_symbols.required_modifiers = static, shared
dotnet_naming_symbols.private_static_field_symbols.applicable_kinds = field
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.symbols = private_static_field_symbols
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.style = camel_case_and_prefix_with_s_underscore_style
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.style = pascal_case_style
dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.severity = warning
dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.required_prefix = s_
dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.capitalization = camel_case
Expand All @@ -406,10 +423,12 @@ dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.capitalization
dotnet_naming_symbols.private_field_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_field_symbols.applicable_kinds = field
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = private_field_symbols
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style
dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = suggestion
dotnet_naming_style.camel_case_and_prefix_with_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_and_prefix_with_underscore_style.capitalization = camel_case
tab_width = 4
end_of_line = crlf

##########################################
# License
Expand Down
2 changes: 2 additions & 0 deletions src/Examine.Core/BaseIndexProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ protected BaseIndexProvider(ILoggerFactory loggerFactory, string name,
IOptionsMonitor<IndexOptions> indexOptions)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
}

LoggerFactory = loggerFactory;
_logger = loggerFactory.CreateLogger<BaseIndexProvider>();
Expand Down
6 changes: 5 additions & 1 deletion src/Examine.Core/BaseSearchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public abstract class BaseSearchProvider : ISearcher
/// <inheritdoc/>
protected BaseSearchProvider(string name)
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
}

Name = name;
}

Expand Down
13 changes: 8 additions & 5 deletions src/Examine.Core/DisposableObjectSlim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ public abstract class DisposableObjectSlim : IDisposable
protected bool Disposed { get; private set; }

/// <inheritdoc/>
public void Dispose()
{
Dispose(true);
}
public void Dispose() => Dispose(true);

private void Dispose(bool disposing)
{
lock (_locko)
{
if (Disposed) return;
if (Disposed)
{
return;
}

Disposed = true;
}

if (disposing)
{
DisposeResources();
}
}

/// <summary>
Expand Down
22 changes: 4 additions & 18 deletions src/Examine.Core/EmptySearchResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,21 @@ private EmptySearchResults()
public static ISearchResults Instance { get; } = new EmptySearchResults();

/// <inheritdoc/>
public IEnumerator<ISearchResult> GetEnumerator()
{
return Enumerable.Empty<ISearchResult>().GetEnumerator();
}
public IEnumerator<ISearchResult> GetEnumerator() => Enumerable.Empty<ISearchResult>().GetEnumerator();

/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return Enumerable.Empty<ISearchResult>().GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => Enumerable.Empty<ISearchResult>().GetEnumerator();

/// <inheritdoc/>
public long TotalItemCount => 0;


#pragma warning disable IDE0060 // Remove unused parameter
/// <inheritdoc/>
public IEnumerable<ISearchResult> Skip(int skip)
#pragma warning restore IDE0060 // Remove unused parameter
{
return Enumerable.Empty<ISearchResult>();
}
public IEnumerable<ISearchResult> Skip(int skip) => Enumerable.Empty<ISearchResult>();

/// <inheritdoc/>
#pragma warning disable IDE0060 // Remove unused parameter
public IEnumerable<ISearchResult> SkipTake(int skip, int? take = null)
#pragma warning restore IDE0060 // Remove unused parameter
{
return Enumerable.Empty<ISearchResult>();
}
public IEnumerable<ISearchResult> SkipTake(int skip, int? take = null) => Enumerable.Empty<ISearchResult>();
}
}
11 changes: 10 additions & 1 deletion src/Examine.Core/Examine.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
<NoWarn>RS0036</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Remove="PublicAPI.Shipped.txt" />
<None Remove="PublicAPI.Unshipped.txt" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\assets\logo-round-small.png" Link="logo-round-small.png" Pack="true" PackagePath="" />
</ItemGroup>
Expand Down
19 changes: 4 additions & 15 deletions src/Examine.Core/ExamineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ public static class ExamineExtensions
public static T GetNamedOptions<T>(this IOptionsMonitor<T> optionsMonitor, string name)
where T : class
{
T options = optionsMonitor.Get(name);

if (options == null)
{
throw new InvalidOperationException($"No named {typeof(T)} options with name {name}");
}
var options = optionsMonitor.Get(name) ?? throw new InvalidOperationException($"No named {typeof(T)} options with name {name}");

return options;
}
Expand All @@ -37,7 +32,7 @@ public static T GetNamedOptions<T>(this IOptionsMonitor<T> optionsMonitor, strin
/// <returns></returns>
public static IIndex GetIndex(this IExamineManager examineManager, string indexName)
{
if (examineManager.TryGetIndex(indexName, out IIndex? index))
if (examineManager.TryGetIndex(indexName, out var index))
{
return index;
}
Expand All @@ -49,20 +44,14 @@ public static IIndex GetIndex(this IExamineManager examineManager, string indexN
/// </summary>
/// <param name="index"></param>
/// <param name="itemId"></param>
public static void DeleteFromIndex(this IIndex index, string itemId)
{
index.DeleteFromIndex(new[] {itemId});
}
public static void DeleteFromIndex(this IIndex index, string itemId) => index.DeleteFromIndex(new[] { itemId });

/// <summary>
/// Method to re-index specific data
/// </summary>
/// <param name="index"></param>
/// <param name="node"></param>
public static void IndexItem(this IIndex index, ValueSet node)
{
index.IndexItems(new[] { node });
}
public static void IndexItem(this IIndex index, ValueSet node) => index.IndexItems(new[] { node });

}
}
4 changes: 2 additions & 2 deletions src/Examine.Core/ExamineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class ExamineManager : IDisposable, IExamineManager
/// <inheritdoc/>
public ExamineManager(IEnumerable<IIndex> indexes, IEnumerable<ISearcher> searchers)
{
foreach(IIndex i in indexes)
foreach(var i in indexes)
{
AddIndex(i);
}

foreach(ISearcher s in searchers)
foreach(var s in searchers)
{
AddSearcher(s);
}
Expand Down
Loading

0 comments on commit f2dc6e7

Please sign in to comment.