Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

  • Added Platform.Exceptions.Static.EnsureStatic with static methods for argument validation
  • Added Platform.Exceptions.Static.ThrowStatic with static methods for exception throwing
  • Created comprehensive tests demonstrating static usage patterns
  • Added example code showing traditional vs static extension usage patterns

Problem Solved

Issue #25 requested "Static extensions support in the programming language". This implementation allows developers to use C#'s using static directive for more convenient and cleaner exception handling syntax.

Usage Comparison

Before (traditional extension methods):

using Platform.Exceptions;

// Traditional usage
Ensure.Always.ArgumentNotNull(parameter, nameof(parameter));
Throw.A.NotSupportedException();

After (with static extensions):

using static Platform.Exceptions.Static.EnsureStatic;
using static Platform.Exceptions.Static.ThrowStatic;

// Cleaner static usage
ArgumentNotNull(parameter, nameof(parameter));
NotSupportedException();

Features Added

EnsureStatic class provides:

  • ArgumentNotNull<T>() - validates arguments are not null
  • ArgumentMeetsCriteria<T>() - validates arguments meet custom criteria

ThrowStatic class provides:

  • NotSupportedException() - throws NotSupportedException
  • NotImplementedException() - throws NotImplementedException
  • ArgumentNullException() - throws ArgumentNullException
  • ArgumentException() - throws ArgumentException
  • Return variants for use in expression contexts

Test plan

  • All existing tests continue to pass
  • New comprehensive test suite for static methods
  • Build succeeds without errors
  • Examples demonstrate usage patterns
  • Maintains backward compatibility with existing API

🤖 Generated with Claude Code


Resolves #25

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #25
@konard konard self-assigned this Sep 14, 2025
konard and others added 2 commits September 14, 2025 09:34
… usage

- Added Platform.Exceptions.Static.EnsureStatic with static methods for argument validation
- Added Platform.Exceptions.Static.ThrowStatic with static methods for exception throwing
- Created comprehensive tests demonstrating static usage patterns
- Added example code showing traditional vs static extension usage patterns
- Enables cleaner syntax: ArgumentNotNull(obj, "obj") instead of Ensure.Always.ArgumentNotNull(obj, "obj")

Resolves issue #25 requesting static extensions support in the programming language.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Static extensions support in the programming language is needed Add static extensions support for convenient 'using static' directive usage Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static extensions support in the programming language is needed

1 participant