Referential transparency
Methods marked with [PureMethod] are checked for mutable static state, non-pure calls, and I/O operations.
diff --git a/docs/assets/site.css b/docs/assets/site.css new file mode 100644 index 0000000..bf4762d --- /dev/null +++ b/docs/assets/site.css @@ -0,0 +1 @@ +*{box-sizing:border-box}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.6;color:#1f2937;background:#fff}body{margin:0}a{color:#2563eb}header{border-bottom:1px solid #e5e7eb;background:#f8fafc}nav{max-width:1040px;margin:auto;padding:1rem 1.25rem;display:flex;justify-content:space-between;gap:1rem;align-items:center}nav span{display:flex;gap:1rem;flex-wrap:wrap}.brand{font-weight:700;text-decoration:none;color:#111827}main{max-width:1040px;margin:auto;padding:2rem 1.25rem 4rem}.hero{padding:3rem 0 2rem}.eyebrow{text-transform:uppercase;letter-spacing:.08em;font-size:.82rem;font-weight:700;color:#475569}.lead{font-size:1.25rem;max-width:760px}h1{font-size:clamp(2.2rem,6vw,4rem);line-height:1.05;margin:.3rem 0 1rem}h2{margin-top:2.4rem}h3{margin-top:0}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:1rem}.grid article{border:1px solid #e5e7eb;border-radius:12px;padding:1.2rem;background:#f8fafc}.button{display:inline-block;padding:.7rem 1rem;border-radius:8px;background:#111827;color:white;text-decoration:none;margin:.25rem .35rem .25rem 0}.button.secondary{background:#475569}code,pre{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}pre{overflow:auto;padding:1rem;border-radius:10px;background:#111827;color:#f8fafc}table{width:100%;border-collapse:collapse;margin-top:1rem}th,td{padding:.7rem;border-bottom:1px solid #e5e7eb;text-align:left;vertical-align:top}footer{border-top:1px solid #e5e7eb;padding:2rem 1.25rem;color:#64748b}footer p{max-width:1040px;margin:auto}@media(max-width:640px){nav{align-items:flex-start;flex-direction:column}.hero{padding-top:2rem}table{font-size:.92rem}} \ No newline at end of file diff --git a/docs/diagnostics.html b/docs/diagnostics.html new file mode 100644 index 0000000..b71f48c --- /dev/null +++ b/docs/diagnostics.html @@ -0,0 +1,24 @@ + + +
+ +PureSharp exposes seven documented diagnostics across referential transparency, local-variable purity, naming, and FluentIf validation.
+| ID | Purpose | Default |
|---|---|---|
| RT0001 | Static mutable field access in [PureMethod] | Error |
| RT0002 | Non-pure method call in [PureMethod] | Error |
| RT0003 | I/O operation in [PureMethod] | Error |
| LVP0001 | Reassignment to an immutable local | Error |
| LVP0002 | Immutable local missing declaration-time initialization | Error |
| LVP0003 | Suggestion for an effectively immutable local | Warning |
| FIF0001 | FluentIf chain not terminated with .Else(...) | Error |
[*.cs]
+dotnet_diagnostic.RT0001.severity = error
+dotnet_diagnostic.LVP0003.severity = warning
+For the complete diagnostic contract, triggering conditions, compatibility rules, and message semantics, read docs/DIAGNOSTICS.md.
Annotate methods with [PureMethod] to ask PureSharp to verify selected referential-transparency constraints. The analyzer reports mutable static field access, calls to methods that are not known to be pure, and I/O operations inside marked methods.
PureSharp uses an explicit naming convention for immutable locals: names beginning with an underscore are treated as immutable variables. They must be initialized at declaration and cannot be reassigned. Effectively immutable ordinary locals can also receive a naming suggestion.
Fluent.If provides expression-oriented conditional flow. The analyzer verifies that a chain is terminated with .Else(...), preventing incomplete fluent conditions from becoming unnoticed logic errors.
PureSharp diagnostics appear during normal IDE analysis and dotnet build. Severity can be configured with standard dotnet_diagnostic.<ID>.severity settings in .editorconfig.
Functional programming support for C#
A Roslyn-based toolset that brings compile-time checks for referential transparency, local-variable immutability, and safer functional-style control flow to C#.
PureSharp helps developers make purity and immutability explicit and mechanically verifiable instead of relying only on conventions and code review.
Methods marked with [PureMethod] are checked for mutable static state, non-pure calls, and I/O operations.
Locals using PureSharp's underscore convention can be required to initialize once and never be reassigned.
Fluent.If chains are checked so incomplete conditional expressions do not silently escape validation.
C# supports functional programming techniques, but the language does not mechanically enforce referential transparency or immutable local variables. PureSharp uses Roslyn diagnostics to turn selected functional-programming constraints into build-time feedback.
Diagnostics use standard .editorconfig severity controls. PureSharp is MIT licensed and its analyzer behavior is documented in a versioned diagnostic contract.