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
273 changes: 273 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
# EncDotNet - editorconfig
#
# Machine-readable encoding of the C# coding style guide
# (docs/coding-style.md). CI enforces whitespace and using-directive rules;
# broader style and naming rules are surfaced by IDE analyzers and followed by
# hand.

root = true

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

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

[*.{cmd,bat}]
end_of_line = crlf

[*.md]
# Trailing double-space is a hard line break in Markdown.
trim_trailing_whitespace = false

##########################################
# C# files
##########################################
[*.cs]
indent_size = 4
insert_final_newline = true

#### Language / usings ####

# File-scoped namespaces only (guide section 2).
csharp_style_namespace_declarations = file_scoped:warning

# using directives outside the namespace, System.* first (guide section 2).
csharp_using_directive_placement = outside_namespace:warning
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
# Unused usings (build already treats warnings as errors).
dotnet_diagnostic.IDE0005.severity = warning

#### Formatting: newlines (Allman braces, guide section 3) ####

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_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

#### Formatting: indentation ####

csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current

#### Formatting: spacing ####

csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

#### Formatting: wrapping ####

csharp_preserve_single_line_blocks = true
# Keep terse single-line statements (for example, `if (x) return false;`) intact
# rather than force-splitting them onto multiple lines (guide section 3).
csharp_preserve_single_line_statements = true

#### 'this.' qualification - not used (guide section 4) ####

dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning

#### Language keywords over framework type names ####

dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning

#### var preferences (guide section 5) ####
# `var` is the default; explicit types remain acceptable where clearer, so
# these are suggestions rather than warnings.

csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

#### Expression-bodied members (guide section 3) ####

csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion

#### Modern language idioms (guide section 5) ####

csharp_style_namespace_declarations = file_scoped:warning
csharp_prefer_braces = when_multiline:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent

dotnet_style_collection_initializer = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion

#### Modifiers ####

dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
csharp_prefer_static_local_function = true:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
dotnet_style_readonly_field = true:suggestion

#### Parentheses clarity ####

dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent

##########################################
# Naming conventions (guide section 4)
##########################################

# --- Symbol groups ---
dotnet_naming_symbols.types.applicable_kinds = class, struct, enum, delegate
dotnet_naming_symbols.types.applicable_accessibilities = *

dotnet_naming_symbols.interfaces.applicable_kinds = interface
dotnet_naming_symbols.interfaces.applicable_accessibilities = *

dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter
dotnet_naming_symbols.type_parameters.applicable_accessibilities = *

dotnet_naming_symbols.members.applicable_kinds = property, method, event, namespace
dotnet_naming_symbols.members.applicable_accessibilities = *

dotnet_naming_symbols.constants.applicable_kinds = field, local
dotnet_naming_symbols.constants.applicable_accessibilities = *
dotnet_naming_symbols.constants.required_modifiers = const

dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = *
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly

dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, protected, protected_internal

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, internal, private_protected

dotnet_naming_symbols.parameters_locals.applicable_kinds = parameter, local
dotnet_naming_symbols.parameters_locals.applicable_accessibilities = *

# --- Naming styles ---
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.camel_case.capitalization = camel_case

dotnet_naming_style.interface_prefix.capitalization = pascal_case
dotnet_naming_style.interface_prefix.required_prefix = I

dotnet_naming_style.type_parameter_prefix.capitalization = pascal_case
dotnet_naming_style.type_parameter_prefix.required_prefix = T

dotnet_naming_style.underscore_camel_case.capitalization = camel_case
dotnet_naming_style.underscore_camel_case.required_prefix = _

# --- Rules (ordered specific -> general) ---
dotnet_naming_rule.interfaces_prefixed_i.symbols = interfaces
dotnet_naming_rule.interfaces_prefixed_i.style = interface_prefix
dotnet_naming_rule.interfaces_prefixed_i.severity = warning

dotnet_naming_rule.type_parameters_prefixed_t.symbols = type_parameters
dotnet_naming_rule.type_parameters_prefixed_t.style = type_parameter_prefix
dotnet_naming_rule.type_parameters_prefixed_t.severity = warning

dotnet_naming_rule.types_pascal.symbols = types
dotnet_naming_rule.types_pascal.style = pascal_case
dotnet_naming_rule.types_pascal.severity = warning

dotnet_naming_rule.members_pascal.symbols = members
dotnet_naming_rule.members_pascal.style = pascal_case
dotnet_naming_rule.members_pascal.severity = warning

dotnet_naming_rule.constants_pascal.symbols = constants
dotnet_naming_rule.constants_pascal.style = pascal_case
dotnet_naming_rule.constants_pascal.severity = warning

dotnet_naming_rule.static_readonly_pascal.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_pascal.style = pascal_case
dotnet_naming_rule.static_readonly_pascal.severity = warning

dotnet_naming_rule.public_fields_pascal.symbols = public_fields
dotnet_naming_rule.public_fields_pascal.style = pascal_case
dotnet_naming_rule.public_fields_pascal.severity = warning

dotnet_naming_rule.private_fields_underscore.symbols = private_fields
dotnet_naming_rule.private_fields_underscore.style = underscore_camel_case
dotnet_naming_rule.private_fields_underscore.severity = warning

dotnet_naming_rule.parameters_locals_camel.symbols = parameters_locals
dotnet_naming_rule.parameters_locals_camel.style = camel_case
dotnet_naming_rule.parameters_locals_camel.severity = suggestion

##########################################
# Test projects - relax naming so xUnit
# `Method_State_Expected` style is allowed.
##########################################
[tests/**.cs]
dotnet_naming_rule.members_pascal.severity = none
dotnet_diagnostic.IDE0005.severity = warning
6 changes: 6 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ S-57 uses **chain-node topology**:

## Coding Conventions

- The normative C# rules are in [`docs/coding-style.md`](../docs/coding-style.md)
and encoded in [`.editorconfig`](../.editorconfig). Follow both when changing
code.
- Before finishing, run `dotnet format whitespace EncDotNet.slnx` and
`dotnet format style EncDotNet.slnx --diagnostics IDE0005`; CI verifies both
with `--verify-no-changes`.
- Target framework: **.NET 10** with nullable reference types and implicit usings enabled.
- Use `ReadOnlySpan<byte>` for parsing hot paths where possible.
- Use `ImmutableArray<T>` and `ImmutableDictionary<K,V>` for parsed record data — records are immutable after construction.
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
contents: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -49,6 +49,32 @@ jobs:
name: nupkgs
path: nupkgs/*.nupkg

format:
name: Format check
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Restore
run: dotnet restore

- name: Verify formatting (whitespace)
# Fix locally with: dotnet format whitespace EncDotNet.slnx
run: dotnet format whitespace EncDotNet.slnx --no-restore --verify-no-changes

- name: Verify usings (ordering + unused)
# Fix locally with:
# dotnet format style EncDotNet.slnx --diagnostics IDE0005
run: dotnet format style EncDotNet.slnx --diagnostics IDE0005 --severity warn --no-restore --verify-no-changes

publish:
needs: build
strategy:
Expand All @@ -74,7 +100,7 @@ jobs:
MACOS_SIGNING_ENABLED: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12 != '' && github.event_name != 'pull_request' }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>
<!-- Keep the build warning-free: compiler, analyzer, and NuGet audit
warnings fail the build rather than quietly accumulating. -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode>
</PropertyGroup>

</Project>
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="11.3.11" />
<PackageVersion Include="Avalonia.Desktop" Version="11.3.11" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.11" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.3.11" />
<PackageVersion Include="Avalonia" Version="11.3.18" />
<PackageVersion Include="Avalonia.Desktop" Version="11.3.18" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.18" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.3.18" />
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.3.0" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.3.11" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.3.18" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Mapsui.Avalonia" Version="5.0.2" />
<PackageVersion Include="Mapsui.Nts" Version="5.0.2" />
<PackageVersion Include="MessagePack" Version="3.1.4" />
<PackageVersion Include="MessagePack" Version="3.1.8" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.15.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.17.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.17.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.17.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.3.8" />
<PackageVersion Include="xunit" Version="2.9.3" />
Expand Down
Loading
Loading