Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 13, 2025

Summary

This PR resolves issue #63 by renaming the Ensure class to Contract to avoid naming conflicts with external libraries like Ensure.That.

Problem

The existing Ensure class conflicts with the popular Ensure.That library, making it difficult for users to use both libraries in the same project. The issue specifically mentioned that this conflict could complicate code translation to C++.

Solution

  • Renamed EnsureContract across the entire codebase
  • Updated extension root classes: EnsureAlwaysExtensionRootContractAlwaysExtensionRoot, EnsureOnDebugExtensionRootContractOnDebugExtensionRoot
  • Updated all extension methods to work with the new classes
  • Updated both C# and C++ implementations to maintain consistency
  • Updated all tests to use the new API

API Changes

Before:

Ensure.Always.ArgumentNotNull(argument, "argumentName");
Ensure.OnDebug.ArgumentNotNull(argument, "argumentName");

After:

Contract.Always.ArgumentNotNull(argument, "argumentName");
Contract.OnDebug.ArgumentNotNull(argument, "argumentName");

C++ Changes:

// Before
Platform::Exceptions::Ensure::Always::ArgumentNotNull(ptr, "ptr");

// After  
Platform::Exceptions::Contract::Always::ArgumentNotNull(ptr, "ptr");

Testing

  • ✅ All C# tests pass (2/2)
  • ✅ Build succeeds with no errors
  • ✅ Maintains same functionality and performance characteristics
  • ✅ Extension mechanism works identically

Breaking Changes

This is a breaking change that requires users to update their code from Ensure to Contract. However, the API pattern and functionality remain exactly the same.

Benefits

  • ✅ Resolves naming conflicts with external libraries
  • ✅ Allows users to use both Platform.Exceptions and Ensure.That together
  • ✅ Maintains consistency between C# and C++ implementations
  • ✅ Uses a semantically appropriate name (Contract is commonly used for assertion libraries)

Fixes #63

🤖 Generated with Claude Code

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

Issue: #63
@konard konard self-assigned this Sep 13, 2025
konard and others added 2 commits September 13, 2025 09:02
This change resolves issue #63 by renaming the Ensure class to Contract
to avoid conflicts with external libraries like Ensure.That.

Changes made:
- Renamed Ensure class to Contract in both C# and C++
- Updated all extension root classes (EnsureAlwaysExtensionRoot -> ContractAlwaysExtensionRoot)
- Updated all extension methods and their references
- Updated all test files and namespaces
- Maintained the same API pattern (Contract.Always and Contract.OnDebug)

The new API usage:
- Contract.Always.ArgumentNotNull(argument, "argumentName")
- Contract.OnDebug.ArgumentNotNull(argument, "argumentName")

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

Co-Authored-By: Claude <[email protected]>
- Renamed C++ namespaces from Platform::Exceptions::Ensure to Platform::Exceptions::Contract
- Updated all C++ test files to use the new Contract namespace
- Maintained consistency between C# and C++ implementations

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] May be we should undesing the Ensure Rename Ensure class to Contract to resolve naming conflicts Sep 13, 2025
@konard konard marked this pull request as ready for review September 13, 2025 06:03
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.

May be we should undesing the Ensure

1 participant