Skip to content
Merged

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ internal static bool FlagsAreValid (ExportMethod exportData, RootContext context
/// <returns><c>true</c> if the data is valid; otherwise, <c>false</c>.</returns>
internal static bool SelectorIsNotNull (string? selector, RootContext context, out ImmutableArray<Diagnostic> diagnostics,
Location? location = null)
=> StringStrategies.IsNotNull (
=> StringStrategies.IsNotNullOrEmpty (
selector: selector,
descriptor: RBI0022, // A export property must have a selector defined
diagnostics: out diagnostics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ExportPropertyAttributeValidator : Validator<ExportData<Property>> {
/// <returns><c>true</c> if the data is valid; otherwise, <c>false</c>.</returns>
internal static bool SelectorIsNotNull (string? selector, RootContext context, out ImmutableArray<Diagnostic> diagnostics,
Location? location = null)
=> StringStrategies.IsNotNull (
=> StringStrategies.IsNotNullOrEmpty (
selector: selector,
descriptor: RBI0018, // A export property must have a selector defined
diagnostics: out diagnostics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FieldValidator : Validator<Property> {
/// <returns><c>true</c> if the selector is not null or empty; otherwise, <c>false</c>.</returns>
internal static bool SelectorIsNotNull (string? selector, RootContext context, out ImmutableArray<Diagnostic> diagnostics,
Location? location = null)
=> StringStrategies.IsNotNull (
=> StringStrategies.IsNotNullOrEmpty (
selector: selector,
descriptor: RBI0018, // A export property must have a selector defined
diagnostics: out diagnostics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public static class StringStrategies {
/// <param name="diagnostics">When this method returns, contains an array of diagnostics if the data is invalid; otherwise, an empty array.</param>
/// <param name="location">The code location to be used for the diagnostics.</param>
/// <returns><c>true</c> if the data is valid; otherwise, <c>false</c>.</returns>
internal static bool IsNotNull (string? selector, DiagnosticDescriptor descriptor, out ImmutableArray<Diagnostic> diagnostics,
internal static bool IsNotNullOrEmpty (string? selector, DiagnosticDescriptor descriptor, out ImmutableArray<Diagnostic> diagnostics,
Location? location = null)
{
diagnostics = ImmutableArray<Diagnostic>.Empty;
if (selector is not null)
if (!string.IsNullOrEmpty (selector))
return true;
diagnostics = [
Diagnostic.Create (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void ValidateValidFieldPropertyTests ()

[Theory]
[InlineData ("validSelector", true, 0)]
[InlineData ("", true, 0)]
[InlineData ("", false, 1)]
[InlineData (null, false, 1)]
[InlineData ("another_valid_selector", true, 0)]
[InlineData ("valid123", true, 0)]
Expand Down