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.
Immutable local variables
Locals using PureSharp's underscore convention can be required to initialize once and never be reassigned.
Fluent conditional flow
Fluent.If chains are checked so incomplete conditional expressions do not silently escape validation.
+
Why use it?
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.
+
Open source and configurable
Diagnostics use standard .editorconfig severity controls. PureSharp is MIT licensed and its analyzer behavior is documented in a versioned diagnostic contract.
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.
+
Immutable local variables
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.
+
FluentIf
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.
+
Roslyn-native workflow
PureSharp diagnostics appear during normal IDE analysis and dotnet build. Severity can be configured with standard dotnet_diagnostic.<ID>.severity settings in .editorconfig.
+
Project components
PureSharp.Core — attributes and runtime utilities.