Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 13, 2025

Summary

This PR fixes the transformation of C# readonly fields to properly use const in C++ output, addressing issue #56.

Changes Made

  • Updated the regex pattern on line 127 in CSharpToCppTransformer.cs to include const in the replacement string for string types
  • The pattern (const|static readonly) string now correctly outputs inline static const std::string instead of inline static std::string
  • Line 130 already handled non-string types correctly with const output

Before

public: inline static std::string ExceptionContentsSeparator = "---";

After

public: inline static const std::string ExceptionContentsSeparator = "---";

Testing

  • All existing unit tests pass
  • Added test cases in experiments/ folder to verify the transformation works correctly
  • Verified that both readonly and const C# keywords are now properly converted to const in C++

Test Plan

  • Run existing unit tests (dotnet test)
  • Create and run transformation tests with various readonly field types
  • Verify string types now output with const
  • Verify non-string types continue to work correctly
  • Confirm no regressions in existing transformations

🤖 Generated with Claude Code


Resolves #56

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

Issue: #56
@konard konard self-assigned this Sep 13, 2025
- Updated regex pattern on line 127 to include 'const' in the replacement string
- This ensures that both 'readonly' and 'const' C# keywords are converted to 'const' in C++
- Added test cases in experiments/ folder to verify the transformation works correctly
- All existing tests continue to pass

Resolves issue #56

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] readonly should be converted to const Fix: Convert readonly to const in C++ transformations Sep 13, 2025
@konard konard marked this pull request as ready for review September 13, 2025 13:38
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.

readonly should be converted to const

1 participant