Contributing¶
Build and test¶
dotnet build # whole solution
dotnet test # all tests across the three test projects
dotnet test tests/Filtering.Net.Generator.Tests --filter "FullyQualifiedName~CompositeValidate"
TreatWarningsAsErrors is on solution-wide. Build failures often surface as warning-promoted-to-error — read the actual message before suppressing.
Coding conventions¶
- Variable names spell things out.
validationErrorsnoterrs,requestedPageSizenotrps. The codebase consistently uses meaningful names; matching that style is a hard requirement. - Custom exception types only —
FilterValidationException,FilterDispatchException,FilterConfigurationException,FilterEmissionException. Never throwInvalidOperationException/UnreachableExceptionfrom production code. - Composite interfaces over capability splits —
IFilterDefinition<T>carries every Validate/ApplyFilter/ApplySorting overload; we don't split it intoIValidator+IPredicateBuilderetc. - Drop features over adding magic defaults — when a config combination is ambiguous, the design surfaces a diagnostic rather than guessing.
- One method per concern in the public DSL — e.g.,
For(...)and.Operator(...)are distinct steps; we don't overload a singleConfiguremethod that accepts both.
Adding a new diagnostic¶
- Add a
DiagnosticDescriptortosrc/Filtering.Net.Generator/Diagnostics/DiagnosticDescriptors.cswith the nextFN0xxx/FN1xxxid. - Append a row to the appropriate table in
docs/github/docs/diagnostics/index.md(errors or warnings). - Wire it into the relevant extractor / analyzer.
- Add a test under
tests/Filtering.Net.Generator.Tests/that asserts the diagnostic fires (and does not fire when the offending construct is removed).
Snapshot-test workflow¶
tests/Filtering.Net.Generator.Tests/Emission/Snapshots/ holds .verified.cs baselines under Verify.Xunit. When a generator change intentionally alters emitted output:
dotnet test— failing tests write.received.cssiblings.- Inspect each
.verified.csvs.received.csdiff and confirm semantic equivalence (diff -uwignores whitespace; non-whitespace differences must be traceable to the template/emitter change you intended). - Bless. PowerShell:
Get-ChildItem -Recurse -Filter '*.received.cs' |
ForEach-Object { Move-Item -Force $_ ($_ -replace '\.received\.cs$', '.verified.cs') }
Bash:
- Re-run
dotnet testto confirm green.
Compile-and-run and runtime-behaviour tests (*_Compiles, EmittedCodeCompilesTests, EndToEndRuntimeTests) MUST stay green at every step — only snapshot diffs may go red mid-refactor.