Skip to content

Modernize solutions, improve documentation, and enhance CI workflows - #16

Open
wforney wants to merge 74 commits into
sunduk:masterfrom
wforney:main
Open

Modernize solutions, improve documentation, and enhance CI workflows#16
wforney wants to merge 74 commits into
sunduk:masterfrom
wforney:main

Conversation

@wforney

@wforney wforney commented Jul 26, 2026

Copy link
Copy Markdown

This pull request introduces comprehensive repository-wide improvements to developer experience, automation, and documentation. It establishes clear guidance for agents and contributors, adds CI workflows for build/test/coverage, and ensures protocol and threading invariants are well-documented and enforced. Several configuration and helper files are added for local development, Copilot, and MCP integration. It also adds a basic test project for the sample client.

Repository guidance and conventions

  • Added AGENTS.md, .clinerules, .cursorrules, and CLAUDE.md to define canonical repository instructions, protocol/threading constraints, and agent priorities. These files centralize rules for packet compatibility, threading, protocol IDs, and PR workflow. [1] [2] [3] [4]
  • Added .github/copilot-instructions.md for Copilot-specific build, test, and protocol conventions, and .github/prompts/ with prompt templates for manual testing and protocol-safe changes. [1] [2] [3]

Continuous Integration and PR workflow

  • Introduced .github/workflows/build-test.yml for CI: builds, tests, and collects coverage for both FreeNet.slnx and viruswar_server.slnx on PRs and pushes. Coverage is summarized and commented on PRs.
  • Added a standardized pull request template (.github/PULL_REQUEST_TEMPLATE.md) to guide contributors in documenting changes, testing, and risk.

Local development and configuration

  • Added .vscode/tasks.json for one-click restore, build, and run tasks for main and sample projects.
  • Provided .mcp.json.example and .github/mcp-setup.md for easy Model Context Protocol (MCP) integration and setup. [1] [2]

Testing improvements

  • Added a new test project CSampleClient.Tests with a basic protocol stability test, and updated CSampleClient to .NET 10 and enabled implicit usings. [1] [2] [3]

Other

  • Added .contextkeeper/.git-branches/main.ck for context preservation in compatible tools.

These changes collectively improve onboarding, enforce protocol safety, automate CI, and clarify expectations for all contributors and agents.

Comment thread FreeNet/CNetworkService.cs Outdated
return;
}

while (e.BytesTransferred > 0 && e.SocketError == SocketError.Success)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps the same semantics as before, but fixes the stack overflow. But it never gets to the try below. Is that intentional or just a logic bomb?

wforney and others added 7 commits July 26, 2026 07:10
Major refactor replacing legacy C-style class names with modern .NET/C# conventions (e.g., UserToken, Packet, NetworkService). All core networking, packet, and session management classes rewritten using modern C# features, improved encapsulation, and clearer APIs. Method and interface names updated to PascalCase. Buffer, queue, and pool management reimplemented for thread safety and clarity. Message resolver and packet serialization logic refactored. All sample and game server code updated to use new types and APIs. Added .editorconfig for consistent style enforcement. All references to old C* types replaced. Improved access modifiers, collection usage, and synchronization. Codebase now aligns with modern C# best practices for maintainability and readability.
Refactored CSampleServer for modern C# conventions and improved encapsulation:
- Made CGameUser internal, applied explicit interface implementation, and renamed fields/methods to C# standards.
- Removed legacy code, unused usings, and redundant comments.
- Converted Program.cs to top-level statements; user management and session creation are now static methods with thread-safe user list.
- Moved and simplified protocol enum under CSampleServer namespace.
- Updated all references to match new structure and naming.
- main.ck now opens CGameUser.cs instead of UserToken.cs.
- Minor formatting and comment improvements throughout.
Refactored client and server code for clarity and modern C# style:
- Renamed CGameUser to GameUser and CRemoteServerPeer to RemoteServerPeer, updating all references.
- Moved RemoteServerPeer to its own file and modernized its implementation.
- Updated client and server Program.cs to use top-level statements and simplified logic.
- Declared protocol enum directly in CSampleClient namespace.
- Modernized method signatures and removed unused usings/comments.
- Updated test and solution metadata for new file names and line numbers.
Major refactor replacing legacy C-style classes with idiomatic C#:
- Renamed all core types to PascalCase and updated to use properties, modern collections, and expression-bodied members.
- Introduced StateManager<T, T2> and MessageDispatcher<T, T2> for improved state and message handling.
- Updated IState/IUserState interfaces and separated room/user state logic into dedicated files.
- Moved protocol enum and logic to protocol.cs with better docs.
- Refactored Vector2 as a struct with operator overloads.
- Updated .editorconfig for modern C# style enforcement.
- Updated tests and entry point to use new types.
- Removed legacy files and added favorites.json for .editorconfig.
This improves maintainability, readability, and aligns with C# best practices.
Refactored codebase for modern C# conventions:
- Used 'var' for obvious types.
- Converted simple methods to expression-bodied members.
- Updated test assertions to discard results with '_ = await ...'.
- Reordered and moved test methods for clarity.
- Removed unused usings and improved formatting.
- Renamed variables for clarity.
No functional changes; all updates are stylistic.
- Added extensive unit tests for FreeNet and VirusWar server: core infra, network service, session lifecycle, and game logic.
- Set logic thread as background for test isolation.
- Improved UserToken.Close() with null checks to prevent NREs.
- Ensure UserToken.ProcessSend always closes on send failure.
- Added InternalsVisibleTo for test assemblies.
- Updated main.ck for active document path change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wforney added 21 commits July 27, 2026 02:43
All comments and XML docs in UserToken.cs are now in English for improved readability and maintainability. Inline comments and method summaries clarify protocol handling, state meanings, and method purposes. Minor code cleanups include expression-bodied members for simple methods, use of null-conditional operators for null checks, and modernized variable declarations with var. No functional changes were made; all logic remains unchanged.
Introduced a Protocol project to unify protocol enums, message types, and serialization logic. Refactored CSampleClient and CSampleServer to use strongly-typed protocol messages and the new PacketProtocol enum. Added movement and user info protocol messages with serialization/deserialization. Removed legacy protocol.cs files. Added Protocol.Tests for protocol stability and message round-trip tests. Updated FreeNet.slnx, improved documentation, and revised connection logic and user handling. Added Tizen workload install script and updated README.md.
Added <TUnitReflectionScanner>true</TUnitReflectionScanner> to the main PropertyGroup of all test .csproj files to enable TUnit reflection scanning for test discovery and execution. Affected projects: CSampleClient.Tests, CSampleServer.Tests, FreeNet.Tests, Protocol.Tests, and GameServer.Tests.
The ToInboundPacket method in ProtocolMessageTests.cs now calls PopProtocolId() after creating the inbound Packet, ensuring the protocol id is consumed before returning. This change makes test parsing behavior consistent with real-world usage, where the protocol id is read prior to message-specific fields.
Replaced all Korean comments and docstrings with English equivalents for improved accessibility. Added or updated English XML documentation and inline comments for major classes, methods, and protocol definitions. Performed minor code cleanups, including discard assignments for unused return values and more idiomatic variable naming. Reorganized and renamed test methods in NetworkServiceTests.cs for clarity. No functional changes; all updates are documentation, comment, or style improvements to enhance maintainability and international readability.
Refactored Vector2 struct to use PascalCase property names (X, Y) and updated all references. Standardized variable declarations to use var for clarity. Simplified test code with collection expressions, null-coalescing checks, and concise lambdas. Updated test assertions to use null-conditional access where appropriate.
Migrated the InternalsVisibleTo attribute from AssemblyInfo.cs to the FreeNet.csproj file using the <InternalsVisibleTo> MSBuild property. This modernizes the project by following SDK-style .NET conventions and enables FreeNet.Tests to access internal members.
Refactored parameter and variable names for consistency (e.g., networkService, remoteEndpoint), improved XML documentation throughout, and moved the Defines class to its own file and namespace. Enhanced encapsulation and naming in DoubleBufferingQueue, updated interface/method signatures, and replaced legacy comments. Fixed minor bugs, typos, and added missing braces for improved code clarity and maintainability.
Refactored Connector, Listener, and NetworkService to use C# events instead of delegate properties for connection/session callbacks, improving composability and thread safety. Modernized Connector with async ConnectAsync, updated Listener to async accept loop with cancellation, and revised tests and samples for event-based wiring. Includes minor cleanup and improved error handling.
Refactored connection/session lifecycle to use standard .NET EventHandler<TEventArgs> patterns with new strongly-typed event args classes, replacing custom delegate events. Modernized async I/O by removing SAEA pooling and BufferManager, adopting System.IO.Pipelines for all send/receive logic in UserToken. Updated all usages, tests, and sample code to match the new event and pipelines model. Enabled nullable reference types, cleaned up obsolete code, and updated documentation including a new README section on pipelines.
The <ItemGroup> referencing <Folder Include="Examples\" /> was removed from the project file. This folder inclusion is unnecessary for build or reference purposes and its removal simplifies the project structure. No other changes were made.
Renamed protocol message classes for consistency (e.g., SCMoveCast → MoveCast, CSMoveReq → MoveRequest, SCUserInfo → UserInfo) and updated all usages. Switched from AProtocolMessage<T> to ProtocolMessage<T> as the base class. Adjusted method signatures, type constraints, and serialization logic. Removed obsolete CSMoveReq class and improved XML documentation for clarity.
Refactored session lifecycle events to use a new SessionEventArgs class instead of the generic EventArgs<T>, updating all usages and event handler signatures. Removed EventArgs<T> and exposed UserToken directly via SessionEventArgs. Changed MessageResolver's callback to Action<ArraySegment<byte>> for simplicity. Improved input handling and comments for clarity.
Refactored LogicMessageEntry to use System.Threading.Channels for async message dispatch, replacing AutoResetEvent and double-buffered queue. Added Stop() methods to LogicMessageEntry and NetworkService for clean shutdown of logic dispatch, listener, and heartbeat. Improved nullability and defensive checks in GameRoom and tests. Updated session pipeline startup and code style for clarity. Added XML docs to ServerUserManager.
All code comments, UI strings, protocol/state descriptions, and documentation have been translated from Korean to English. Korean text has been removed from C# source files, UI/game messages, protocol enums, and state classes. Documentation files (`README.md`, `TestManual.md`) are now English-only. Added `KOREAN_TEXT_REPORT.md` to summarize the changes. Minor code cleanups include updating `Helper.cs` and replacing the custom `Vector2` struct with `System.Numerics.Vector2`. These changes improve accessibility for English-speaking developers and users.
Deleted the KOREAN_TEXT_REPORT.md file, which included the inventory of Korean text extraction, counts of Korean text entries in C# files, and listings of Korean text found in README.md and TestManual.md. This file is no longer needed in the repository.
Updated <VersionPrefix>, <AssemblyVersion>, and <FileVersion> in Directory.Build.props from 0.1.2 to 0.2.0 to signal a new minor release, indicating new features or breaking changes.
Added a LICENSE file containing the MIT License text. The license specifies terms for use, distribution, and liability, and attributes copyright to "FreeNet Contributors" for the year 2026.
- Rewrote README.md version history for clarity and detail, using bold headings and bullet points per release.
- Expanded v0.2.0 entry to highlight System.IO.Pipelines migration, new async APIs, and backward compatibility.
- Updated license section to explicitly state MIT License and link to LICENSE file.
- Added PIPELINES_MODERNIZATION.md documenting the migration to System.IO.Pipelines in v0.2.0, including startup, send/receive loop changes, shutdown semantics, and compatibility notes.
- Included references to updated versioning and Microsoft documentation.
Updated README.md to remove that the new async I/O using pipelines is backward compatible with existing SAEA-based implementations. The SAEA-based implementation has been removed. Also added README.md to favorites.json for easier access.
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.

5 participants