Skip to content

Use the real API names in the README samples and reference [patch] - #178

Open
matt-edmondson wants to merge 2 commits into
mainfrom
fix/138-readme-samples
Open

matt-edmondson wants to merge 2 commits into
mainfrom
fix/138-readme-samples

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #138

What was wrong

README.md is also the nuget.org package page, and most of its C# samples didn't compile:

Was Now
TextFilter.Match(...) TextFilter.IsMatch(...)
MatchOptions.AnyWord / AllWords / WholeString TextFilterMatchOptions.ByWordAny / ByWordAll / ByWholeString
FilterType.Glob / Regex / Fuzzy TextFilterType.Glob / Regex / Fuzzy
Default match option documented as WholeString ByWordAny, as in the method signatures
Rank(..., MatchOptions options) in the API reference the real Rank(strings, fuzzyFilter) and Rank<TItem>(items, keySelector, fuzzyFilter)
Acknowledgement links ktsu-io/ktsu.FuzzySearch ktsu-dev/FuzzySearch

The API reference now also lists the IsMatch(..., out int score, ...) overload, Filter<TItem> and GetHint. The Match Options sample now shows the result of each call: true, false, false under the default case-sensitive matching.

Test

TextFilter.Test/ReadmeTests.cs reads the README and checks it against the library by reflection:

  • every Type.Member in a C# block (after stripping string literals and // comments) must be a public static member of a ktsu.TextFilter type
  • every method in the API reference table must exist, and every default it documents must match the parameter's real default
  • the Match Options, Basic and Filter Types samples return the results shown

I ran the new tests against the old README and two of them failed, naming exactly the problems in the issue:

README samples use names the library doesn't define: TextFilter.Match, MatchOptions.AnyWord, MatchOptions.AllWords, MatchOptions.WholeString, FilterType.Glob, FilterType.Regex, FilterType.Fuzzy
Match does not exist; Filter has no parameter options; Filter(filterType) is documented as defaulting to FilterType.Glob; Rank has no parameter options

With the new README, the full suite passes (218/218).

Open PR #163 adds a "Glob Character Classes" section next to the Case Sensitivity section. This PR doesn't touch those lines.


Generated by Claude Code

The README samples called TextFilter.Match, MatchOptions.* and FilterType.*,
none of which exist, so every first sample a new user copied failed with
CS0117/CS0103. The API reference documented WholeString as the default match
option (it is ByWordAny) and a Rank overload that takes match options (there
is none), and the FuzzySearch acknowledgement linked the old ktsu-io repo.

The samples now use IsMatch, TextFilterType and TextFilterMatchOptions. The
reference lists the real IsMatch, Filter, Rank and GetHint overloads with
their defaults, and the enum tables mark which value is the default.

ReadmeTests checks every Type.Member in the README's C# blocks, and every
method and default in the API reference table, against the library by
reflection, so the README can't drift from the API again unnoticed.

Fixes #138

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5rmwEcdN9nYifxAwK
Comment thread TextFilter.Test/ReadmeTests.cs Fixed
Comment thread TextFilter.Test/ReadmeTests.cs Fixed
Path.Combine drops earlier segments when a later one is rooted; Path.Join
doesn't, and matches how the other ktsu test suites build these paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5rmwEcdN9nYifxAwK
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant