Skip to content

Add [MemberNotNullWhen] to Result.IsSuccess/IsFailure #1

Description

@andregoepel

Discovered while rolling out `TreatWarningsAsErrors` in `andregoepel/finance-app`: its own local `Result` class (the one `AndreGoepel.Core.Result` was modeled after) had to add `[MemberNotNullWhen(true, nameof(Error))]` to `IsFailure` to compile cleanly under strict nullable warnings — `if (result.IsFailure) { UseError(result.Error); }` otherwise triggers CS8602 (possible null dereference), which is a build error under `TreatWarningsAsErrors`.

Since this repo's own `Directory.Build.props` already sets `TreatWarningsAsErrors`, and every future consumer of this package is expected to do the same (per the shared `.claude-shared/dotnet-conventions.md` Warnings section), this needs to land in the canonical type — otherwise every repo migrating onto `AndreGoepel.Core.Result` (finance-app #58, customer-portal #81, marten-identity #148) hits the same warning on day one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions