From a6cbb0844a6d1b9a0999eb27678fca78c5473950 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 11 Apr 2020 12:34:10 +0900 Subject: [PATCH 1/5] 1. remove osu.game because it's no longer be used. 2. fix typo 3. update .editorContig from official --- .editorconfig | 179 +++++++++++++++++- .../Skinning/KaraokeHitObjectTestScene.cs | 2 +- osu.Game.props | 21 -- 3 files changed, 174 insertions(+), 28 deletions(-) delete mode 100644 osu.Game.props diff --git a/.editorconfig b/.editorconfig index 24825b7c4..440c24fe1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,16 +12,183 @@ trim_trailing_whitespace = true #PascalCase for public and protected members dotnet_naming_style.pascalcase.capitalization = pascal_case -dotnet_naming_symbols.public_members.applicable_accessibilities = public,internal,protected,protected_internal -dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event,delegate -dotnet_naming_rule.public_members_pascalcase.severity = suggestion +dotnet_naming_symbols.public_members.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event +dotnet_naming_rule.public_members_pascalcase.severity = error dotnet_naming_rule.public_members_pascalcase.symbols = public_members dotnet_naming_rule.public_members_pascalcase.style = pascalcase #camelCase for private members dotnet_naming_style.camelcase.capitalization = camel_case + dotnet_naming_symbols.private_members.applicable_accessibilities = private -dotnet_naming_symbols.private_members.applicable_kinds = property,method,field,event,delegate -dotnet_naming_rule.private_members_camelcase.severity = suggestion +dotnet_naming_symbols.private_members.applicable_kinds = property,method,field,event +dotnet_naming_rule.private_members_camelcase.severity = warning dotnet_naming_rule.private_members_camelcase.symbols = private_members -dotnet_naming_rule.private_members_camelcase.style = camelcase \ No newline at end of file +dotnet_naming_rule.private_members_camelcase.style = camelcase + +dotnet_naming_symbols.local_function.applicable_kinds = local_function +dotnet_naming_rule.local_function_camelcase.severity = warning +dotnet_naming_rule.local_function_camelcase.symbols = local_function +dotnet_naming_rule.local_function_camelcase.style = camelcase + +#all_lower for private and local constants/static readonlys +dotnet_naming_style.all_lower.capitalization = all_lower +dotnet_naming_style.all_lower.word_separator = _ + +dotnet_naming_symbols.private_constants.applicable_accessibilities = private +dotnet_naming_symbols.private_constants.required_modifiers = const +dotnet_naming_symbols.private_constants.applicable_kinds = field +dotnet_naming_rule.private_const_all_lower.severity = warning +dotnet_naming_rule.private_const_all_lower.symbols = private_constants +dotnet_naming_rule.private_const_all_lower.style = all_lower + +dotnet_naming_symbols.private_static_readonly.applicable_accessibilities = private +dotnet_naming_symbols.private_static_readonly.required_modifiers = static,readonly +dotnet_naming_symbols.private_static_readonly.applicable_kinds = field +dotnet_naming_rule.private_static_readonly_all_lower.severity = warning +dotnet_naming_rule.private_static_readonly_all_lower.symbols = private_static_readonly +dotnet_naming_rule.private_static_readonly_all_lower.style = all_lower + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.required_modifiers = const +dotnet_naming_rule.local_const_all_lower.severity = warning +dotnet_naming_rule.local_const_all_lower.symbols = local_constants +dotnet_naming_rule.local_const_all_lower.style = all_lower + +#ALL_UPPER for non private constants/static readonlys +dotnet_naming_style.all_upper.capitalization = all_upper +dotnet_naming_style.all_upper.word_separator = _ + +dotnet_naming_symbols.public_constants.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.public_constants.required_modifiers = const +dotnet_naming_symbols.public_constants.applicable_kinds = field +dotnet_naming_rule.public_const_all_upper.severity = warning +dotnet_naming_rule.public_const_all_upper.symbols = public_constants +dotnet_naming_rule.public_const_all_upper.style = all_upper + +dotnet_naming_symbols.public_static_readonly.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.public_static_readonly.required_modifiers = static,readonly +dotnet_naming_symbols.public_static_readonly.applicable_kinds = field +dotnet_naming_rule.public_static_readonly_all_upper.severity = warning +dotnet_naming_rule.public_static_readonly_all_upper.symbols = public_static_readonly +dotnet_naming_rule.public_static_readonly_all_upper.style = all_upper + +#Roslyn formating options + +#Formatting - indentation options +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +#Formatting - new line options +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_open_brace = all +#csharp_new_line_before_members_in_anonymous_types = true +#csharp_new_line_before_members_in_object_initializers = true # Currently no effect in VS/dotnet format (16.4), and makes Rider confusing +csharp_new_line_between_query_expression_clauses = true + +#Formatting - organize using options +dotnet_sort_system_directives_first = true + +#Formatting - spacing options +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false + +#Formatting - wrapping options +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#Roslyn language styles + +#Style - this. qualification +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 + +#Style - type names +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning +csharp_style_var_when_type_is_apparent = true:none +csharp_style_var_for_built_in_types = true:none +csharp_style_var_elsewhere = true:silent + +#Style - modifiers +dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning +csharp_preferred_modifier_order = public,private,protected,internal,new,abstract,virtual,sealed,override,static,readonly,extern,unsafe,volatile,async:warning + +#Style - parentheses +# Skipped because roslyn cannot separate +-*/ with << >> + +#Style - expression bodies +csharp_style_expression_bodied_accessors = true:warning +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = true:warning +csharp_style_expression_bodied_properties = true:warning +csharp_style_expression_bodied_local_functions = true:silent + +#Style - expression preferences +dotnet_style_object_initializer = true:warning +dotnet_style_collection_initializer = 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 = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_compound_assignment = true:warning + +#Style - null/type checks +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_throw_expression = true:silent +csharp_style_conditional_delegate_call = true:warning + +#Style - unused +dotnet_style_readonly_field = true:silent +dotnet_code_quality_unused_parameters = non_public:silent +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_style_unused_value_assignment_preference = discard_variable:warning + +#Style - variable declaration +csharp_style_inlined_variable_declaration = true:warning +csharp_style_deconstructed_variable_declaration = true:warning + +#Style - other C# 7.x features +dotnet_style_prefer_inferred_tuple_names = true:warning +csharp_prefer_simple_default_expression = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent + +#Style - C# 8 features +csharp_prefer_static_local_function = true:warning +csharp_prefer_simple_using_statement = true:silent +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_prefer_switch_expression = false:none + +#Supressing roslyn built-in analyzers +# Suppress: EC112 + +#Private method is unused +dotnet_diagnostic.IDE0051.severity = silent +#Private member is unused +dotnet_diagnostic.IDE0052.severity = silent + +#Rules for disposable +dotnet_diagnostic.IDE0067.severity = none +dotnet_diagnostic.IDE0068.severity = none +dotnet_diagnostic.IDE0069.severity = none \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeHitObjectTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeHitObjectTestScene.cs index 2f5135405..a37514d47 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeHitObjectTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeHitObjectTestScene.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Skinning { /// - /// A test scene for a karaoke hitobject. + /// A test scene for a karaoke hitObject. /// public abstract class KaraokeHitObjectTestScene : KaraokeSkinnableTestScene { diff --git a/osu.Game.props b/osu.Game.props deleted file mode 100644 index ef03ef58c..000000000 --- a/osu.Game.props +++ /dev/null @@ -1,21 +0,0 @@ - - - - 7.2 - - - - osu.licenseheader - - - - - - - ppy Pty Ltd - Copyright (c) 2019 ppy Pty Ltd - - NU1701 - - \ No newline at end of file From 145fe3b6787b3bd59527852eba0eefa53fc64f94 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 11 Apr 2020 14:06:02 +0900 Subject: [PATCH 2/5] Add code rules and import into project --- CodeAnalysis/BannedSymbols.txt | 6 ++++ CodeAnalysis/osu.ruleset | 58 ++++++++++++++++++++++++++++++++++ Directory.Build.props | 32 +++++++++++++++++++ global.json | 10 ++++++ osu.Game.Rulesets.Karaoke.sln | 10 ++++++ 5 files changed, 116 insertions(+) create mode 100644 CodeAnalysis/BannedSymbols.txt create mode 100644 CodeAnalysis/osu.ruleset create mode 100644 Directory.Build.props create mode 100644 global.json diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt new file mode 100644 index 000000000..a92191a43 --- /dev/null +++ b/CodeAnalysis/BannedSymbols.txt @@ -0,0 +1,6 @@ +M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. +M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. +M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. +M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead. +T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. +M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. diff --git a/CodeAnalysis/osu.ruleset b/CodeAnalysis/osu.ruleset new file mode 100644 index 000000000..d497365f8 --- /dev/null +++ b/CodeAnalysis/osu.ruleset @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..bfd4f89f3 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,32 @@ + + + + 8.0 + true + + + + osu.licenseheader + + + + + + + + + + + + $(MSBuildThisFileDirectory)CodeAnalysis\osu.ruleset + + + true + $(NoWarn);CS1591 + + + + $(NoWarn);NU1701 + + \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 000000000..6c793a3f1 --- /dev/null +++ b/global.json @@ -0,0 +1,10 @@ +{ + "sdk": { + "allowPrerelease": false, + "rollForward": "minor", + "version": "3.1.100" + }, + "msbuild-sdks": { + "Microsoft.Build.Traversal": "2.0.34" + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke.sln b/osu.Game.Rulesets.Karaoke.sln index a367231e2..3942d2ef2 100644 --- a/osu.Game.Rulesets.Karaoke.sln +++ b/osu.Game.Rulesets.Karaoke.sln @@ -7,6 +7,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Karaoke", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Karaoke.Tests", "osu.Game.Rulesets.Karaoke.Tests\osu.Game.Rulesets.Karaoke.Tests.csproj", "{B4577C85-CB83-462A-BCE3-22FFEB16311D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10DF8F12-50FD-45D8-8A38-17BA764BF54D}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + Directory.Build.props = Directory.Build.props + global.json = global.json + CodeAnalysis\osu.ruleset = CodeAnalysis\osu.ruleset + osu.Game.Rulesets.Karaoke.sln.DotSettings = osu.Game.Rulesets.Karaoke.sln.DotSettings + osu.TestProject.props = osu.TestProject.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 76fc35ef2c0af19a1622481f3bf31f372f4859cf Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 11 Apr 2020 14:17:28 +0900 Subject: [PATCH 3/5] Apply ruleset into project. --- CodeAnalysis/osu.ruleset | 2 +- .../osu.Game.Rulesets.Karaoke.Tests.csproj | 1 - osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 5 +---- osu.TestProject.props | 7 ++++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CodeAnalysis/osu.ruleset b/CodeAnalysis/osu.ruleset index d497365f8..dd27d4b8d 100644 --- a/CodeAnalysis/osu.ruleset +++ b/CodeAnalysis/osu.ruleset @@ -1,5 +1,5 @@  - + diff --git a/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj b/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj index 7873f6303..c29813931 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj +++ b/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj @@ -3,7 +3,6 @@ osu.Game.Rulesets.Karaoke.Tests.VisualTestRunner - diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 71a89f8cc..a93f30242 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -1,14 +1,11 @@  netstandard2.1 - osu.Game.Rulesets.Sample + osu.Game.Rulesets.Karaoke Library AnyCPU osu.Game.Rulesets.Karaoke - - - diff --git a/osu.TestProject.props b/osu.TestProject.props index 2418b7953..5fc192a9f 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -1,10 +1,11 @@ - osu.Game.Tests.VisualTestRunner - - + + + VisualTestRunner.cs + false From 37d9e8b76a8cfc6e844a8ed59360e666a2a5534a Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 11 Apr 2020 14:21:29 +0900 Subject: [PATCH 4/5] Add license header --- osu.licenseheader | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 osu.licenseheader diff --git a/osu.licenseheader b/osu.licenseheader new file mode 100644 index 000000000..cd32351bf --- /dev/null +++ b/osu.licenseheader @@ -0,0 +1,9 @@ +extensions: .cs +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +extensions: .xml .config .xsd + \ No newline at end of file From 43e2808ab915e171a57df1e71698fade1cd40172 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 13 Jun 2020 15:14:16 +0900 Subject: [PATCH 5/5] Fix compile error. --- .../Mods/TestSceneKaraokeModDisableNote.cs | 2 +- .../Replays/TestSceneAutoGeneration.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Mods/TestSceneKaraokeModDisableNote.cs b/osu.Game.Rulesets.Karaoke.Tests/Mods/TestSceneKaraokeModDisableNote.cs index 8111e16e1..0b1d8aebd 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Mods/TestSceneKaraokeModDisableNote.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Mods/TestSceneKaraokeModDisableNote.cs @@ -31,7 +31,7 @@ public void TestCheckNoteExistInPlayfield() => CreateModTest(new ModTestData return false; // check has no note in playfield - return lyricPlayfield.AllHitObjects.Any() && notePlayfield.AllHitObjects.Count() == 0; + return lyricPlayfield.AllHitObjects.Any() && !notePlayfield.AllHitObjects.Any(); } }); } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGeneration.cs b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGeneration.cs index 3b78b72b4..f9d99fb1c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGeneration.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGeneration.cs @@ -104,13 +104,13 @@ public void TestNoteStair() private bool checkMatching(ReplayFrame frame, Tone? tone) { if (!(frame is KaraokeReplayFrame karaokeReplayFrame)) - throw new Exception($"{nameof(frame)} is not karaoke replay frame."); + throw new ArgumentException($"{nameof(frame)} is not karaoke replay frame."); if (!karaokeReplayFrame.Sound) return !tone.HasValue; if (tone == null) - throw new Exception($"{nameof(tone)} should not be null in compare."); + throw new ArgumentException($"{nameof(tone)} should not be null in compare."); return karaokeReplayFrame.Scale == tone.Value.Scale + (tone.Value.Half ? 0.5f : 0); }