8.5 KiB
GitHub Copilot Instructions for mRemoteNG
Project Overview
mRemoteNG is an open-source, multi-protocol, tabbed remote connections manager for Windows. It's a fork of mRemote that allows users to view and manage all their remote connections (RDP, VNC, SSH, Telnet, HTTP/HTTPS, rlogin, Raw Socket, PowerShell remoting, AnyDesk) in a simple yet powerful interface.
Technology Stack
- Language: C# with latest language version
- Framework: .NET 10.0 for Windows (net10.0-windows10.0.26100.0)
- UI Framework: Windows Forms with WPF support
- Target Platforms: x64 and ARM64
- Testing Framework: NUnit with NSubstitute for mocking
- Build System: MSBuild with .NET SDK-style projects
Building the Project
Prerequisites
- Visual Studio 2022 (version 17.14.12 or later)
- .NET 10.0 Desktop Runtime
- Windows 10/11 or Windows Server 2016+
Build Commands
# Restore NuGet packages
dotnet restore
# Build the solution
msbuild mRemoteNG.sln -p:Configuration=Release -p:Platform=x64
# Or for ARM64
msbuild mRemoteNG.sln -p:Configuration=Release -p:Platform=arm64
Running Tests
The project uses NUnit for testing. Test projects are in mRemoteNGTests/ directory.
dotnet test mRemoteNGTests/mRemoteNGTests.csproj
Code Organization
Main Projects
- mRemoteNG: Main application project
- mRemoteNGTests: Unit and integration tests
- mRemoteNGSpecs: Specification tests
- ObjectListView.NetCore: Custom list view control
- ExternalConnectors: External protocol connector implementations
- mRemoteNGDocumentation: reStructuredText documentation
Key Directories in mRemoteNG Project
App/: Application startup and initializationConnection/: Connection models, protocols, and managementConfig/: Configuration and serialization (XML, CSV)Container/: Container/folder node implementationsCredential/: Credential storage and repositoriesLanguage/: Localization resource files (.resx)Security/: Authentication, encryption, and password managementTree/: Connection tree UI and managementUI/: User interface components and formsTools/: Utility classes and helpers
Code Style and Conventions
EditorConfig Settings
The project uses EditorConfig (.editorconfig in mRemoteNG/ directory) with these key rules:
- Indentation: 4 spaces (no tabs)
- Line Endings: CRLF (Windows-style)
- Charset: UTF-8 with BOM for C# files
- New Lines: Opening braces on new lines (Allman style)
- Using Directives: Sort System directives first
- this. Qualifier: Do not use
this.prefix unless necessary
Naming Conventions
- Classes/Interfaces: PascalCase (e.g.,
ConnectionInfo,IInheritable) - Methods: PascalCase (e.g.,
GetConnection,SaveToXml) - Properties: PascalCase (e.g.,
ConnectionName,Port) - Fields: Use camelCase for private fields, consider
_prefix for backing fields - Constants: PascalCase
Code Patterns
Inheritance System
mRemoteNG has a sophisticated property inheritance system for connection settings:
- Properties can be inherited from parent containers/folders
- Each inheritable property has a corresponding
Inherit<PropertyName>boolean inConnectionInfoInheritanceclass - Use
IInheritableinterface for objects that support inheritance - Example:
ConnectionFrameColorproperty hasInheritConnectionFrameColorboolean
Serialization
The project supports multiple serialization formats:
XML Serialization (Config/Serializers/ConnectionSerializers/Xml/):
- Node-based serializers (e.g.,
XmlConnectionNodeSerializer28.cs) - Deserializers handle backward compatibility
- Attributes for properties and inheritance flags
- Always maintain backward compatibility - old files must still load
CSV Serialization (Config/Serializers/ConnectionSerializers/Csv/):
- Export connections to CSV format
- Include both value and inheritance columns
- Maintain column order consistency
Localization
All user-facing strings must be localized:
- Add entries to
Language/Language.resx(English base) - Use
Language.ResourceNameto access strings in code - Resource naming:
- Properties:
PropertyName(e.g.,ConnectionFrameColor) - Descriptions:
PropertyDescription<PropertyName> - Enum values:
<EnumName><Value>(e.g.,FrameColorRed)
- Properties:
- Provide clear, concise descriptions for PropertyGrid tooltips
Common Patterns
Adding a New Connection Property
- Add enum (if needed) in
Connection/directory - Add property to
AbstractConnectionRecord.csorConnectionInfo.cs- Add
[Category("CategoryName")]attribute for PropertyGrid grouping - Add
[Description("Language.PropertyDescription<Name>")]for tooltip - Use appropriate TypeConverter if needed
- Add
- Add inheritance support in
ConnectionInfoInheritance.cs - Update serializers:
- XML: Update latest
XmlConnectionNodeSerializer*.csandXmlConnectionsDeserializer.cs - CSV: Update
CsvConnectionsSerializerMremotengFormat.cs
- XML: Update latest
- Add localization in
Language/Language.resx - Write tests in
mRemoteNGTests/Connection/ - Update documentation in
mRemoteNGDocumentation/if user-facing
UI Controls
- Prefer existing mRemoteNG patterns for UI controls
- Connection panels use
InterfaceControlbase class - Custom painting: Override
OnPaintor handlePaintevent - Follow Windows Forms best practices
Testing Guidelines
Test Structure
- Use NUnit's
[Test]attribute for test methods - Use
[SetUp]and[TearDown]for test initialization/cleanup - Use
[TestCase]for parameterized tests - Use NSubstitute for mocking:
Substitute.For<IInterface>()
Test Naming
- Use descriptive names:
MethodName_Scenario_ExpectedBehavior - Example:
ConnectionInfo_SetPassword_EncryptsValue
Test Organization
Mirror the main project structure in mRemoteNGTests/:
Connection/for connection testsSecurity/for security testsConfig/for configuration/serialization tests
Important Notes and Pitfalls
Backward Compatibility
- Critical: Never break loading of old connection files
- Always provide default values for new properties
- Test that files without new attributes still load correctly
Security
- Sensitive data (passwords, credentials) must be encrypted
- Use existing security providers in
Security/namespace - Never log or expose credentials in plain text
Performance
- Connection tree can contain thousands of nodes
- Optimize for large connection files
- Avoid unnecessary UI refreshes
- Use async/await for I/O operations
Platform-Specific Code
- The project targets both x64 and ARM64
- Avoid platform-specific code unless absolutely necessary
- Test on both platforms when possible
External Dependencies
- PuTTY for SSH/Telnet (bundled)
- Terminal Service Client for RDP
- Various protocol-specific libraries (see CREDITS.md)
Documentation
User Documentation
- Located in
mRemoteNGDocumentation/ - Written in reStructuredText (.rst)
- Follows ReadTheDocs format
- Include screenshots and examples for new features
Code Documentation
- Use XML documentation comments for public APIs
- Document complex algorithms and business logic
- Keep implementation notes in
IMPLEMENTATION_NOTES.mdfor significant features
Common Tasks
Adding a Protocol
- Create protocol implementation in
Connection/Protocol/ - Add protocol enum value to protocol types
- Implement connection logic
- Add UI controls if needed
- Update documentation
Adding a Theme
- Add theme files to
Themes/directory - Update theme manager
- Add documentation in
mRemoteNGDocumentation/themes/
Updating Dependencies
- Dependencies are centrally managed in
Directory.Packages.props - Use
dotnet restoreafter updating - Test thoroughly after dependency updates
Version and Release
- Current development version: 1.78.2-dev
- Version is set in
mRemoteNG.csproj - Builds are automated via GitHub Actions (
.github/workflows/) - Changelog maintained in
CHANGELOG.md
Getting Help
- Project website: https://mremoteng.org
- Documentation: https://mremoteng.readthedocs.io
- GitHub Issues: Report bugs and feature requests
- Community: Reddit r/mRemoteNG, Matrix chat
Summary
When contributing to mRemoteNG:
- Follow the existing code style (EditorConfig)
- Maintain backward compatibility with old connection files
- Localize all user-facing strings
- Write tests for new functionality
- Update documentation for user-facing changes
- Test on both x64 and ARM64 if possible
- Keep security and performance in mind