chore: .net8 support and extended support for pipeline jobs
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 32s
Build, Package and Push Images / sbom-scan (push) Successful in 1m2s
Build, Package and Push Images / container-sbom-scan (push) Successful in 40s
Build, Package and Push Images / container-build (push) Successful in 2m2s
Build, Package and Push Images / sonarqube (push) Successful in 2m5s
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 32s
Build, Package and Push Images / sbom-scan (push) Successful in 1m2s
Build, Package and Push Images / container-sbom-scan (push) Successful in 40s
Build, Package and Push Images / container-build (push) Successful in 2m2s
Build, Package and Push Images / sonarqube (push) Successful in 2m5s
fix: incorrect command fix: incorrect command fix: incorrect command fix: export tools path chore: test dir fix: test build script fix: missing semicolon fix: missing semicolon fix: missing buildscript fix: missing buildscript chore: update build to .net7 ci: set root dir ci: set root dir revert: .net 8 support for benchmarks ci: disable docker for ci ci: disable docker for ci ci: disable docker for ci ci: trigger ci: i stg ci: let's hope its the correct one ci: i stg ci: further sonarscanner setup ci: add tools ci: rearrange ci: verbose output ci: hardcoded project key ci: test env ci: test more env ci: env test again ci: test env ci: shit ci: final setup ci: final setup ci: final setup ci: adjust buildscript ci: nuke ci: install java ci: install java refactor: loggermessages to own namespace chore: switch to dotnet foundation editorconfig preset ci: switch to basic gitea ci ci: steps ci: add missing runs-on ci: remove unnecessary actions ci: test attempt? ci: add missing name for step ci: fix missing project name reference ci: lets try again ci: again ci: again.. ci: idk at this point ci: append path prematurely ci: add path to bash cli: I really don't know ci: again.... ci: idk ci: again.... ci: another one ci: fix incorrect path add-path ci: add dependency track support ci: fix upload ci: forgot to adjust data for action ci: incorrect path? ci: add version tag ci: idk ci: fix incorrect path for bom ci: fix version tag ci: disable github license resolution for now ci: does this work ci: another one bites the dust chore: .net 8 and extended pipeline support ci: again chore: dockerignore added chore(deps): update dependency benchmarkdotnet to v0.13.10 Signed-off-by: noreply@rainote.dev ci: dependency track can run on any branch ci: first attempt docker image ci: again ci: some fixes ci: idk ci: does this help ci: idk ci: another one ci: forgot ci: downgrade qemu setup ci: downgrade.. ci: v1 includes docker ci: rearrange ci: idk what to do with this ci: let's try cat ci: alt ci: depressing ci: yikes ci: ah come on ci: let's try new version again ci: again ci: another one ci: another one ci: confusion ci: try single ci: aaaa ci: one more time ci: again main (#69) Reviewed-on: #69 Co-authored-by: Timothy Schenk <admin@rainote.dev> Co-committed-by: Timothy Schenk <admin@rainote.dev> chore: ci jobs expanded & .net 8 support ci: branch name sanitization for docker ci: another attempt ci: forgot actor chore: remove nuke remnants chore(deps): update dependency dotnet-sdk to v7.0.403 Signed-off-by: noreply@rainote.dev refactor: shared data into library refactor: rewrite for packethandler/id map chore: logging chore: Sonar Warnings chore: upgrade to .net8 image chore: fetch all required information for characters chore: upgrade to .net 8 ci: install .net 7.0 alongside 8.0 for sbom fix: incorrect job ci: let's try arm64 again ci: adjust project for .net 8 support chore: adjustments to composefile chore: analyzer setup chore: analyzer and project settings updated chore: ci jobs expanded & .net 8 support
This commit is contained in:
parent
20931b5751
commit
85aaec2371
41 changed files with 2108 additions and 908 deletions
843
.editorconfig
843
.editorconfig
|
@ -1,453 +1,466 @@
|
|||
# Version: 4.1.1 (Using https://semver.org/)
|
||||
# Updated: 2022-05-23
|
||||
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
|
||||
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
|
||||
# See http://EditorConfig.org for more information about .editorconfig files.
|
||||
; EditorConfig to support per-solution formatting.
|
||||
; Use the EditorConfig VS add-in to make this work.
|
||||
; http://editorconfig.org/
|
||||
;
|
||||
; Here are some resources for what's supported for .NET/C#
|
||||
; https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
|
||||
; https://learn.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
|
||||
;
|
||||
; Be **careful** editing this because some of the rules don't support adding a severity level
|
||||
; For instance if you change to `dotnet_sort_system_directives_first = true:warning` (adding `:warning`)
|
||||
; then the rule will be silently ignored.
|
||||
|
||||
##########################################
|
||||
# Common Settings
|
||||
##########################################
|
||||
|
||||
# This file is the top-most EditorConfig file
|
||||
; This is the default for the codeline.
|
||||
root = true
|
||||
|
||||
# All Files
|
||||
; For disabling MA0048 and MA0051 in a specific folder, e.g., Migrations
|
||||
[**/Migrations/*.cs]
|
||||
dotnet_diagnostic.MA0048.severity = none
|
||||
dotnet_diagnostic.MA0051.severity = none
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
##########################################
|
||||
# File Extension Settings
|
||||
##########################################
|
||||
|
||||
# Visual Studio Solution Files
|
||||
[*.sln]
|
||||
indent_style = tab
|
||||
|
||||
# Visual Studio XML Project Files
|
||||
[*.{csproj,vbproj,vcxproj.filters,proj,projitems,shproj}]
|
||||
indent_size = 2
|
||||
|
||||
# XML Configuration Files
|
||||
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
|
||||
indent_size = 2
|
||||
|
||||
# JSON Files
|
||||
[*.{json,json5,webmanifest}]
|
||||
indent_size = 2
|
||||
|
||||
# YAML Files
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
# Markdown Files
|
||||
[*.{md,mdx}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
# Web Files
|
||||
[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
|
||||
indent_size = 2
|
||||
|
||||
# Batch Files
|
||||
[*.{cmd,bat}]
|
||||
end_of_line = crlf
|
||||
|
||||
# Bash Files
|
||||
[*.sh]
|
||||
end_of_line = lf
|
||||
|
||||
# Makefiles
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
##########################################
|
||||
# Default .NET Code Style Severities
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope
|
||||
##########################################
|
||||
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# Default Severity for all .NET Code Style rules below
|
||||
dotnet_analyzer_diagnostic.severity = warning
|
||||
|
||||
##########################################
|
||||
# Language Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules
|
||||
##########################################
|
||||
|
||||
# .NET Style Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# "this." and "Me." qualifiers
|
||||
dotnet_style_qualification_for_field = true:warning
|
||||
dotnet_style_qualification_for_property = true:warning
|
||||
dotnet_style_qualification_for_method = true:warning
|
||||
dotnet_style_qualification_for_event = true:warning
|
||||
# Language keywords instead of framework type names for type references
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
|
||||
dotnet_style_predefined_type_for_member_access = true:warning
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = always:warning
|
||||
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:warning
|
||||
visual_basic_preferred_modifier_order = Partial, Default, Private, Protected, Public, Friend, NotOverridable, Overridable, MustOverride, Overloads, Overrides, MustInherit, NotInheritable, Static, Shared, Shadows, ReadOnly, WriteOnly, Dim, Const, WithEvents, Widening, Narrowing, Custom, Async:warning
|
||||
dotnet_style_readonly_field = true:warning
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
|
||||
# Expression-level preferences
|
||||
dotnet_style_object_initializer = true:warning
|
||||
dotnet_style_collection_initializer = true:warning
|
||||
dotnet_style_explicit_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
|
||||
dotnet_diagnostic.IDE0045.severity = suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
|
||||
dotnet_diagnostic.IDE0046.severity = suggestion
|
||||
dotnet_style_prefer_compound_assignment = true:warning
|
||||
dotnet_style_prefer_simplified_interpolation = true:warning
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true:warning
|
||||
# Null-checking preferences
|
||||
dotnet_style_coalesce_expression = true:warning
|
||||
dotnet_style_null_propagation = true:warning
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
|
||||
# File header preferences
|
||||
# file_header_template = <copyright file="{fileName}" company="PROJECT-AUTHOR">\n© PROJECT-AUTHOR\n</copyright>
|
||||
# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match.
|
||||
# dotnet_diagnostic.SA1636.severity = none
|
||||
# Undocumented
|
||||
dotnet_style_operator_placement_when_wrapping = end_of_line:warning
|
||||
csharp_style_prefer_null_check_over_type_check = true:warning
|
||||
|
||||
# C# Style Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
|
||||
[*.{cs,csx,cake}]
|
||||
# 'var' preferences
|
||||
csharp_style_var_for_built_in_types = true:warning
|
||||
csharp_style_var_when_type_is_apparent = true:warning
|
||||
csharp_style_var_elsewhere = true:warning
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_methods = true:warning
|
||||
csharp_style_expression_bodied_constructors = true:warning
|
||||
csharp_style_expression_bodied_operators = true:warning
|
||||
csharp_style_expression_bodied_properties = true:warning
|
||||
csharp_style_expression_bodied_indexers = true:warning
|
||||
csharp_style_expression_bodied_accessors = true:warning
|
||||
csharp_style_expression_bodied_lambdas = true:warning
|
||||
csharp_style_expression_bodied_local_functions = true:warning
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:warning
|
||||
csharp_style_prefer_switch_expression = true:warning
|
||||
csharp_style_prefer_pattern_matching = true:warning
|
||||
csharp_style_prefer_not_pattern = true:warning
|
||||
# Expression-level preferences
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
csharp_prefer_simple_default_expression = true:warning
|
||||
csharp_style_pattern_local_over_anonymous_function = true:warning
|
||||
csharp_style_deconstructed_variable_declaration = true:warning
|
||||
csharp_style_prefer_index_operator = true:warning
|
||||
csharp_style_prefer_range_operator = true:warning
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
|
||||
# "Null" checking preferences
|
||||
csharp_style_throw_expression = true:warning
|
||||
csharp_style_conditional_delegate_call = true:warning
|
||||
# Code block preferences
|
||||
csharp_prefer_braces = true:warning
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
dotnet_diagnostic.IDE0063.severity = suggestion
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = inside_namespace:warning
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true:warning
|
||||
|
||||
##########################################
|
||||
# Unnecessary Code Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
|
||||
##########################################
|
||||
|
||||
# .NET Unnecessary code rules
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
dotnet_code_quality_unused_parameters = all:warning
|
||||
dotnet_remove_unnecessary_suppression_exclusions = none:warning
|
||||
|
||||
# C# Unnecessary code rules
|
||||
[*.{cs,csx,cake}]
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
|
||||
dotnet_diagnostic.IDE0058.severity = suggestion
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||
dotnet_diagnostic.IDE0059.severity = suggestion
|
||||
|
||||
##########################################
|
||||
# Formatting Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
|
||||
##########################################
|
||||
|
||||
# .NET formatting rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#net-formatting-rules
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# Organize using directives
|
||||
[*.cs]
|
||||
indent_size = 4
|
||||
dotnet_sort_system_directives_first = true
|
||||
dotnet_separate_import_directive_groups = false
|
||||
# Dotnet namespace options
|
||||
dotnet_style_namespace_match_folder = true:suggestion
|
||||
dotnet_diagnostic.IDE0130.severity = suggestion
|
||||
|
||||
# C# formatting rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
|
||||
[*.{cs,csx,cake}]
|
||||
# Newline options
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options
|
||||
# Don't use this. qualifier
|
||||
dotnet_style_qualification_for_field = false:suggestion
|
||||
dotnet_style_qualification_for_property = false:suggestion
|
||||
|
||||
# use int x = .. over Int32
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
|
||||
# use int.MaxValue over Int32.MaxValue
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# Require var all the time.
|
||||
csharp_style_var_for_built_in_types = true:suggestion
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
csharp_style_var_elsewhere = true:suggestion
|
||||
|
||||
# Disallow throw expressions.
|
||||
csharp_style_throw_expression = false:suggestion
|
||||
|
||||
# Newline settings
|
||||
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
|
||||
# Indentation options
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = no_change
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents_when_block = false
|
||||
# Spacing options
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_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_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_square_brackets = false
|
||||
# Wrap options
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_preserve_single_line_blocks = true
|
||||
# Namespace options
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options
|
||||
csharp_style_namespace_declarations = file_scoped:warning
|
||||
|
||||
##########################################
|
||||
# .NET Naming Rules
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules
|
||||
##########################################
|
||||
# Namespace settings
|
||||
csharp_style_namespace_declarations = file_scoped
|
||||
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# Brace settings
|
||||
csharp_prefer_braces = true # Prefer curly braces even for one line of code
|
||||
|
||||
##########################################
|
||||
# Styles
|
||||
##########################################
|
||||
|
||||
# camel_case_style - Define the camelCase style
|
||||
dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||
# pascal_case_style - Define the PascalCase style
|
||||
# name all constant fields using PascalCase
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
# first_upper_style - The first character must start with an upper-case character
|
||||
dotnet_naming_style.first_upper_style.capitalization = first_word_upper
|
||||
# prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I'
|
||||
dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case
|
||||
dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
|
||||
# prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T'
|
||||
dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case
|
||||
dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T
|
||||
# disallowed_style - Anything that has this style applied is marked as disallowed
|
||||
dotnet_naming_style.disallowed_style.capitalization = pascal_case
|
||||
dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____
|
||||
dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____
|
||||
# internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file
|
||||
dotnet_naming_style.internal_error_style.capitalization = pascal_case
|
||||
dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____
|
||||
dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR____
|
||||
|
||||
##########################################
|
||||
# .NET Design Guideline Field Naming Rules
|
||||
# Naming rules for fields follow the .NET Framework design guidelines
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/index
|
||||
##########################################
|
||||
# internal and private fields should be _camelCase
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
|
||||
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
|
||||
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
|
||||
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
|
||||
|
||||
# All public/protected/protected_internal constant fields must be PascalCase
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning
|
||||
[*.{xml,config,*proj,nuspec,props,resx,targets,yml,tasks}]
|
||||
indent_size = 2
|
||||
|
||||
# All public/protected/protected_internal static readonly fields must be PascalCase
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning
|
||||
# Xml config files
|
||||
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
|
||||
indent_size = 2
|
||||
|
||||
# No other public/protected/protected_internal fields are allowed
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
##########################################
|
||||
# StyleCop Field Naming Rules
|
||||
# Naming rules for fields follow the StyleCop analyzers
|
||||
# This does not override any rules using disallowed_style above
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
|
||||
##########################################
|
||||
[*.{ps1,psm1}]
|
||||
indent_size = 4
|
||||
|
||||
# All constant fields must be PascalCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning
|
||||
[*.sh]
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
|
||||
# All static readonly fields must be PascalCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning
|
||||
[*.{razor,cshtml}]
|
||||
charset = utf-8-bom
|
||||
|
||||
# No non-private instance fields are allowed
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md
|
||||
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
|
||||
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error
|
||||
[*.{cs,vb}]
|
||||
|
||||
# Private fields must be camelCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md
|
||||
dotnet_naming_symbols.stylecop_private_fields_group.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.stylecop_private_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.symbols = stylecop_private_fields_group
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.style = camel_case_style
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.severity = warning
|
||||
# SYSLIB1054: Use 'LibraryImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
|
||||
dotnet_diagnostic.SYSLIB1054.severity = warning
|
||||
|
||||
# Local variables must be camelCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md
|
||||
dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local
|
||||
dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent
|
||||
# CA1018: Mark attributes with AttributeUsageAttribute
|
||||
dotnet_diagnostic.CA1018.severity = warning
|
||||
|
||||
# This rule should never fire. However, it's included for at least two purposes:
|
||||
# First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers.
|
||||
# Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#).
|
||||
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error
|
||||
# CA1047: Do not declare protected member in sealed type
|
||||
dotnet_diagnostic.CA1047.severity = warning
|
||||
|
||||
# CA1305: Specify IFormatProvider
|
||||
dotnet_diagnostic.CA1305.severity = warning
|
||||
|
||||
##########################################
|
||||
# Other Naming Rules
|
||||
##########################################
|
||||
# CA1507: Use nameof to express symbol names
|
||||
dotnet_diagnostic.CA1507.severity = warning
|
||||
|
||||
# All of the following must be PascalCase:
|
||||
# - Namespaces
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md
|
||||
# - Classes and Enumerations
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md
|
||||
# - Delegates
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types
|
||||
# - Constructors, Properties, Events, Methods
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members
|
||||
dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property
|
||||
dotnet_naming_rule.element_rule.symbols = element_group
|
||||
dotnet_naming_rule.element_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.element_rule.severity = warning
|
||||
# CA1510: Use ArgumentNullException throw helper
|
||||
dotnet_diagnostic.CA1510.severity = warning
|
||||
|
||||
# Interfaces use PascalCase and are prefixed with uppercase 'I'
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
dotnet_naming_symbols.interface_group.applicable_kinds = interface
|
||||
dotnet_naming_rule.interface_rule.symbols = interface_group
|
||||
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
|
||||
dotnet_naming_rule.interface_rule.severity = warning
|
||||
# CA1511: Use ArgumentException throw helper
|
||||
dotnet_diagnostic.CA1511.severity = warning
|
||||
|
||||
# Generics Type Parameters use PascalCase and are prefixed with uppercase 'T'
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter
|
||||
dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group
|
||||
dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style
|
||||
dotnet_naming_rule.type_parameter_rule.severity = warning
|
||||
# CA1512: Use ArgumentOutOfRangeException throw helper
|
||||
dotnet_diagnostic.CA1512.severity = warning
|
||||
|
||||
# Function parameters use camelCase
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters
|
||||
dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
|
||||
dotnet_naming_rule.parameters_rule.symbols = parameters_group
|
||||
dotnet_naming_rule.parameters_rule.style = camel_case_style
|
||||
dotnet_naming_rule.parameters_rule.severity = warning
|
||||
# CA1513: Use ObjectDisposedException throw helper
|
||||
dotnet_diagnostic.CA1513.severity = warning
|
||||
|
||||
# Disable warnings for using LoggerMessage delegates
|
||||
dotnet_diagnostic.CA1848.severity = none
|
||||
# CA1725: Parameter names should match base declaration
|
||||
dotnet_diagnostic.CA1725.severity = suggestion
|
||||
|
||||
##########################################
|
||||
# License
|
||||
##########################################
|
||||
# The following applies as to the .editorconfig file ONLY, and is
|
||||
# included below for reference, per the requirements of the license
|
||||
# corresponding to this .editorconfig file.
|
||||
# See: https://github.com/RehanSaeed/EditorConfig
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2017-2019 Muhammad Rehan Saeed
|
||||
# Copyright (c) 2019 Henry Gabryjelski
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any
|
||||
# person obtaining a copy of this software and associated
|
||||
# documentation files (the "Software"), to deal in the
|
||||
# Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute,
|
||||
# sublicense, and/or sell copies of the Software, and to permit
|
||||
# persons to whom the Software is furnished to do so, subject
|
||||
# to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
##########################################
|
||||
# CA1802: Use literals where appropriate
|
||||
dotnet_diagnostic.CA1802.severity = warning
|
||||
|
||||
# CA1805: Do not initialize unnecessarily
|
||||
dotnet_diagnostic.CA1805.severity = warning
|
||||
|
||||
# CA1810: Do not initialize unnecessarily
|
||||
dotnet_diagnostic.CA1810.severity = warning
|
||||
|
||||
# CA1821: Remove empty Finalizers
|
||||
dotnet_diagnostic.CA1821.severity = warning
|
||||
|
||||
# CA1822: Make member static
|
||||
dotnet_diagnostic.CA1822.severity = warning
|
||||
dotnet_code_quality.CA1822.api_surface = private, internal
|
||||
|
||||
# CA1823: Avoid unused private fields
|
||||
dotnet_diagnostic.CA1823.severity = warning
|
||||
|
||||
# CA1825: Avoid zero-length array allocations
|
||||
dotnet_diagnostic.CA1825.severity = warning
|
||||
|
||||
# CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly
|
||||
dotnet_diagnostic.CA1826.severity = warning
|
||||
|
||||
# CA1827: Do not use Count() or LongCount() when Any() can be used
|
||||
dotnet_diagnostic.CA1827.severity = warning
|
||||
|
||||
# CA1828: Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used
|
||||
dotnet_diagnostic.CA1828.severity = warning
|
||||
|
||||
# CA1829: Use Length/Count property instead of Count() when available
|
||||
dotnet_diagnostic.CA1829.severity = warning
|
||||
|
||||
# CA1830: Prefer strongly-typed Append and Insert method overloads on StringBuilder
|
||||
dotnet_diagnostic.CA1830.severity = warning
|
||||
|
||||
# CA1831: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1831.severity = warning
|
||||
|
||||
# CA1832: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1832.severity = warning
|
||||
|
||||
# CA1833: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1833.severity = warning
|
||||
|
||||
# CA1834: Consider using 'StringBuilder.Append(char)' when applicable
|
||||
dotnet_diagnostic.CA1834.severity = warning
|
||||
|
||||
# CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
|
||||
dotnet_diagnostic.CA1835.severity = warning
|
||||
|
||||
# CA1836: Prefer IsEmpty over Count
|
||||
dotnet_diagnostic.CA1836.severity = warning
|
||||
|
||||
# CA1837: Use 'Environment.ProcessId'
|
||||
dotnet_diagnostic.CA1837.severity = warning
|
||||
|
||||
# CA1838: Avoid 'StringBuilder' parameters for P/Invokes
|
||||
dotnet_diagnostic.CA1838.severity = warning
|
||||
|
||||
# CA1839: Use 'Environment.ProcessPath'
|
||||
dotnet_diagnostic.CA1839.severity = warning
|
||||
|
||||
# CA1840: Use 'Environment.CurrentManagedThreadId'
|
||||
dotnet_diagnostic.CA1840.severity = warning
|
||||
|
||||
# CA1841: Prefer Dictionary.Contains methods
|
||||
dotnet_diagnostic.CA1841.severity = warning
|
||||
|
||||
# CA1842: Do not use 'WhenAll' with a single task
|
||||
dotnet_diagnostic.CA1842.severity = warning
|
||||
|
||||
# CA1843: Do not use 'WaitAll' with a single task
|
||||
dotnet_diagnostic.CA1843.severity = warning
|
||||
|
||||
# CA1844: Provide memory-based overrides of async methods when subclassing 'Stream'
|
||||
dotnet_diagnostic.CA1844.severity = warning
|
||||
|
||||
# CA1845: Use span-based 'string.Concat'
|
||||
dotnet_diagnostic.CA1845.severity = warning
|
||||
|
||||
# CA1846: Prefer AsSpan over Substring
|
||||
dotnet_diagnostic.CA1846.severity = warning
|
||||
|
||||
# CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
|
||||
dotnet_diagnostic.CA1847.severity = warning
|
||||
|
||||
# CA1852: Seal internal types
|
||||
dotnet_diagnostic.CA1852.severity = warning
|
||||
|
||||
# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
|
||||
dotnet_diagnostic.CA1854.severity = warning
|
||||
|
||||
# CA1855: Prefer 'Clear' over 'Fill'
|
||||
dotnet_diagnostic.CA1855.severity = warning
|
||||
|
||||
# CA1856: Incorrect usage of ConstantExpected attribute
|
||||
dotnet_diagnostic.CA1856.severity = error
|
||||
|
||||
# CA1857: A constant is expected for the parameter
|
||||
dotnet_diagnostic.CA1857.severity = warning
|
||||
|
||||
# CA1858: Use 'StartsWith' instead of 'IndexOf'
|
||||
dotnet_diagnostic.CA1858.severity = warning
|
||||
|
||||
# CA2007: Consider calling ConfigureAwait on the awaited task
|
||||
dotnet_diagnostic.CA2007.severity = warning
|
||||
|
||||
# CA2008: Do not create tasks without passing a TaskScheduler
|
||||
dotnet_diagnostic.CA2008.severity = warning
|
||||
|
||||
# CA2009: Do not call ToImmutableCollection on an ImmutableCollection value
|
||||
dotnet_diagnostic.CA2009.severity = warning
|
||||
|
||||
# CA2011: Avoid infinite recursion
|
||||
dotnet_diagnostic.CA2011.severity = warning
|
||||
|
||||
# CA2012: Use ValueTask correctly
|
||||
dotnet_diagnostic.CA2012.severity = warning
|
||||
|
||||
# CA2013: Do not use ReferenceEquals with value types
|
||||
dotnet_diagnostic.CA2013.severity = warning
|
||||
|
||||
# CA2014: Do not use stackalloc in loops.
|
||||
dotnet_diagnostic.CA2014.severity = warning
|
||||
|
||||
# CA2016: Forward the 'CancellationToken' parameter to methods that take one
|
||||
dotnet_diagnostic.CA2016.severity = warning
|
||||
|
||||
# CA2200: Rethrow to preserve stack details
|
||||
dotnet_diagnostic.CA2200.severity = warning
|
||||
|
||||
# CA2201: Do not raise reserved exception types
|
||||
dotnet_diagnostic.CA2201.severity = warning
|
||||
|
||||
# CA2208: Instantiate argument exceptions correctly
|
||||
dotnet_diagnostic.CA2208.severity = warning
|
||||
|
||||
# CA2245: Do not assign a property to itself
|
||||
dotnet_diagnostic.CA2245.severity = warning
|
||||
|
||||
# CA2246: Assigning symbol and its member in the same statement
|
||||
dotnet_diagnostic.CA2246.severity = warning
|
||||
|
||||
# CA2249: Use string.Contains instead of string.IndexOf to improve readability.
|
||||
dotnet_diagnostic.CA2249.severity = warning
|
||||
|
||||
# IDE0005: Remove unnecessary usings
|
||||
dotnet_diagnostic.IDE0005.severity = warning
|
||||
|
||||
# IDE0011: Curly braces to surround blocks of code
|
||||
dotnet_diagnostic.IDE0011.severity = warning
|
||||
|
||||
# IDE0020: Use pattern matching to avoid is check followed by a cast (with variable)
|
||||
dotnet_diagnostic.IDE0020.severity = warning
|
||||
|
||||
# IDE0029: Use coalesce expression (non-nullable types)
|
||||
dotnet_diagnostic.IDE0029.severity = warning
|
||||
|
||||
# IDE0030: Use coalesce expression (nullable types)
|
||||
dotnet_diagnostic.IDE0030.severity = warning
|
||||
|
||||
# IDE0031: Use null propagation
|
||||
dotnet_diagnostic.IDE0031.severity = warning
|
||||
|
||||
# IDE0035: Remove unreachable code
|
||||
dotnet_diagnostic.IDE0035.severity = warning
|
||||
|
||||
# IDE0036: Order modifiers
|
||||
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:suggestion
|
||||
dotnet_diagnostic.IDE0036.severity = warning
|
||||
|
||||
# IDE0038: Use pattern matching to avoid is check followed by a cast (without variable)
|
||||
dotnet_diagnostic.IDE0038.severity = warning
|
||||
|
||||
# IDE0043: Format string contains invalid placeholder
|
||||
dotnet_diagnostic.IDE0043.severity = warning
|
||||
|
||||
# IDE0044: Make field readonly
|
||||
dotnet_diagnostic.IDE0044.severity = warning
|
||||
|
||||
# IDE0051: Remove unused private members
|
||||
dotnet_diagnostic.IDE0051.severity = warning
|
||||
|
||||
# IDE0055: All formatting rules
|
||||
dotnet_diagnostic.IDE0055.severity = suggestion
|
||||
|
||||
# IDE0059: Unnecessary assignment to a value
|
||||
dotnet_diagnostic.IDE0059.severity = warning
|
||||
|
||||
# IDE0060: Remove unused parameter
|
||||
dotnet_code_quality_unused_parameters = non_public
|
||||
dotnet_diagnostic.IDE0060.severity = warning
|
||||
|
||||
# IDE0062: Make local function static
|
||||
dotnet_diagnostic.IDE0062.severity = warning
|
||||
|
||||
# IDE0073: File header
|
||||
dotnet_diagnostic.IDE0073.severity = warning
|
||||
# Not a dotnet foundation project
|
||||
#file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
# IDE0161: Convert to file-scoped namespace
|
||||
dotnet_diagnostic.IDE0161.severity = warning
|
||||
|
||||
# IDE0200: Lambda expression can be removed
|
||||
dotnet_diagnostic.IDE0200.severity = warning
|
||||
|
||||
# IDE2000: Disallow multiple blank lines
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = false
|
||||
dotnet_diagnostic.IDE2000.severity = warning
|
||||
|
||||
[{eng/tools/**.cs,**/{test,testassets,samples,Samples,perf,benchmarkapps,scripts,stress}/**.cs,src/Hosting/Server.IntegrationTesting/**.cs,src/Servers/IIS/IntegrationTesting.IIS/**.cs,src/Shared/Http2cat/**.cs,src/Testing/**.cs}]
|
||||
# CA1018: Mark attributes with AttributeUsageAttribute
|
||||
dotnet_diagnostic.CA1018.severity = suggestion
|
||||
# CA1507: Use nameof to express symbol names
|
||||
dotnet_diagnostic.CA1507.severity = suggestion
|
||||
# CA1510: Use ArgumentNullException throw helper
|
||||
dotnet_diagnostic.CA1510.severity = suggestion
|
||||
# CA1511: Use ArgumentException throw helper
|
||||
dotnet_diagnostic.CA1511.severity = suggestion
|
||||
# CA1512: Use ArgumentOutOfRangeException throw helper
|
||||
dotnet_diagnostic.CA1512.severity = suggestion
|
||||
# CA1513: Use ObjectDisposedException throw helper
|
||||
dotnet_diagnostic.CA1513.severity = suggestion
|
||||
# CA1802: Use literals where appropriate
|
||||
dotnet_diagnostic.CA1802.severity = suggestion
|
||||
# CA1805: Do not initialize unnecessarily
|
||||
dotnet_diagnostic.CA1805.severity = suggestion
|
||||
# CA1810: Do not initialize unnecessarily
|
||||
dotnet_diagnostic.CA1810.severity = suggestion
|
||||
# CA1822: Make member static
|
||||
dotnet_diagnostic.CA1822.severity = suggestion
|
||||
# CA1823: Avoid zero-length array allocations
|
||||
dotnet_diagnostic.CA1825.severity = suggestion
|
||||
# CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly
|
||||
dotnet_diagnostic.CA1826.severity = suggestion
|
||||
# CA1827: Do not use Count() or LongCount() when Any() can be used
|
||||
dotnet_diagnostic.CA1827.severity = suggestion
|
||||
# CA1829: Use Length/Count property instead of Count() when available
|
||||
dotnet_diagnostic.CA1829.severity = suggestion
|
||||
# CA1831: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1831.severity = suggestion
|
||||
# CA1832: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1832.severity = suggestion
|
||||
# CA1833: Use AsSpan or AsMemory instead of Range-based indexers when appropriate
|
||||
dotnet_diagnostic.CA1833.severity = suggestion
|
||||
# CA1834: Consider using 'StringBuilder.Append(char)' when applicable
|
||||
dotnet_diagnostic.CA1834.severity = suggestion
|
||||
# CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
|
||||
dotnet_diagnostic.CA1835.severity = suggestion
|
||||
# CA1837: Use 'Environment.ProcessId'
|
||||
dotnet_diagnostic.CA1837.severity = suggestion
|
||||
# CA1838: Avoid 'StringBuilder' parameters for P/Invokes
|
||||
dotnet_diagnostic.CA1838.severity = suggestion
|
||||
# CA1841: Prefer Dictionary.Contains methods
|
||||
dotnet_diagnostic.CA1841.severity = suggestion
|
||||
# CA1844: Provide memory-based overrides of async methods when subclassing 'Stream'
|
||||
dotnet_diagnostic.CA1844.severity = suggestion
|
||||
# CA1845: Use span-based 'string.Concat'
|
||||
dotnet_diagnostic.CA1845.severity = suggestion
|
||||
# CA1846: Prefer AsSpan over Substring
|
||||
dotnet_diagnostic.CA1846.severity = suggestion
|
||||
# CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
|
||||
dotnet_diagnostic.CA1847.severity = suggestion
|
||||
# CA1852: Seal internal types
|
||||
dotnet_diagnostic.CA1852.severity = suggestion
|
||||
# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
|
||||
dotnet_diagnostic.CA1854.severity = suggestion
|
||||
# CA1855: Prefer 'Clear' over 'Fill'
|
||||
dotnet_diagnostic.CA1855.severity = suggestion
|
||||
# CA1856: Incorrect usage of ConstantExpected attribute
|
||||
dotnet_diagnostic.CA1856.severity = suggestion
|
||||
# CA1857: A constant is expected for the parameter
|
||||
dotnet_diagnostic.CA1857.severity = suggestion
|
||||
# CA1858: Use 'StartsWith' instead of 'IndexOf'
|
||||
dotnet_diagnostic.CA1858.severity = suggestion
|
||||
# CA2007: Consider calling ConfigureAwait on the awaited task
|
||||
dotnet_diagnostic.CA2007.severity = suggestion
|
||||
# CA2008: Do not create tasks without passing a TaskScheduler
|
||||
dotnet_diagnostic.CA2008.severity = suggestion
|
||||
# CA2012: Use ValueTask correctly
|
||||
dotnet_diagnostic.CA2012.severity = suggestion
|
||||
# CA2201: Do not raise reserved exception types
|
||||
dotnet_diagnostic.CA2201.severity = suggestion
|
||||
# CA2249: Use string.Contains instead of string.IndexOf to improve readability.
|
||||
dotnet_diagnostic.CA2249.severity = suggestion
|
||||
# IDE0005: Remove unnecessary usings
|
||||
dotnet_diagnostic.IDE0005.severity = suggestion
|
||||
# IDE0020: Use pattern matching to avoid is check followed by a cast (with variable)
|
||||
dotnet_diagnostic.IDE0020.severity = suggestion
|
||||
# IDE0029: Use coalesce expression (non-nullable types)
|
||||
dotnet_diagnostic.IDE0029.severity = suggestion
|
||||
# IDE0030: Use coalesce expression (nullable types)
|
||||
dotnet_diagnostic.IDE0030.severity = suggestion
|
||||
# IDE0031: Use null propagation
|
||||
dotnet_diagnostic.IDE0031.severity = suggestion
|
||||
# IDE0038: Use pattern matching to avoid is check followed by a cast (without variable)
|
||||
dotnet_diagnostic.IDE0038.severity = suggestion
|
||||
# IDE0044: Make field readonly
|
||||
dotnet_diagnostic.IDE0044.severity = suggestion
|
||||
# IDE0051: Remove unused private members
|
||||
dotnet_diagnostic.IDE0051.severity = suggestion
|
||||
# IDE0059: Unnecessary assignment to a value
|
||||
dotnet_diagnostic.IDE0059.severity = suggestion
|
||||
# IDE0060: Remove unused parameters
|
||||
dotnet_diagnostic.IDE0060.severity = suggestion
|
||||
# IDE0062: Make local function static
|
||||
dotnet_diagnostic.IDE0062.severity = suggestion
|
||||
# IDE0200: Lambda expression can be removed
|
||||
dotnet_diagnostic.IDE0200.severity = suggestion
|
||||
|
||||
# CA2016: Forward the 'CancellationToken' parameter to methods that take one
|
||||
dotnet_diagnostic.CA2016.severity = suggestion
|
||||
|
||||
# Defaults for content in the shared src/ and shared runtime dir
|
||||
|
||||
[{**/Shared/runtime/**.{cs,vb},src/Shared/test/Shared.Tests/runtime/**.{cs,vb},**/microsoft.extensions.hostfactoryresolver.sources/**.{cs,vb}}]
|
||||
# CA1822: Make member static
|
||||
dotnet_diagnostic.CA1822.severity = silent
|
||||
# IDE0011: Use braces
|
||||
dotnet_diagnostic.IDE0011.severity = silent
|
||||
# IDE0055: Fix formatting
|
||||
dotnet_diagnostic.IDE0055.severity = silent
|
||||
# IDE0060: Remove unused parameters
|
||||
dotnet_diagnostic.IDE0060.severity = silent
|
||||
# IDE0062: Make local function static
|
||||
dotnet_diagnostic.IDE0062.severity = silent
|
||||
# IDE0161: Convert to file-scoped namespace
|
||||
dotnet_diagnostic.IDE0161.severity = silent
|
||||
|
||||
[{**/Shared/**.cs,**/microsoft.extensions.hostfactoryresolver.sources/**.{cs,vb}}]
|
||||
# IDE0005: Remove unused usings. Ignore for shared src files since imports for those depend on the projects in which they are included.
|
||||
dotnet_diagnostic.IDE0005.severity = silent
|
|
@ -1,13 +1,171 @@
|
|||
name: Test if Server can be built
|
||||
name: Build, Package and Push Images
|
||||
run-name: ${{ gitea.actor }} is building the Server application
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
preprocess:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }}
|
||||
steps:
|
||||
- name: Sanitize branch name
|
||||
id: sanitize
|
||||
run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')"
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: https://github.com/actions/setup-dotnet@v3
|
||||
with:
|
||||
global-json-file: global.json
|
||||
- run: dotnet build Server
|
||||
dotnet-version: 8.0
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build Server -c Release
|
||||
# dotnet test Server.Tests -c Release
|
||||
|
||||
sonarqube:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref_name == 'master'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: https://github.com/actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 8.0
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dotnet restore
|
||||
echo "::add-path::$HOME/.dotnet/tools"
|
||||
- name: Setup Sonarqube Dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install --yes openjdk-11-jre
|
||||
dotnet tool install --global dotnet-sonarscanner
|
||||
dotnet tool install --global dotnet-coverage
|
||||
- name: Sonarqube Begin
|
||||
run: |
|
||||
dotnet sonarscanner begin /key:"${{ secrets.SONAR_PROJECT_KEY }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
|
||||
- name: Sonarqube Scan
|
||||
run: |
|
||||
dotnet build Server -c Release
|
||||
# dotnet test --collect "Code Coverage" --logger trx --results-directory "TestsResults"
|
||||
# dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
|
||||
- name: Sonarqube End
|
||||
run: |
|
||||
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|
||||
|
||||
sbom-scan:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: https://github.com/actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: |
|
||||
7.0
|
||||
8.0
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dotnet restore
|
||||
echo "::add-path::$HOME/.dotnet/tools"
|
||||
- name: Setup Dependency Track Dependencies
|
||||
run: |
|
||||
dotnet tool install --global CycloneDX
|
||||
- name: Generate SBOM
|
||||
run: |
|
||||
dotnet CycloneDX Server/Server.csproj -o . -dgl
|
||||
- name: Upload SBOM
|
||||
uses: https://github.com/DependencyTrack/gh-upload-sbom@v2.0.1
|
||||
with:
|
||||
apiKey: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
|
||||
serverHostname: ${{ secrets.DEPENDENCY_TRACK_URL }}
|
||||
projectName: ${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }}
|
||||
autoCreate: true
|
||||
# set projectversion to be the branch name
|
||||
projectVersion: "${{ github.ref_name }}"
|
||||
bomFilename: "${{ github.workspace }}/bom.xml"
|
||||
|
||||
container-build:
|
||||
runs-on: ubuntu-latest
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
needs: [ build, preprocess ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: https://github.com/actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 8.0
|
||||
# Add support for more platforms with QEMU (optional)
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ github.server_url }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Server/Dockerfile
|
||||
push: true
|
||||
tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
- name: Build and push to latest
|
||||
if: github.ref_name == 'master'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Server/Dockerfile
|
||||
push: true
|
||||
tags: forge.rainote.dev/${{ github.repository }}:latest
|
||||
platforms: linux/amd64, linux/arm64
|
||||
|
||||
container-sbom-scan:
|
||||
needs: [ container-build, preprocess ]
|
||||
runs-on: ubuntu-latest
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: https://github.com/actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 8.0
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dotnet restore
|
||||
echo "::add-path::$HOME/.dotnet/tools"
|
||||
- name: Setup Dependency Track Dependencies
|
||||
run: |
|
||||
mkdir ~/.docker
|
||||
curl -sSfL https://raw.githubusercontent.com/docker/sbom-cli-plugin/main/install.sh | sh -s --
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ github.server_url }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Generate SBOM
|
||||
run: |
|
||||
docker sbom forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }} --format cyclonedx-json --output bom.json
|
||||
- name: Upload SBOM
|
||||
uses: https://github.com/DependencyTrack/gh-upload-sbom@v2.0.1
|
||||
with:
|
||||
apiKey: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
|
||||
serverHostname: ${{ secrets.DEPENDENCY_TRACK_URL }}
|
||||
projectName: "${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }}-container"
|
||||
autoCreate: true
|
||||
# set projectversion to be the branch name
|
||||
projectVersion: "${{ github.ref_name }}"
|
||||
bomFilename: "${{ github.workspace }}/bom.json"
|
||||
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.104">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -14,30 +14,30 @@ using BenchmarkDotNet.Order;
|
|||
[ThreadingDiagnoser]
|
||||
public class BinaryConversionBenchmarks
|
||||
{
|
||||
private byte[] data;
|
||||
private int offset;
|
||||
private byte[] _data = null!;
|
||||
private int _offset;
|
||||
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
this.data = RandomNumberGenerator.GetBytes(4000);
|
||||
this.offset = RandomNumberGenerator.GetInt32(0, 3500);
|
||||
this._data = RandomNumberGenerator.GetBytes(4000);
|
||||
this._offset = RandomNumberGenerator.GetInt32(0, 3500);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public short BitConverterTest() => BitConverter.ToInt16(this.data, this.offset);
|
||||
public short BitConverterTest() => BitConverter.ToInt16(this._data, this._offset);
|
||||
|
||||
[Benchmark]
|
||||
public short BinaryReader()
|
||||
{
|
||||
using var ms = new MemoryStream(this.data);
|
||||
using var ms = new MemoryStream(this._data);
|
||||
using var reader = new BinaryReader(ms);
|
||||
reader.BaseStream.Position = this.offset;
|
||||
reader.BaseStream.Position = this._offset;
|
||||
return reader.ReadInt16();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public short BinaryPrimitives() =>
|
||||
System.Buffers.Binary.BinaryPrimitives.ReadInt16LittleEndian(
|
||||
new ArraySegment<byte>(this.data, this.offset, sizeof(short)));
|
||||
new ArraySegment<byte>(this._data, this._offset, sizeof(short)));
|
||||
}
|
||||
|
|
|
@ -4,12 +4,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csp
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{7D560FA1-A61C-4B67-8300-835CA5814621}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{046A3B46-FC08-4B08-A52A-1DC5D426120D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C1303691-99F6-41CE-BAD3-2CA112D75DBF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker-compose.yml = docker-compose.yml
|
||||
EndProjectSection
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonderking", "Wonderking\Wonderking.csproj", "{6B53A10B-C397-4347-BB00-A12272D0528E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -17,8 +12,6 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{046A3B46-FC08-4B08-A52A-1DC5D426120D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{046A3B46-FC08-4B08-A52A-1DC5D426120D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7EDA8B31-3E03-4CA3-87D1-CFEB05C277D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7EDA8B31-3E03-4CA3-87D1-CFEB05C277D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7EDA8B31-3E03-4CA3-87D1-CFEB05C277D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -27,5 +20,9 @@ Global
|
|||
{7D560FA1-A61C-4B67-8300-835CA5814621}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
1227
Server/.dockerignore
Normal file
1227
Server/.dockerignore
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
|||
using Wonderking.Packets;
|
||||
|
||||
namespace Server;
|
||||
|
||||
using System.Reflection;
|
||||
|
@ -8,28 +10,28 @@ using Packets;
|
|||
|
||||
public class AuthSession : TcpSession
|
||||
{
|
||||
private readonly ILogger<AuthSession> logger;
|
||||
private readonly IMediator mediator;
|
||||
private readonly ILogger<AuthSession> _logger;
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public AuthSession(TcpServer
|
||||
server, IMediator mediator, ILogger<AuthSession> logger) : base(server)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
this.logger = logger;
|
||||
this._mediator = mediator;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
public override long Send(byte[] buffer)
|
||||
{
|
||||
this.logger.LogInformation("Data being sent is: {Data}", BitConverter.ToString(buffer));
|
||||
this._logger.LogInformation("Data being sent is: {Data}", BitConverter.ToString(buffer));
|
||||
return base.Send(buffer);
|
||||
}
|
||||
|
||||
public void Send(IPacket packet)
|
||||
{
|
||||
var type = packet.GetType();
|
||||
this.logger.LogTrace("Packet of type {Type} is being serialized", type.Name);
|
||||
this._logger.LogTrace("Packet of type {Type} is being serialized", type.Name);
|
||||
var packetIdAttribute = type.GetCustomAttribute<PacketIdAttribute>();
|
||||
if (packetIdAttribute == null)
|
||||
{
|
||||
|
@ -57,40 +59,40 @@ public class AuthSession : TcpSession
|
|||
buffer[2 + i] = bytesOfOpcode[i];
|
||||
}
|
||||
|
||||
this.logger.LogTrace("Packet data being parsed is: {Data}", BitConverter.ToString(packetData.ToArray()));
|
||||
this.logger.LogTrace("Packet being parsed is: {Data}", BitConverter.ToString(buffer.ToArray()));
|
||||
this._logger.LogTrace("Packet data being parsed is: {Data}", BitConverter.ToString(packetData.ToArray()));
|
||||
this._logger.LogTrace("Packet being parsed is: {Data}", BitConverter.ToString(buffer.ToArray()));
|
||||
|
||||
this.Send(buffer);
|
||||
}
|
||||
|
||||
protected override void OnReceived(byte[] buffer, long offset, long size)
|
||||
{
|
||||
this.logger.LogDebug("Length: {Size} & offset: {Offset}", size, offset);
|
||||
this._logger.LogDebug("Length: {Size} & offset: {Offset}", size, offset);
|
||||
Span<byte> decryptedBuffer = new byte[size];
|
||||
|
||||
// xor every value after the first 8 bytes
|
||||
var dataBuffer = Decrypt(new ArraySegment<byte>(buffer, 8, (int)size - 8).ToArray());
|
||||
|
||||
this.logger.LogDebug("Length {Length}", BitConverter.ToUInt16(buffer, 0));
|
||||
this._logger.LogDebug("Length {Length}", BitConverter.ToUInt16(buffer, 0));
|
||||
|
||||
var opCode = BitConverter.ToUInt16(buffer.ToArray(), 2);
|
||||
|
||||
this.logger.LogDebug("Packet Op Code: {OpCode}", opCode);
|
||||
this.logger.LogDebug("Some Value: {RandomValue}", buffer[4]);
|
||||
this._logger.LogDebug("Packet Op Code: {OpCode}", opCode);
|
||||
this._logger.LogDebug("Some Value: {RandomValue}", buffer[4]);
|
||||
|
||||
var clientAliveTime = BitConverter.ToUInt16(buffer.ToArray(), 5);
|
||||
|
||||
this.logger.LogDebug("Client Alive time: {ClientAliveTime}", clientAliveTime);
|
||||
this.logger.LogDebug("Might be a flag: {Flag}", buffer[7]);
|
||||
this._logger.LogDebug("Client Alive time: {ClientAliveTime}", clientAliveTime);
|
||||
this._logger.LogDebug("Might be a flag: {Flag}", buffer[7]);
|
||||
|
||||
this.logger.LogDebug("Full buffer: {Buffer}", BitConverter.ToString(dataBuffer.ToArray()));
|
||||
this._logger.LogDebug("Full buffer: {Buffer}", BitConverter.ToString(dataBuffer.ToArray()));
|
||||
|
||||
var rawPacket = new RawPacket((OperationCode)opCode, dataBuffer, clientAliveTime, buffer[7],
|
||||
buffer[4], this.Id, this);
|
||||
|
||||
_ = this.mediator.Send(rawPacket);
|
||||
_ = this._mediator.Send(rawPacket);
|
||||
|
||||
this.logger.LogInformation("Connection from: {@RemoteEndpoint}", this.Socket.RemoteEndPoint?.ToString());
|
||||
this._logger.LogInformation("Connection from: {@RemoteEndpoint}", this.Socket.RemoteEndPoint?.ToString());
|
||||
base.OnReceived(decryptedBuffer.ToArray(), offset, decryptedBuffer.Length);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,34 +8,34 @@ using NetCoreServer;
|
|||
|
||||
public class ChannelSession : TcpSession
|
||||
{
|
||||
private static readonly byte[] Key = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7 }
|
||||
private static readonly byte[] _key = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7 }
|
||||
.Reverse().ToArray();
|
||||
|
||||
private static readonly byte[] Iv = new byte[]
|
||||
private static readonly byte[] _iv = new byte[]
|
||||
{
|
||||
0xfe, 220, 0xba, 0x98, 0x76, 0x54, 50, 0x10, 15, 30, 0x2d, 60, 0x4b, 90, 0x69, 120
|
||||
}.Reverse().ToArray();
|
||||
|
||||
private readonly ICryptoTransform decryptor;
|
||||
private readonly ICryptoTransform _decryptor;
|
||||
|
||||
private readonly ICryptoTransform encryptor;
|
||||
private readonly ILogger<ChannelSession> logger;
|
||||
private readonly IMediator mediator;
|
||||
private readonly ICryptoTransform _encryptor;
|
||||
private readonly ILogger<ChannelSession> _logger;
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public ChannelSession(TcpServer server, IMediator mediator, ILogger<ChannelSession> logger) : base(server)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
this.logger = logger;
|
||||
this._mediator = mediator;
|
||||
this._logger = logger;
|
||||
var aes = Aes.Create();
|
||||
aes.Key = Key;
|
||||
aes.IV = Iv;
|
||||
aes.Key = _key;
|
||||
aes.IV = _iv;
|
||||
aes.Padding = PaddingMode.None;
|
||||
#pragma warning disable SEC0026
|
||||
aes.Mode = CipherMode.ECB;
|
||||
#pragma warning restore SEC0026
|
||||
|
||||
this.decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
this.encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
this._decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
this._encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
}
|
||||
|
||||
protected override void OnReceived(byte[] buffer, long offset, long size)
|
||||
|
@ -43,12 +43,12 @@ public class ChannelSession : TcpSession
|
|||
try
|
||||
{
|
||||
using (var ms = new MemoryStream(Decrypt(buffer)))
|
||||
using (var cs = new CryptoStream(ms, this.decryptor, CryptoStreamMode.Read))
|
||||
using (var cs = new CryptoStream(ms, this._decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
var amountOfReadBytes = cs.Read(buffer);
|
||||
if (amountOfReadBytes != buffer.Length)
|
||||
{
|
||||
this.logger.LogError("Amount of read bytes is not equal to buffer length.");
|
||||
this._logger.LogError("Amount of read bytes is not equal to buffer length.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ public class ChannelSession : TcpSession
|
|||
}
|
||||
catch (CryptographicException ex)
|
||||
{
|
||||
this.logger.LogError("An error has occured while decrypting: {ErrorMessage}", ex.Message);
|
||||
this.logger.LogError("Default buffer message: {Message}", Encoding.ASCII.GetString(buffer));
|
||||
this._logger.LogError("An error has occured while decrypting: {ErrorMessage}", ex.Message);
|
||||
this._logger.LogError("Default buffer message: {Message}", Encoding.ASCII.GetString(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ using Services;
|
|||
|
||||
public class PacketConsumer : IConsumer<RawPacket>
|
||||
{
|
||||
private readonly PacketDistributorService distributorService;
|
||||
private readonly PacketDistributorService _distributorService;
|
||||
|
||||
public PacketConsumer(PacketDistributorService distributorService) => this.distributorService = distributorService;
|
||||
public PacketConsumer(PacketDistributorService distributorService) => this._distributorService = distributorService;
|
||||
|
||||
public Task Consume(ConsumeContext<RawPacket> context)
|
||||
{
|
||||
this.distributorService.AddPacket(context.Message);
|
||||
this._distributorService.AddPacket(context.Message);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
public class WonderkingContext : DbContext
|
||||
{
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly ILoggerFactory loggerFactory;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
public WonderkingContext(ILoggerFactory loggerFactory, IConfiguration configuration)
|
||||
{
|
||||
this.loggerFactory = loggerFactory;
|
||||
this.configuration = configuration;
|
||||
this._loggerFactory = loggerFactory;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
public DbSet<Account> Accounts { get; set; }
|
||||
|
@ -22,8 +22,8 @@ public class WonderkingContext : DbContext
|
|||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
|
||||
optionsBuilder
|
||||
.UseNpgsql(
|
||||
$"Host={this.configuration["DB:Host"]};Username={this.configuration["DB:Username"]};Password={this.configuration["DB:Password"]};Database={this.configuration["DB:Database"]};Port={this.configuration["DB:Port"]}")
|
||||
.EnableSensitiveDataLogging().UseLoggerFactory(this.loggerFactory);
|
||||
$"Host={this._configuration["DB:Host"]};Username={this._configuration["DB:Username"]};Password={this._configuration["DB:Password"]};Database={this._configuration["DB:Database"]};Port={this._configuration["DB:Port"]}")
|
||||
.EnableSensitiveDataLogging().UseLoggerFactory(this._loggerFactory);
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) =>
|
||||
modelBuilder.Entity<Account>(builder =>
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0-bookworm-slim AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build
|
||||
ARG TARGETARCH
|
||||
ENV TZ=Etc/UTC
|
||||
ENV DOTNET_TieredPGO=1
|
||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
|
||||
RUN echo "Target: $TARGETARCH"
|
||||
RUN echo "Build: $BUILDPLATFORM"
|
||||
WORKDIR /src
|
||||
COPY ["Wonderking/Wonderking.csproj", "Wonderking/"]
|
||||
COPY ["Server/Server.csproj", "Server/"]
|
||||
RUN dotnet restore "Server/Server.csproj"
|
||||
RUN dotnet restore "Wonderking/Wonderking.csproj" -a $TARGETARCH
|
||||
RUN dotnet restore "Server/Server.csproj" -a $TARGETARCH
|
||||
COPY . .
|
||||
WORKDIR "/src/Server"
|
||||
RUN dotnet build "Server.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Server.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
RUN dotnet publish "Server/Server.csproj" -c Release -a $TARGETARCH --no-restore -f net8.0 -o /app
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Server.dll"]
|
||||
COPY --from=publish /app .
|
||||
USER $APP_UID
|
||||
ENTRYPOINT ["./Server"]
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
namespace Server;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Packets;
|
||||
using Wonderking.Packets;
|
||||
|
||||
namespace Server.LoggerMessages;
|
||||
|
||||
public static partial class PacketLoggerMessages
|
||||
{
|
||||
|
@ -43,7 +43,6 @@ public static partial class PacketLoggerMessages
|
|||
Message = "Packet data {PacketData}")]
|
||||
public static partial void PacketData(this ILogger logger, string packetData);
|
||||
|
||||
|
||||
[LoggerMessage(EventId = 9, Level = LogLevel.Critical,
|
||||
Message = "No Packets have been found")]
|
||||
public static partial void NoPacketsFound(this ILogger logger);
|
|
@ -1,23 +1,25 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Wonderking.Packets.Incoming;
|
||||
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using DB;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetCoreServer;
|
||||
using Packets.Incoming;
|
||||
|
||||
public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
||||
{
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly ILogger<ChannelSelectionHandler> logger;
|
||||
private readonly WonderkingContext wonderkingContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<ChannelSelectionHandler> _logger;
|
||||
private readonly WonderkingContext _wonderkingContext;
|
||||
|
||||
public ChannelSelectionHandler(IConfiguration configuration, ILogger<ChannelSelectionHandler> logger,
|
||||
WonderkingContext wonderkingContext)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.logger = logger;
|
||||
this.wonderkingContext = wonderkingContext;
|
||||
this._configuration = configuration;
|
||||
this._logger = logger;
|
||||
this._wonderkingContext = wonderkingContext;
|
||||
}
|
||||
|
||||
public ChannelSelectionHandler()
|
||||
|
@ -27,7 +29,9 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
|
|||
public Task HandleAsync(ChannelSelectionPacket packet, TcpSession session)
|
||||
{
|
||||
var authSession = (AuthSession)session;
|
||||
var charactersOfAccount = this.wonderkingContext.Accounts.FirstOrDefault(a => a.Id == authSession.AccountId);
|
||||
var charactersOfAccount = this._wonderkingContext.Accounts.Include(account => account.Characters)
|
||||
.FirstOrDefault(a => a.Id == authSession.AccountId)
|
||||
?.Characters;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
using Wonderking.Packets;
|
||||
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using NetCoreServer;
|
||||
using Packets;
|
||||
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public interface IPacketHandler<in T> where T : IPacket
|
||||
|
|
|
@ -1,35 +1,36 @@
|
|||
namespace Server.PacketHandlers;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Wonderking.Packets.Incoming;
|
||||
using Wonderking.Packets.Outgoing;
|
||||
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using DB;
|
||||
using DB.Documents;
|
||||
using Konscious.Security.Cryptography;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetCoreServer;
|
||||
using Packets.Incoming;
|
||||
using Packets.Outgoing;
|
||||
|
||||
public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
||||
{
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly ILogger<LoginHandler> logger;
|
||||
private readonly WonderkingContext wonderkingContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<LoginHandler> _logger;
|
||||
private readonly WonderkingContext _wonderkingContext;
|
||||
|
||||
public LoginHandler(ILogger<LoginHandler> logger, WonderkingContext wonderkingContext, IConfiguration configuration)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.wonderkingContext = wonderkingContext;
|
||||
this.configuration = configuration;
|
||||
this._logger = logger;
|
||||
this._wonderkingContext = wonderkingContext;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task HandleAsync(LoginInfoPacket packet, TcpSession session)
|
||||
{
|
||||
LoginResponseReason loginResponseReason;
|
||||
this.logger.LogInformation("Login data: Username {Username} & Password {Password}", packet.Username,
|
||||
this._logger.LogInformation("Login data: Username {Username} & Password {Password}", packet.Username,
|
||||
packet.Password);
|
||||
var account = this.wonderkingContext.Accounts.FirstOrDefault(a => a.Username == packet.Username);
|
||||
var account = this._wonderkingContext.Accounts.FirstOrDefault(a => a.Username == packet.Username);
|
||||
|
||||
// https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Chea1t_Sheet.html#argon2id
|
||||
// "Use Argon2id with a minimum configuration of 19 MiB of memory, an iteration count of 2, and 1 degree of parallelism."
|
||||
|
@ -41,22 +42,22 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
};
|
||||
if (account == null)
|
||||
{
|
||||
if (this.configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
|
||||
if (this._configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
|
||||
{
|
||||
argon2Id.Salt = RandomNumberGenerator.GetBytes(16);
|
||||
var finalAccount =
|
||||
await this.wonderkingContext.Accounts.AddAsync(new Account(packet.Username, Array.Empty<byte>(), "",
|
||||
await this._wonderkingContext.Accounts.AddAsync(new Account(packet.Username, Array.Empty<byte>(), "",
|
||||
0, argon2Id.Salt)).ConfigureAwait(true);
|
||||
await this.wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
await this._wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
argon2Id.AssociatedData = finalAccount.Entity.Id.ToByteArray();
|
||||
finalAccount.Entity.Password = await argon2Id.GetBytesAsync(16).ConfigureAwait(true);
|
||||
this.wonderkingContext.Accounts.Update(finalAccount.Entity);
|
||||
this._wonderkingContext.Accounts.Update(finalAccount.Entity);
|
||||
loginResponseReason = LoginResponseReason.Ok;
|
||||
await this.wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
await this._wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.logger.LogInformation("Requested account for user: {Username} does not exist", packet.Username);
|
||||
this._logger.LogInformation("Requested account for user: {Username} does not exist", packet.Username);
|
||||
loginResponseReason = LoginResponseReason.AccountDoesNotExit;
|
||||
}
|
||||
}
|
||||
|
@ -78,13 +79,10 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
IsGameMaster = true
|
||||
};
|
||||
var sess = session as AuthSession;
|
||||
if (account != null)
|
||||
{
|
||||
if (sess != null)
|
||||
if (account != null && sess != null)
|
||||
{
|
||||
sess.AccountId = account.Id;
|
||||
}
|
||||
}
|
||||
|
||||
sess?.Send(loginResponsePacket);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using Wonderking.Packets;
|
||||
|
||||
namespace Server.Packets;
|
||||
|
||||
using MassTransit;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#pragma warning disable AV1500
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using MassTransit;
|
||||
|
@ -35,11 +34,10 @@ builder.Services.AddHostedService(provider => new WonderkingAuthServer(IPAddress
|
|||
provider.GetService<IServiceProvider>() ?? throw new InvalidOperationException()));
|
||||
|
||||
using var host = builder.Build();
|
||||
await using (var scope = host.Services.CreateAsyncScope())
|
||||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<WonderkingContext>();
|
||||
await db.Database.MigrateAsync().ConfigureAwait(true);
|
||||
}
|
||||
|
||||
await host.RunAsync().ConfigureAwait(true);
|
||||
#pragma warning restore AV1500
|
||||
|
|
|
@ -2,13 +2,32 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>warnings</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<RootNamespace>Server</RootNamespace>
|
||||
<LangVersion>default</LangVersion>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<Features>strict</Features>
|
||||
<Authors>Timothy (RaiNote) Schenk</Authors>
|
||||
<Copyright>Timothy (RaiNote) Schenk</Copyright>
|
||||
<PackageProjectUrl>https://forge.rainote.dev/wonderking/continuity</PackageProjectUrl>
|
||||
<RepositoryUrl>https://forge.rainote.dev/wonderking/continuity</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<GenerateDocumentationFile>False</GenerateDocumentationFile>
|
||||
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<AnalysisLevel>latest-recommended</AnalysisLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
|
||||
<WarningLevel>7</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
|
||||
<WarningLevel>7</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -18,26 +37,35 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNext" Version="4.15.0" />
|
||||
<PackageReference Include="AsyncFixer" Version="1.6.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="DotNext" Version="4.15.0"/>
|
||||
<PackageReference Include="DotNext.IO" Version="4.15.0"/>
|
||||
<PackageReference Include="DotNext.Metaprogramming" Version="4.15.0"/>
|
||||
<PackageReference Include="DotNext.Reflection" Version="4.9.0"/>
|
||||
<PackageReference Include="DotNext.Threading" Version="4.14.2"/>
|
||||
<PackageReference Include="DotNext.Unsafe" Version="4.14.0"/>
|
||||
<PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0"/>
|
||||
<PackageReference Include="JetBrains.ExternalAnnotations" Version="10.2.134"/>
|
||||
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/>
|
||||
<PackageReference Include="MassTransit" Version="8.1.1"/>
|
||||
<PackageReference Include="MassTransit.Analyzers" Version="8.1.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.13" />
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.104">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview1.23165.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.13"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.13"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/>
|
||||
|
@ -68,4 +96,15 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wonderking\Wonderking.csproj"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
using Server.LoggerMessages;
|
||||
using Wonderking.Packets;
|
||||
|
||||
namespace Server.Services;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
@ -17,35 +20,32 @@ using static DotNext.Metaprogramming.CodeGenerator;
|
|||
|
||||
public class PacketDistributorService : IHostedService
|
||||
{
|
||||
private readonly ConcurrentQueue<RawPacket> concurrentQueue;
|
||||
private readonly ConcurrentQueue<RawPacket> _concurrentQueue;
|
||||
|
||||
private readonly
|
||||
ImmutableDictionary<OperationCode,
|
||||
Func<byte[], IPacket>> deserializationMap;
|
||||
Func<byte[], IPacket>> _deserializationMap;
|
||||
|
||||
private readonly ILogger<PacketDistributorService> logger;
|
||||
private readonly ConcurrentDictionary<OperationCode, object> packetHandlersInstantiation;
|
||||
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly ILogger<PacketDistributorService> _logger;
|
||||
private readonly ConcurrentDictionary<OperationCode, object> _packetHandlersInstantiation;
|
||||
|
||||
public PacketDistributorService(ILogger<PacketDistributorService> logger, IServiceProvider serviceProvider)
|
||||
{
|
||||
this.concurrentQueue = new ConcurrentQueue<RawPacket>();
|
||||
this.logger = logger;
|
||||
this.serviceProvider = serviceProvider;
|
||||
this._concurrentQueue = new ConcurrentQueue<RawPacket>();
|
||||
this._logger = logger;
|
||||
var tempDeserializationMap =
|
||||
new Dictionary<OperationCode, Func<byte[], IPacket>>();
|
||||
|
||||
var executingAssembly = Assembly.GetExecutingAssembly();
|
||||
var packetsTypes = this.GetPacketsWithId(executingAssembly);
|
||||
var packetHandlers = this.GetAllPacketHandlersWithId(executingAssembly);
|
||||
this.packetHandlersInstantiation = new ConcurrentDictionary<OperationCode, object>();
|
||||
this._packetHandlersInstantiation = new ConcurrentDictionary<OperationCode, object>();
|
||||
packetHandlers.ForEach(x =>
|
||||
{
|
||||
var packetHandler =
|
||||
ActivatorUtilities.GetServiceOrCreateInstance(this.serviceProvider,
|
||||
ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider,
|
||||
x.Value);
|
||||
this.packetHandlersInstantiation.TryAdd(x.Key, packetHandler);
|
||||
this._packetHandlersInstantiation.TryAdd(x.Key, packetHandler);
|
||||
});
|
||||
foreach (var packetsType in packetsTypes)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public class PacketDistributorService : IHostedService
|
|||
tempDeserializationMap.Add(packetsType.Key, lambda);
|
||||
}
|
||||
|
||||
this.deserializationMap = tempDeserializationMap.ToImmutableDictionary();
|
||||
this._deserializationMap = tempDeserializationMap.ToImmutableDictionary();
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
@ -82,45 +82,56 @@ public class PacketDistributorService : IHostedService
|
|||
if (packetsWithId is not { Count: 0 })
|
||||
{
|
||||
packetsWithId.AsParallel()
|
||||
.ForAll(packet => this.logger.PacketWithIdAdded(packet.Key, packet.Value.FullName));
|
||||
.ForAll(packet => this._logger.PacketWithIdAdded(packet.Key, packet.Value.FullName));
|
||||
return packetsWithId;
|
||||
}
|
||||
|
||||
this.logger.NoPacketsFound();
|
||||
this._logger.NoPacketsFound();
|
||||
throw new IncompleteInitialization();
|
||||
}
|
||||
|
||||
private Dictionary<OperationCode, Type> GetAllPacketHandlersWithId(Assembly assembly)
|
||||
{
|
||||
var packetHandlersWithId = assembly.GetTypes().AsParallel().Where(t =>
|
||||
t is { IsClass: true, IsAbstract: false } && t
|
||||
.GetInterfaces().Any(i =>
|
||||
i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))).ToDictionary(type =>
|
||||
type.GetInterfaces().First(t =>
|
||||
t is { IsGenericType: true } && t.GetGenericTypeDefinition() == typeof(IPacketHandler<>))
|
||||
.GetGenericArguments().First().GetCustomAttribute<PacketIdAttribute>().Code);
|
||||
// ! : We are filtering if types that don't have an instance of the required Attribute
|
||||
var packetHandlersWithId = assembly.GetTypes().AsParallel()
|
||||
.Where(t =>
|
||||
t is { IsClass: true, IsAbstract: false } && Array.Exists(t
|
||||
.GetInterfaces(), i =>
|
||||
i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>)))
|
||||
.Select(type => new
|
||||
{
|
||||
Type = type,
|
||||
PacketId = type
|
||||
.GetInterfaces().First(t1 =>
|
||||
t1 is { IsGenericType: true } && t1.GetGenericTypeDefinition() == typeof(IPacketHandler<>))
|
||||
.GetGenericArguments()[0].GetCustomAttribute<PacketIdAttribute>()?.Code
|
||||
})
|
||||
.Where(x => x.PacketId is not null)
|
||||
.ToDictionary(
|
||||
x => x.PacketId!.Value, x => x.Type
|
||||
);
|
||||
|
||||
if (packetHandlersWithId is not { Count: 0 })
|
||||
{
|
||||
packetHandlersWithId.AsParallel().ForAll(packetHandler =>
|
||||
this.logger.PacketHandlerWithIdAdded(packetHandler.Key, packetHandler.Value.FullName));
|
||||
this._logger.PacketHandlerWithIdAdded(packetHandler.Key, packetHandler.Value.FullName));
|
||||
return packetHandlersWithId;
|
||||
}
|
||||
|
||||
this.logger.NoPacketHandlersFound();
|
||||
this._logger.NoPacketHandlersFound();
|
||||
throw new IncompleteInitialization();
|
||||
}
|
||||
|
||||
public void AddPacket(RawPacket rawPacket)
|
||||
{
|
||||
this.concurrentQueue.Enqueue(rawPacket);
|
||||
this._concurrentQueue.Enqueue(rawPacket);
|
||||
this.DequeueRawPacket();
|
||||
this.logger.PacketReceived(rawPacket.OperationCode);
|
||||
this._logger.PacketReceived(rawPacket.OperationCode);
|
||||
}
|
||||
|
||||
private void DequeueRawPacket()
|
||||
{
|
||||
if (this.concurrentQueue.TryDequeue(out var item))
|
||||
if (this._concurrentQueue.TryDequeue(out var item))
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(this.InvokePacketHandler, item, true);
|
||||
}
|
||||
|
@ -128,18 +139,19 @@ public class PacketDistributorService : IHostedService
|
|||
|
||||
private void InvokePacketHandler(RawPacket item)
|
||||
{
|
||||
this.logger.PacketDequeued(item.Session.Id, item.OperationCode);
|
||||
if (!this.deserializationMap.ContainsKey(item.OperationCode))
|
||||
this._logger.PacketDequeued(item.Session.Id, item.OperationCode);
|
||||
if (!this._deserializationMap.TryGetValue(item.OperationCode, out var value))
|
||||
{
|
||||
this.logger.PacketTypeNotFound(item.OperationCode);
|
||||
this._logger.PacketTypeNotFound(item.OperationCode);
|
||||
return;
|
||||
}
|
||||
|
||||
var packet = this.deserializationMap[item.OperationCode](item.MessageBody);
|
||||
this.logger.PacketData(JsonConvert.SerializeObject(packet));
|
||||
this.packetHandlersInstantiation[item.OperationCode].GetType().GetMethod(nameof(IPacketHandler<IPacket>.HandleAsync))
|
||||
?.Invoke(this.packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session });
|
||||
var packet = value(item.MessageBody);
|
||||
this._logger.PacketData(JsonConvert.SerializeObject(packet));
|
||||
this._packetHandlersInstantiation[item.OperationCode].GetType()
|
||||
.GetMethod(nameof(IPacketHandler<IPacket>.HandleAsync))
|
||||
?.Invoke(this._packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session });
|
||||
|
||||
this.logger.PacketFinished(item.Session.Id, item.OperationCode);
|
||||
this._logger.PacketFinished(item.Session.Id, item.OperationCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ using NetCoreServer;
|
|||
|
||||
public class WonderkingAuthServer : TcpServer, IHostedService
|
||||
{
|
||||
private readonly ILogger<WonderkingAuthServer> logger;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly ILogger<WonderkingAuthServer> _logger;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public WonderkingAuthServer(IPAddress address, int port, ILogger<WonderkingAuthServer> logger,
|
||||
IServiceProvider serviceProvider) : base(address, port)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.serviceProvider = serviceProvider;
|
||||
this._logger = logger;
|
||||
this._serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
|
@ -32,31 +32,31 @@ public class WonderkingAuthServer : TcpServer, IHostedService
|
|||
}
|
||||
|
||||
protected override TcpSession CreateSession() =>
|
||||
ActivatorUtilities.CreateInstance<AuthSession>(this.serviceProvider, this);
|
||||
ActivatorUtilities.CreateInstance<AuthSession>(this._serviceProvider, this);
|
||||
|
||||
protected override void OnStarting()
|
||||
{
|
||||
this.logger.LogInformation("Starting");
|
||||
this._logger.LogInformation("Starting");
|
||||
base.OnStarting();
|
||||
}
|
||||
|
||||
protected override void OnStarted()
|
||||
{
|
||||
this.logger.LogInformation("Started");
|
||||
this._logger.LogInformation("Started");
|
||||
base.OnStarted();
|
||||
}
|
||||
|
||||
protected override void OnStopping()
|
||||
{
|
||||
this.logger.LogInformation("Stopping");
|
||||
this._logger.LogInformation("Stopping");
|
||||
base.OnStopping();
|
||||
}
|
||||
|
||||
protected override void OnStopped()
|
||||
{
|
||||
this.logger.LogInformation("Stopped");
|
||||
this._logger.LogInformation("Stopped");
|
||||
base.OnStopped();
|
||||
}
|
||||
|
||||
protected override void OnError(SocketError error) => this.logger.LogError("An error has occured {Error}", error);
|
||||
protected override void OnError(SocketError error) => this._logger.LogError("An error has occured {Error}", error);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
services:
|
||||
server:
|
||||
image: continuity-server:latest
|
||||
container_name: continuity-server
|
||||
image: server:latest
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- ENVIRONMENT=Development
|
||||
- Testing:CreateAccountOnLogin=true
|
||||
|
@ -14,6 +17,7 @@
|
|||
- "10001:10001"
|
||||
|
||||
db:
|
||||
container_name: continuity-db
|
||||
image: postgres:16.0-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=continuity
|
||||
|
@ -23,6 +27,11 @@
|
|||
- continuity
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'" ]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
networks:
|
||||
continuity:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace Server.Packets;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Wonderking.Packets;
|
||||
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public interface IPacket
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Incoming;
|
||||
namespace Wonderking.Packets.Incoming;
|
||||
|
||||
[PacketId(OperationCode.ChannelSelection)]
|
||||
public class ChannelSelectionPacket : IPacket
|
||||
|
@ -12,5 +12,5 @@ public class ChannelSelectionPacket : IPacket
|
|||
this.ChannelId = BitConverter.ToUInt16(data, 2);
|
||||
}
|
||||
|
||||
public byte[] Serialize() => throw new NotImplementedException();
|
||||
public byte[] Serialize() => throw new NotSupportedException();
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
namespace Server.Packets.Incoming;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Wonderking.Packets.Incoming;
|
||||
|
||||
[PacketId(OperationCode.LoginInfo)]
|
||||
public class LoginInfoPacket : IPacket
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Wonderking.Packets;
|
||||
|
||||
public enum OperationCode : ushort
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
namespace Wonderking.Packets.Outgoing;
|
||||
|
||||
[PacketId(OperationCode.LoginResponse)]
|
||||
public class LoginResponsePacket : IPacket
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
namespace Wonderking.Packets.Outgoing;
|
||||
|
||||
public enum LoginResponseReason : byte
|
||||
{
|
|
@ -1,5 +1,8 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Wonderking.Packets.Outgoing;
|
||||
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct ServerChannelData
|
||||
{
|
||||
public ushort ServerId { get; set; }
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Wonderking.Packets;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class PacketIdAttribute : Attribute
|
34
Wonderking/Wonderking.csproj
Normal file
34
Wonderking/Wonderking.csproj
Normal file
|
@ -0,0 +1,34 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
|
||||
<Features>strict</Features>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncFixer" Version="1.6.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" />
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.104">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview1.23165.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.7.30">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,7 +0,0 @@
|
|||
:; set -eo pipefail
|
||||
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||||
:; ${SCRIPT_DIR}/build.sh "$@"
|
||||
:; exit $?
|
||||
|
||||
@ECHO OFF
|
||||
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
|
74
build.ps1
74
build.ps1
|
@ -1,74 +0,0 @@
|
|||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||
[string[]]$BuildArguments
|
||||
)
|
||||
|
||||
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
|
||||
|
||||
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
|
||||
###########################################################################
|
||||
# CONFIGURATION
|
||||
###########################################################################
|
||||
|
||||
$BuildProjectFile = "$PSScriptRoot\build\build.csproj"
|
||||
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
|
||||
|
||||
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
|
||||
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
|
||||
$DotNetChannel = "STS"
|
||||
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
|
||||
$env:DOTNET_MULTILEVEL_LOOKUP = 0
|
||||
|
||||
###########################################################################
|
||||
# EXECUTION
|
||||
###########################################################################
|
||||
|
||||
function ExecSafe([scriptblock] $cmd) {
|
||||
& $cmd
|
||||
if ($LASTEXITCODE) { exit $LASTEXITCODE }
|
||||
}
|
||||
|
||||
# If dotnet CLI is installed globally and it matches requested version, use for execution
|
||||
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
|
||||
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
|
||||
$env:DOTNET_EXE = (Get-Command "dotnet").Path
|
||||
}
|
||||
else {
|
||||
# Download install script
|
||||
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
|
||||
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
|
||||
|
||||
# If global.json exists, load expected version
|
||||
if (Test-Path $DotNetGlobalFile) {
|
||||
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
|
||||
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
|
||||
$DotNetVersion = $DotNetGlobal.sdk.version
|
||||
}
|
||||
}
|
||||
|
||||
# Install by channel or version
|
||||
$DotNetDirectory = "$TempDirectory\dotnet-win"
|
||||
if (!(Test-Path variable:DotNetVersion)) {
|
||||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
|
||||
} else {
|
||||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
|
||||
}
|
||||
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
|
||||
}
|
||||
|
||||
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
|
||||
|
||||
if (Test-Path env:NUKE_ENTERPRISE_TOKEN) {
|
||||
& $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null
|
||||
& $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null
|
||||
}
|
||||
|
||||
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
|
||||
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
|
66
build.sh
66
build.sh
|
@ -1,66 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
bash --version 2>&1 | head -n 1
|
||||
|
||||
set -eo pipefail
|
||||
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||||
|
||||
###########################################################################
|
||||
# CONFIGURATION
|
||||
###########################################################################
|
||||
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/build.csproj"
|
||||
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
|
||||
|
||||
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
|
||||
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
|
||||
DOTNET_CHANNEL="STS"
|
||||
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
export DOTNET_MULTILEVEL_LOOKUP=0
|
||||
|
||||
###########################################################################
|
||||
# EXECUTION
|
||||
###########################################################################
|
||||
|
||||
function FirstJsonValue {
|
||||
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
|
||||
}
|
||||
|
||||
# If dotnet CLI is installed globally and it matches requested version, use for execution
|
||||
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
|
||||
export DOTNET_EXE="$(command -v dotnet)"
|
||||
else
|
||||
# Download install script
|
||||
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
|
||||
mkdir -p "$TEMP_DIRECTORY"
|
||||
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
|
||||
chmod +x "$DOTNET_INSTALL_FILE"
|
||||
|
||||
# If global.json exists, load expected version
|
||||
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
|
||||
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
|
||||
if [[ "$DOTNET_VERSION" == "" ]]; then
|
||||
unset DOTNET_VERSION
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install by channel or version
|
||||
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
|
||||
if [[ -z ${DOTNET_VERSION+x} ]]; then
|
||||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
|
||||
else
|
||||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
|
||||
fi
|
||||
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
|
||||
fi
|
||||
|
||||
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
|
||||
|
||||
if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
|
||||
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
|
||||
"$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true
|
||||
fi
|
||||
|
||||
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
|
||||
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
|
|
@ -1,11 +0,0 @@
|
|||
[*.cs]
|
||||
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
|
||||
dotnet_style_require_accessibility_modifiers = never:warning
|
||||
|
||||
csharp_style_expression_bodied_methods = true:silent
|
||||
csharp_style_expression_bodied_properties = true:warning
|
||||
csharp_style_expression_bodied_indexers = true:warning
|
||||
csharp_style_expression_bodied_accessors = true:warning
|
|
@ -1,79 +0,0 @@
|
|||
using Nuke.Common;
|
||||
using Nuke.Common.Git;
|
||||
using Nuke.Common.IO;
|
||||
using Nuke.Common.Tools.Docker;
|
||||
using Nuke.Common.Tools.DotNet;
|
||||
using Nuke.Common.Tools.SonarScanner;
|
||||
using Serilog;
|
||||
|
||||
class Build : NukeBuild
|
||||
{
|
||||
/// Support plugins are available for:
|
||||
/// - JetBrains ReSharper https://nuke.build/resharper
|
||||
/// - JetBrains Rider https://nuke.build/rider
|
||||
/// - Microsoft VisualStudio https://nuke.build/visualstudio
|
||||
/// - Microsoft VSCode https://nuke.build/vscode
|
||||
public static int Main() => Execute<Build>(x => x.Information, x => x.Deploy);
|
||||
|
||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
|
||||
|
||||
GitRepository GitRepository => GitRepository.FromLocalDirectory(RootDirectory);
|
||||
|
||||
Target Information => _ => _
|
||||
.Before(Clean)
|
||||
.Executes(() =>
|
||||
{
|
||||
Log.Information("Branch Name: {BranchName}", GitRepository.Branch);
|
||||
Log.Information("Commit: {Commit}", GitRepository.Commit);
|
||||
});
|
||||
|
||||
Target Clean => _ => _
|
||||
.Before(Restore)
|
||||
.Executes(() => DotNetTasks.DotNetClean());
|
||||
|
||||
Target Restore => _ => _
|
||||
.Executes(() => DotNetTasks.DotNetRestore());
|
||||
|
||||
Target Compile => _ => _
|
||||
.DependsOn(Clean)
|
||||
.DependsOn(Restore)
|
||||
.Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerStackRm(settings => settings.SetStacks("continuity"));
|
||||
DotNetTasks.DotNetBuild(settings => settings.SetNoRestore(true));
|
||||
});
|
||||
|
||||
Target Pack => _ => _
|
||||
.DependsOn(Compile)
|
||||
.Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerBuild(settings => settings
|
||||
.SetPath(AbsolutePath.Create(RootDirectory))
|
||||
.SetFile("Server/Dockerfile")
|
||||
.SetTag("continuity-server:latest")
|
||||
.SetCompress(true)
|
||||
.SetProgress(ProgressType.auto));
|
||||
if (!IsLocalBuild)
|
||||
{
|
||||
DockerTasks.DockerPush(settings => settings.SetName("continuity-server:latest"));
|
||||
}
|
||||
});
|
||||
|
||||
Target Deploy => _ => _.DependsOn(Pack).Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerPull(settings => settings.SetName("postgres:16.0-alpine"));
|
||||
if (IsLocalBuild)
|
||||
{
|
||||
var dockerComposeFile = AbsolutePath.Create(RootDirectory / "Server" / "docker-compose.yml");
|
||||
DockerTasks.DockerStackDeploy(settings => settings
|
||||
.AddComposeFile(dockerComposeFile)
|
||||
.SetStack("continuity")
|
||||
.SetPrune(true)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Error("Deploy is only available on local builds.");
|
||||
});
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using System.ComponentModel;
|
||||
using Nuke.Common.Tooling;
|
||||
|
||||
[TypeConverter(typeof(TypeConverter<Configuration>))]
|
||||
public class Configuration : Enumeration
|
||||
{
|
||||
public static Configuration Debug { get; } = new() { Value = nameof(Debug) };
|
||||
public static Configuration Release { get; } = new() { Value = nameof(Release) };
|
||||
|
||||
public static implicit operator string(Configuration configuration) => configuration.Value;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!-- This file prevents unintended imports of unrelated MSBuild files -->
|
||||
<!-- Uncomment to include parent Directory.Build.props file -->
|
||||
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />-->
|
||||
|
||||
</Project>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<!-- This file prevents unintended imports of unrelated MSBuild files -->
|
||||
<!-- Uncomment to include parent Directory.Build.targets file -->
|
||||
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />-->
|
||||
|
||||
</Project>
|
|
@ -1,18 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace></RootNamespace>
|
||||
<NoWarn>CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006</NoWarn>
|
||||
<NukeRootDirectory>..</NukeRootDirectory>
|
||||
<NukeScriptDirectory>..</NukeScriptDirectory>
|
||||
<NukeTelemetryVersion>1</NukeTelemetryVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nuke.Common" Version="7.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,28 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=HeapView_002EDelegateAllocation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableHidesOuterVariable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassNeverInstantiated_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBeMadeStatic_002ELocal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=InterpolatedStringExpressionIsNotIFormattable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">0</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">False</s:Boolean>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ATTRIBUTE_LENGTH_FOR_SAME_LINE/@EntryValue">120</s:Int64>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">IF_OWNER_IS_SINGLE_LINE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "8.0.0",
|
||||
"rollForward": "latestMinor",
|
||||
"version": "7.0.403",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": true
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue