Skip to content

Add clang-format configuration and apply to sampsharp-component C++ source files - #554

Merged
ikkentim merged 4 commits into
mainfrom
copilot/add-clang-format-file
May 12, 2026
Merged

ikkentim merged 4 commits into
mainfrom
copilot/add-clang-format-file

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

Establishes a consistent C++ code style across the active codebase by introducing a .clang-format file and applying it to first-party sources under src/sampsharp-component/.

Configuration (.clang-format)

  • Allman brace style — opening braces on their own line (matches existing sampsharp-component convention)
  • 4-space indentation, 120-column limit
  • Left pointer/reference alignmenttype* not type *
  • Space before control-statement parensif (...) not if(...)
  • Constructor initializers broken after the colon, one per line
  • SortIncludes: Never — preserves include order intentionally (SDK headers have load-order constraints)
  • Short inline class methods kept on a single line

Legacy code exclusion

The legacy code under src/legacy/ is explicitly excluded from formatting. A src/legacy/.clang-format file with DisableFormat: true ensures the entire legacy tree is never touched by clang-format tooling.

.editorconfig

Added [*.{cpp,hpp,h,c}] section (4-space indent, LF) so editors align with the formatter without relying on project-level IDE config.

Applied formatting

All .cpp/.hpp files under src/sampsharp-component/ have been reformatted. The primary visible changes are pointer alignment normalization and minor whitespace adjustments. The legacy code under src/legacy/ is left entirely unchanged.

Copilot AI linked an issue May 12, 2026 that may be closed by this pull request
@ikkentim

Copy link
Copy Markdown
Owner

@copilot do not touch the legacy code; the clang-format should not apply to it.

Copilot AI changed the title [WIP] Add clang-format file and format src code Add clang-format configuration and apply to all C++ source files May 12, 2026
Copilot AI requested a review from ikkentim May 12, 2026 22:04
…e for legacy tree

Agent-Logs-Url: https://github.com/ikkentim/SampSharp/sessions/5a2292e5-020c-4592-9ef6-c99d3d622f63

Co-authored-by: ikkentim <2820647+ikkentim@users.noreply.github.com>

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot do not touch the legacy code; the clang-format should not apply to it.

Done in 90fb133. All formatting changes to src/legacy/ have been reverted to their original state. A src/legacy/.clang-format file with DisableFormat: true has also been added so the legacy tree is permanently excluded from clang-format going forward.

Copilot AI changed the title Add clang-format configuration and apply to all C++ source files Add clang-format configuration and apply to sampsharp-component C++ source files May 12, 2026
Comment thread src/legacy/SampSharp/includes/.clang-format Outdated
Copilot AI requested a review from ikkentim May 12, 2026 22:08
@ikkentim
ikkentim marked this pull request as ready for review May 12, 2026 22:09
Copilot AI requested a review from ikkentim May 12, 2026 22:10
@ikkentim
ikkentim merged commit be6d404 into main May 12, 2026
4 checks passed
@ikkentim
ikkentim deleted the copilot/add-clang-format-file branch May 12, 2026 22:11
ikkentim added a commit that referenced this pull request May 14, 2026
* origin/main:
  Disable IDE0290 configuration and revert public primary constructors (#560)
  Clean up legacy editorconfig Sonar overrides and eliminate TODO markers in `src/legacy` (#562)
  Add implicit usings to SampSharp.Sdk (#558)
  Add `dotnet new` template package for open.mp ECS gamemodes (#556)
  Add clang-format configuration and apply to sampsharp-component C++ source files (#554)
  Implement SafeComponentHandle and earlier managed cleanup (#552)
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.

Add a clang-format file

2 participants