Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{csproj,props,targets,slnx,xml,axaml,resx,json,yml,yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.cs]
# Namespaces and usings
csharp_style_namespace_declarations = file_scoped:warning
dotnet_diagnostic.IDE0161.severity = warning
dotnet_sort_system_directives_first = true
dotnet_diagnostic.IDE0005.severity = warning

# Braces and layout (Allman; braces optional for single-line statements)
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_prefer_braces = when_multiline:suggestion

# var and expression bodies
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_operators = when_on_single_line:suggestion

# Modern language features
csharp_style_prefer_primary_constructors = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion

# Naming: private fields are _camelCase
dotnet_naming_rule.private_fields_underscore.symbols = private_fields
dotnet_naming_rule.private_fields_underscore.style = underscore_camel
dotnet_naming_rule.private_fields_underscore.severity = suggestion
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style.underscore_camel.required_prefix = _
dotnet_naming_style.underscore_camel.capitalization = camel_case
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches: [master, "refactor/**"]
pull_request:

permissions:
contents: read

jobs:
build:
name: Build and test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json

- name: Restore
run: dotnet restore SharpMath.slnx

# Builds everything, including the WinForms projects (EnableWindowsTargeting), samples and benchmarks.
- name: Build
run: dotnet build SharpMath.slnx --configuration Release --no-restore

# The WinForms tests only run on Windows; elsewhere their project is not a test project.
- name: Test
run: dotnet test --solution SharpMath.slnx --configuration Release --no-build

- name: Collect coverage
if: runner.os == 'Linux'
run: |
dotnet test --project tests/SharpMath.Tests --configuration Release --no-build --coverage --coverage-output-format cobertura --coverage-output core.cobertura.xml --results-directory coverage
dotnet test --project tests/SharpMath.Canvas.Tests --configuration Release --no-build --coverage --coverage-output-format cobertura --coverage-output canvas.cobertura.xml --results-directory coverage

- name: Check coverage (at least 90 % line coverage)
if: runner.os == 'Linux'
run: dotnet run eng/CheckCoverage.cs -- 90 coverage/core.cobertura.xml=SharpMath coverage/canvas.cobertura.xml=SharpMath.Canvas

- name: Upload coverage
if: runner.os == 'Linux' && always()
uses: actions/upload-artifact@v7
with:
name: coverage
path: coverage/*.cobertura.xml
if-no-files-found: ignore
Loading
Loading