V10.1.1/fix semver - #33
Conversation
Extended SemanticApiVersion to support equality and hashing with standard ApiVersion when patch version is zero and no prerelease or build metadata is present. Updated SemanticApiVersionParser to accept shorthand semantic version formats (major only, or major.minor) in addition to full major.minor.patch format.
Added comprehensive unit test coverage for SemanticApiVersion compatibility with standard ApiVersion. Tests verify equality, hash code consistency, and parser support for shorthand semantic version formats (major only and major.minor).
Introduced Codebelt.Extensions.Asp.Versioning.FunctionalTests project with end-to-end test scenarios covering production and non-production compatibility use cases. Tests verify semantic version behavior across real middleware and application context. Updated solution file to include the new test project.
Updated namespace documentation and DocFX publishing configuration to reflect semantic version compatibility feature. Clarified behavior of SemanticApiVersion equality and comparison semantics. Updated site navigation and doc build metadata.
Greptile SummaryThis PR improves
Confidence Score: 3/5The core library changes are well-reasoned and backed by new unit tests, but the NonProduction functional test class has a constructor that references the wrong type and will run its tests against the wrong host setup. The test/Codebelt.Extensions.Asp.Versioning.FunctionalTests/SemanticApiVersionNonProduction.cs — wrong type argument in base constructor call Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["SemanticApiVersion.Equals(ApiVersion other)"] --> B{other is SemanticApiVersion?}
B -- Yes --> C["Compare Major, Minor, Patch,\nPrerelease, BuildMetadata\n(full SemVer identity)"]
B -- No --> D{other is null?}
D -- Yes --> E["return false"]
D -- No --> F{IsCompatibleWithStandardApiVersion?\nPatch==0 && no Prerelease && no BuildMetadata}
F -- No --> G["return false"]
F -- Yes --> H{Major & Minor match? Status empty?}
H -- Yes --> I["return true (equal to standard ApiVersion)"]
H -- No --> J["return false"]
K["SemanticApiVersionParser.TryReadCore(text)"] --> Q{Dots found?}
Q -- No dot --> R["major only, minor=0, patch=0"]
Q -- One dot --> S["major.minor, patch=0"]
Q -- Two dots --> T["major.minor.patch (original)"]
Q -- More than two --> U["return false"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["SemanticApiVersion.Equals(ApiVersion other)"] --> B{other is SemanticApiVersion?}
B -- Yes --> C["Compare Major, Minor, Patch,\nPrerelease, BuildMetadata\n(full SemVer identity)"]
B -- No --> D{other is null?}
D -- Yes --> E["return false"]
D -- No --> F{IsCompatibleWithStandardApiVersion?\nPatch==0 && no Prerelease && no BuildMetadata}
F -- No --> G["return false"]
F -- Yes --> H{Major & Minor match? Status empty?}
H -- Yes --> I["return true (equal to standard ApiVersion)"]
H -- No --> J["return false"]
K["SemanticApiVersionParser.TryReadCore(text)"] --> Q{Dots found?}
Q -- No dot --> R["major only, minor=0, patch=0"]
Q -- One dot --> S["major.minor, patch=0"]
Q -- Two dots --> T["major.minor.patch (original)"]
Q -- More than two --> U["return false"]
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
==========================================
- Coverage 99.60% 99.24% -0.36%
==========================================
Files 10 10
Lines 510 533 +23
Branches 82 89 +7
==========================================
+ Hits 508 529 +21
- Misses 2 4 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| public SemanticApiVersionNonProduction(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output, typeof(SemanticApiVersionProduction)) | ||
| { | ||
| } |
There was a problem hiding this comment.
Wrong type reference in base constructor call
The constructor passes typeof(SemanticApiVersionProduction) instead of typeof(SemanticApiVersionNonProduction). If MinimalWebHostTest uses this type to key or scope the managed test host instance (as the name ManagedWebMinimalHostFixture suggests), both classes will share the same host scope — meaning SemanticApiVersionNonProduction will get a host configured with the routes and settings from SemanticApiVersionProduction rather than its own. This would cause every SemanticApiVersionNonProduction test to run against the wrong application configuration.
| public SemanticApiVersionNonProduction(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output, typeof(SemanticApiVersionProduction)) | |
| { | |
| } | |
| public SemanticApiVersionNonProduction(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output, typeof(SemanticApiVersionNonProduction)) | |
| { | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/Codebelt.Extensions.Asp.Versioning.FunctionalTests/SemanticApiVersionNonProduction.cs
Line: 37-39
Comment:
**Wrong type reference in base constructor call**
The constructor passes `typeof(SemanticApiVersionProduction)` instead of `typeof(SemanticApiVersionNonProduction)`. If `MinimalWebHostTest` uses this type to key or scope the managed test host instance (as the name `ManagedWebMinimalHostFixture` suggests), both classes will share the same host scope — meaning `SemanticApiVersionNonProduction` will get a host configured with the routes and settings from `SemanticApiVersionProduction` rather than its own. This would cause every `SemanticApiVersionNonProduction` test to run against the wrong application configuration.
```suggestion
public SemanticApiVersionNonProduction(ManagedWebMinimalHostFixture hostFixture, ITestOutputHelper output) : base(hostFixture, output, typeof(SemanticApiVersionNonProduction))
{
}
```
How can I resolve this? If you propose a fix, please make it concise.
This pull request introduces enhanced support for semantic API versioning, improves compatibility with standard API versions, and adds comprehensive functional tests to ensure correct routing and negotiation based on various version formats. It also includes minor documentation and configuration updates.
Semantic API Versioning Improvements:
Updated
SemanticApiVersionto improve compatibility with standardApiVersionby adding theIsCompatibleWithStandardApiVersionmethod and refining the logic inGetHashCodeandEqualsto handle standard and semantic versions more robustly. [1] [2] [3]Enhanced
SemanticApiVersionParserto correctly parse numeric and dotted version formats, supporting both short and full semantic version strings.Functional Testing Enhancements:
Codebelt.Extensions.Asp.Versioning.FunctionalTestswith tests for semantic version compatibility and non-production scenarios, ensuring correct routing, negotiation, and status codes for various HTTP methods and version formats. [1] [2] [3]Documentation and Configuration Updates:
Updated
.docfx/toc.ymland.docfx/docfx.jsonto fix links and adjust file exclusions for documentation generation. [1] [2]Added the new functional test project to the solution file
Codebelt.Extensions.Asp.Versioning.slnx.