Skip to content

Remove fluent validation - #2

Merged
matt-edmondson merged 31 commits into
mainfrom
remove-fluent-validation
Aug 25, 2025
Merged

matt-edmondson merged 31 commits into
mainfrom
remove-fluent-validation

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Remove the fluent validation dependency and implement necessary replacement functionality, so that we can support more target frameworks.

This commit includes the following changes:
- Removed the `FluentValidation` dependency from various validation attributes, replacing it with a native validation approach.
- Updated validation logic to return `ValidationResult` objects for success and failure cases.
- Deleted the `FluentValidationAdapter` class and its associated tests, streamlining the validation framework.
- Adjusted multiple validation attributes to ensure they function correctly without the FluentValidation integration.

These modifications aim to simplify the validation framework and enhance maintainability by reducing external dependencies.
…on logic

This commit includes the following changes:
- Updated validation attributes to use constructor parameters for initialization, improving clarity and reducing boilerplate code.
- Refactored validation logic to return `ValidationResult` objects directly, ensuring consistent success and failure handling.
- Simplified the implementation of various validation adapters, including `ContainsValidator`, `EndsWithValidator`, and others, to streamline their functionality.

These modifications aim to improve the maintainability and readability of the validation framework.
This commit includes the following changes:
- Removed obsolete validation rules and README files related to the validation framework.
- Introduced new path-related classes, including `SemanticAbsolutePath`, `SemanticDirectoryPath`, and `SemanticFilePath`, to enhance path handling capabilities.
- Updated project files to reflect the new structure and added necessary interfaces for path validation.
- Improved organization of validation attributes by moving them to a dedicated directory for better maintainability.

These modifications aim to streamline the validation framework and enhance the overall path management functionality.
This commit introduces support for creating and manipulating semantic strings using read-only spans. Key changes include:
- Added `FromReadOnlySpan` methods in `ISemanticStringFactory` and `SemanticStringFactory` for improved performance.
- Updated `SemanticString` methods to utilize read-only spans for various operations, enhancing efficiency.
- Refactored validation attributes to ensure compatibility with new span-based methods.

These modifications aim to optimize string handling and validation processes within the framework.
This commit includes the following changes:
- Added suppression warnings for specific code analysis rules related to string handling in the project file.
- Simplified the `Remove` method in `SemanticString` by removing redundant parameter names for clarity.
- Adjusted formatting for improved readability in the `MoveNext` method.

These modifications aim to enhance code quality and maintainability within the string handling framework.
…operations

This commit updates the `SemanticString` class to improve performance by using `WeakString` for various methods that handle read-only spans. Key changes include:
- Modified `IndexOf`, `LastIndexOf`, `StartsWith`, `EndsWith`, and `Contains` methods to leverage `WeakString` instead of `AsSpan()`.
- Added conditional compilation for span support based on target frameworks.

These modifications aim to enhance efficiency in string operations while maintaining compatibility across different .NET versions.
This commit introduces a new polyfill for `ArgumentNullException.ThrowIfNull` to support older .NET versions. Additionally, it refactors the namespaces of various path-related classes and interfaces to `ktsu.Semantics.Paths` for improved organization and clarity. The changes include:

- Added `ArgumentNullExceptionPolyfill` for null argument validation.
- Updated namespaces in `SemanticAbsolutePath`, `SemanticDirectoryPath`, `SemanticFilePath`, `SemanticRelativePath`, and others to reflect the new structure.
- Adjusted method implementations in path classes to utilize the new polyfill where applicable.

These modifications aim to enhance code maintainability and ensure compatibility across different .NET versions.
…atibility

This commit adds a polyfill for `ArgumentNullException.ThrowIfNull` to support older .NET versions across various path-related classes. Key changes include:

- Integrated `ArgumentNullExceptionPolyfill` in `SemanticRelativePath`, `AbsoluteDirectoryPath`, `AbsoluteFilePath`, `DirectoryPath`, `RelativeDirectoryPath`, and `RelativeFilePath` implementations.
- Updated null checks to utilize the polyfill for compatibility with .NET versions prior to 6.0.

These modifications enhance the robustness of the path handling framework while ensuring backward compatibility.
…bility

This commit updates the `AsRelative` method in the `RelativeFilePath` class to include a conditional compilation directive that utilizes `ArgumentNullExceptionPolyfill.ThrowIfNull` for .NET versions prior to 6.0. This change ensures consistent null argument validation across different framework versions, enhancing the robustness of the path handling implementation.
…tibility

This commit introduces the `System.Memory` package for .NET Standard 2.0 support and adds several polyfills to enhance path handling across different .NET versions. Key changes include:

- Added `System.Memory` package reference in `Directory.Packages.props` and project files for .NET Standard 2.0.
- Implemented polyfills for `OperatingSystem` and `Path` methods to ensure compatibility with older .NET versions.
- Updated various path-related classes to utilize the new polyfills, improving functionality and consistency in path operations.

These modifications aim to enhance the robustness and compatibility of the path handling framework across different .NET versions.
…ation for older .NET versions

This commit updates the `AbsoluteDirectoryPath`, `DirectoryPath`, and `RelativeDirectoryPath` classes to include synchronous `GetContents` methods for compatibility with .NET versions prior to 2.1. The changes ensure that directory contents can be enumerated synchronously when asynchronous methods are not available, enhancing the framework's robustness across different .NET versions. Additionally, minor adjustments were made to the `PooledStringBuilder` class for consistency in handling directory separators.
This commit makes minor formatting adjustments across several files to enhance code clarity. Changes include removing unnecessary blank lines and aligning code indentation for conditional compilation directives. These modifications aim to improve the overall maintainability of the path handling framework while ensuring consistent coding standards.
… clarity

This commit updates the `SemanticDirectoryPath` class to rename the `Contents` property to `GetContents` for improved clarity. The method now consistently handles directory content retrieval, including error handling for access and existence checks. Additionally, the `GetContents` method is implemented synchronously across relevant directory path classes, ensuring compatibility with older .NET versions. Unused asynchronous method signatures have been removed from the `IDirectoryPath` interface to streamline the API.
…ysical dimensions and update test classes to static for consistency. This improves clarity and aligns with coding standards across the project.
…bute, and StartsWithAttribute classes

This commit updates the validation logic in the `ContainsAttribute`, `EndsWithAttribute`, and `StartsWithAttribute` classes to return more informative error messages when the input value is null or empty. Instead of returning a success result, the validation now clearly indicates the expected substring, suffix, or prefix that must be present in the value, improving user feedback and clarity in validation errors.
This commit deletes several outdated files, including the derived cursor rules, .gitignore, and various history documents, to streamline the project and remove unnecessary clutter. The removal of these files helps maintain a cleaner codebase and improves overall project organization.
…hod naming and enhance error handling. The `Contents` property has been renamed to `GetContents` for clarity, and synchronous handling has been implemented to ensure compatibility with older .NET versions.
… improved performance and reliability. This change ensures that the regex operation does not hang indefinitely by setting a one-second timeout, enhancing the overall validation process.
This commit introduces two new test classes: `CasingAndContractsTests` and `RegexMatchAttributeTests`. The `CasingAndContractsTests` class validates camel case, pascal case, boolean, and contract strings, ensuring correct behavior for valid and invalid inputs. The `RegexMatchAttributeTests` class tests regex patterns for various string types, including handling invalid patterns and validating case insensitivity and multiline anchors. These additions enhance the test coverage for string semantics and validation logic.
This commit introduces two new test classes: `CasingValidatorsTests` and `LineCountValidatorsTests`. The `CasingValidatorsTests` class validates various casing formats, including upper case, lower case, title case, sentence case, snake case, kebab case, and macro case, ensuring correct behavior for valid and invalid inputs. The `LineCountValidatorsTests` class checks for exact, minimum, and maximum line counts in strings, enhancing the test coverage for string semantics and validation logic.
This commit introduces a new test class, `FirstClassAndFormatValidatorsTests`, which includes unit tests for multiple validators such as `IsDateTime`, `IsDecimal`, `IsDouble`, `IsGuid`, `IsInt32`, `IsIpAddress`, `IsTimeSpan`, `IsUri`, `IsVersion`, `HasNonWhitespaceContent`, `IsEmptyOrWhitespace`, `IsSingleLine`, and `IsMultiLine`. Each validator is tested for valid, invalid, and empty inputs, enhancing the test coverage for string semantics and validation logic.
This commit updates the Exposure class to use CoulombPerKilogram instead of Coulomb for exposure calculations. Additionally, new unit tests have been added for various nuclear quantities, including AbsorbedDose and EquivalentDose, to ensure correct conversions and calculations. The test suite now includes comprehensive checks for exposure-related functionalities, enhancing overall test coverage.
This commit adds the installation of the `dotnet-coverage` tool in the GitHub Actions workflow to facilitate code coverage collection during tests. It also updates the SonarQube scanner commands to improve coverage reporting and modifies the `Invoke-DotNetTest` function to utilize the new coverage tool. Additionally, the test project configuration is updated to show test failures and details, enhancing the overall testing and reporting capabilities.
This commit introduces a new test class, `AcousticDirectionalityIndexTests`, which includes comprehensive unit tests for the `DirectionalityIndex` class. The tests cover various methods such as `FromDirectivityFactor`, `FromDecibels`, `GetDirectivityPattern`, `EstimateBeamwidth`, and `EstimateFrontToBackRatio`, ensuring accurate calculations and expected behavior across different scenarios. This addition enhances the overall test coverage for acoustic directionality functionalities.
…dSpeed classes

This commit introduces three new test classes: `AcousticImpedanceTests`, `ReflectionCoefficientTests`, and `SoundSpeedTests`. Each class includes comprehensive unit tests for their respective functionalities, covering methods such as impedance creation from various parameters, reflection and transmission coefficients, and conversions between units. These additions enhance the overall test coverage for acoustic and sound-related calculations, ensuring accurate behavior across different scenarios.
…flag from dotnet test command for improved test execution.
This commit introduces new test classes: `AcousticOperatorTests`, which verifies the frequency calculation from speed and wavelength, and `PhysicalDimensionExtensionsTests`, which includes comprehensive tests for converting various physical dimensions (length, mass, time, area, and volume) to base units. These additions enhance the overall test coverage for acoustic calculations and physical dimension conversions, ensuring accurate behavior across different scenarios.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
46.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@matt-edmondson
matt-edmondson merged commit 10bebdd into main Aug 25, 2025
@matt-edmondson
matt-edmondson deleted the remove-fluent-validation branch June 13, 2026 02:38
Damon3000s pushed a commit to Damon3000s/Semantics that referenced this pull request Jul 10, 2026
Adds a self-contained AudioEngineering value-type set in support of the
.NET VST3 effects host plan (upstream roadmap item ktsu-dev#2). These cover the
audio-engineering units the SI/Acoustic domains lack, so an effect's
parameters can be expressed as type-safe quantities with correct display
formatting and host-normalization mapping for free:

- Decibels<T> / Gain<T>: logarithmic level <-> linear amplitude (20·log10)
  and power (10·log10) conventions.
- Semitones<T> / Cents<T>: musical pitch intervals <-> frequency ratios
  (2^(n/12), 1200 cents/octave).
- QFactor<T>: filter Q <-> absolute bandwidth and bandwidth in octaves.
- Ratio<T> / Percent<T>: dimensionless ratios with lossless round-trip.
- NormalizedParameter<T> + ParameterTaper: maps host-normalized [0,1] <-> a
  typed value via linear, power-curve-skewed, logarithmic, or
  center-anchored tapers (Denormalize/Normalize/Clamp).

These are dimensionless/logarithmic and deliberately do not extend the
linear SI unit/dimension framework, so no core bootstrap/dimension/unit
files are touched — the change is purely additive. All types are generic
over INumber<T> following the library's double-based transcendental math
idiom, with comparison operators, friendly operator alternates, and
culture-invariant formatting.

Includes 19 MSTest cases covering conversions, round-trips, taper math,
clamping, and argument validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant