Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add .NET 9 targeting #1274

Merged
merged 12 commits into from
Nov 15, 2024
169 changes: 92 additions & 77 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# top-most EditorConfig file
root = true

# global baselines
#### Core EditorConfig Options ####
[*]
charset = utf-8
end_of_line = lf
Expand All @@ -11,117 +11,134 @@ indent_size = 2
tab_width = 2

line_length = 150
max_line_length = 150
trim_trailing_whitespace = true
insert_final_newline = true

[*.{csproj,props,targets}]
indent_style = space
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2

[*.{cs,vb}]
tab_width = 4
# .NET Globals
[*.cs]
indent_size = 4
end_of_line = lf

#### Naming styles ####
tab_width = 4

# Naming rules
#### .NET Coding Conventions ####
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/overview

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
file_header_template = unset

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Expression-level preferences
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_namespace_match_folder = false:none
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true
dotnet_style_prefer_simplified_interpolation = true

# Symbol specifications
# Collection expression preferences
dotnet_style_prefer_collection_expression = true:suggestion
dotnet_diagnostic.IDE0305.severity = none # exclude collection expression for fluent
csharp_space_between_square_brackets = false
csharp_space_between_empty_square_brackets = false

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity

# Code block and new line preferences
dotnet_style_prefer_braces = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_allow_multiple_blank_lines_experimental = true
dotnet_style_allow_statement_immediately_after_block_experimental = false

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
# Field preferences
dotnet_style_readonly_field = true

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Assignment preferences
dotnet_code_quality_unused_parameters = warning
dotnet_code_quality_unused_value = warning

# Naming styles
# Suppression preferences
dotnet_remove_unnecessary_suppression_exclusions = suggestion

# Naming conventions
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_code_quality_explicit_tuple_names = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_code_quality_unused_parameters = all:suggestion
#### C# Coding Conventions ####
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options

dotnet_sort_system_directives_first = true

dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_namespace_match_folder = false:none
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_collection_expression = true:suggestion

[*.cs]
# ref: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options
# var preferences
csharp_style_var_elsewhere = false
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = false

# Labeling and using directives
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_static_local_function = true:suggestion

# Namespace and method preferences
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion

# Expression-bodied Members
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent

# Function preferences
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_unused_value_assignment_preference = unused_local_variable:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
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_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion

# Variable declarations
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = unused_local_variable:suggestion

# Modifier preferences
csharp_prefer_static_local_function = true
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
csharp_style_prefer_readonly_struct = true
csharp_style_prefer_readonly_struct_member = true

# braces
# Code block preferences
csharp_prefer_braces = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_type_declaration_braces = next_line
csharp_empty_block_style = together_same_line

# New line preferences
csharp_new_line_before_open_brace = methods, properties, control_blocks, types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
Expand All @@ -130,11 +147,9 @@ csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = false

# braces overrides
csharp_type_declaration_braces = next_line
csharp_empty_block_style = together_same_line

# diagnostic analyzers
dotnet_diagnostic.CA1303.severity = none
dotnet_diagnostic.CS1591.severity = silent
dotnet_diagnostic.IDE0058.severity = none
# Diagnostic analyzer suppressions
dotnet_diagnostic.CA1303.severity = none # Passing literals as localized parameters
dotnet_diagnostic.CA2263.severity = none # Prefer generic overload type parameter
dotnet_diagnostic.CS1591.severity = silent # Missing XML comment for publicly visible type or member
dotnet_diagnostic.IDE0058.severity = none # Unused expression value
dotnet_diagnostic.IDE0072.severity = silent # Missing cases in switch statement
6 changes: 3 additions & 3 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Build library
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| Base | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo "| Composed | ${{ steps.compose.outputs.version }} |"
echo "| Composed | ${{ steps.compose.outputs.version }} |"
} >> $GITHUB_STEP_SUMMARY

deploy:
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Setup NuGet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: >
message: |
### Hey there and thank you for opening this pull request! 👋🏼

It looks like your proposed **_Pull request title_** needs to be adjusted.
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/test-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "CodeQL"

on:
push:
branches: [ "main", "v3" ]

pull_request:
branches: [ "main", "v3" ]

schedule:
- cron: '37 14 * * 3'

jobs:

analyze:
name: analyze
runs-on: 'ubuntu-latest'

permissions:
security-events: write
packages: read
actions: read
contents: read

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: csharp
build-mode: manual

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
dotnet-quality: "ga"

- name: Build library
run: >
dotnet build
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:csharp"
2 changes: 1 addition & 1 deletion .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Build examples
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
dotnet-version: ["2.0.x", "6.x", "8.x"]
dotnet-version: ["9.x"]
# TODO: restore when runners have 9.x on all
# ["2.1.x", "6.x", "9.x"]

env:

# identifying primary configuration so only one reports coverage
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '8.x' }}
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.x' }}

# .NET SDK versions in the matrix that support `ga` quality spec
# versions before 5.x do not support it
SUPPORT_GA: ${{ contains(fromJson('["6.x", "8.x"]'), matrix.dotnet-version) }}
SUPPORT_GA: ${{ contains(fromJson('["6.x", "9.x"]'), matrix.dotnet-version) }}

steps:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Build library
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-website-a11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
working-directory: docs
ruby-version: 3.2
ruby-version: 3.3

- name: Install GEMs
working-directory: docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-website-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
working-directory: docs
ruby-version: 3.2
ruby-version: 3.3

- name: Install GEMs
working-directory: docs
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/Backtest/Backtest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Skender.Stock.Indicators" Version="2.5.0" />
<PackageReference Include="Skender.Stock.Indicators" Version="2.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading