From ad010baff105408f83bb96fbc30901b30b70095d Mon Sep 17 00:00:00 2001 From: Ed Kolis Date: Sun, 14 Jan 2024 13:27:28 -0500 Subject: [PATCH] Random refactoring 2024 01 14 (#278) * Fix some warnings erlated to nullability * Get rid of obsolete IsNull extension method; use is null operator instead * Fix more warnings and unnecessary usings --- .editorconfig | 121 +----------------- FrEee.Assets/FrEee.Assets.csproj | 3 + FrEee.Tests/Objects/Abilities/AbilityTest.cs | 2 - FrEee.Tests/TestUtilities.cs | 2 - FrEee.Tests/Utility/DataTest.cs | 10 +- .../Extensions/EnumerableExtensionsTest.cs | 1 - FrEee.Tests/Utility/Extensions/ParserTest.cs | 2 +- FrEee.Tests/Utility/MathXTest.cs | 2 +- FrEee.Tests/Utility/PrngTest.cs | 2 +- FrEee.Tests/Utility/SerializerTest.cs | 4 +- FrEee.Tests/Utility/VectorTest.cs | 2 +- .../Controls/AsteroidFieldReport.cs | 3 +- FrEee.WinForms/Controls/BattleView.cs | 3 +- FrEee.WinForms/Controls/ComponentReport.cs | 2 +- FrEee.WinForms/Controls/DesignReport.cs | 2 +- FrEee.WinForms/Controls/FacilityReport.cs | 2 +- FrEee.WinForms/Controls/FleetReport.cs | 2 +- FrEee.WinForms/Controls/GalaxyView.cs | 6 +- FrEee.WinForms/Controls/GamePanel.cs | 9 +- FrEee.WinForms/Controls/GameProgressBar.cs | 2 +- FrEee.WinForms/Controls/MountReport.cs | 2 +- FrEee.WinForms/Controls/PlanetReport.cs | 2 +- FrEee.WinForms/Controls/ResourceDisplay.cs | 2 +- .../Controls/ResourceQuantityDisplay.cs | 2 +- FrEee.WinForms/Controls/SpaceVehicleReport.cs | 9 +- FrEee.WinForms/Controls/StarReport.cs | 1 - FrEee.WinForms/Controls/StormReport.cs | 1 - FrEee.WinForms/Controls/WarpPointReport.cs | 1 - .../DataGridView/DataGridViewProgressCell.cs | 2 +- .../DataGridView/GridColumnConfig.cs | 2 +- FrEee.WinForms/Forms/BattleResultsForm.cs | 4 +- FrEee.WinForms/Forms/CommandsForm.cs | 10 -- FrEee.WinForms/Forms/ConstructionQueueForm.cs | 2 +- .../Forms/ConstructionQueueListForm.cs | 2 +- FrEee.WinForms/Forms/DebugForm.cs | 1 - FrEee.WinForms/Forms/DesignListForm.cs | 2 +- FrEee.WinForms/Forms/DiplomacyForm.cs | 2 +- FrEee.WinForms/Forms/EditorForm.cs | 2 +- FrEee.WinForms/Forms/EmpireListForm.cs | 2 +- FrEee.WinForms/Forms/EmpireSetupForm.cs | 2 +- FrEee.WinForms/Forms/FleetTransferForm.cs | 2 +- FrEee.WinForms/Forms/GameForm.cs | 13 +- FrEee.WinForms/Forms/GameOverForm.cs | 2 +- FrEee.WinForms/Forms/GameSetupForm.cs | 2 +- FrEee.WinForms/Forms/HostConsoleForm.cs | 8 +- FrEee.WinForms/Forms/HullPickerForm.cs | 2 +- FrEee.WinForms/Forms/MainGameForm.cs | 2 +- FrEee.WinForms/Forms/MainMenuForm.cs | 2 +- FrEee.WinForms/Forms/MinistersForm.cs | 10 +- FrEee.WinForms/Forms/ModPickerForm.cs | 2 +- FrEee.WinForms/Forms/MountPickerForm.cs | 1 - FrEee.WinForms/Forms/PlanetListForm.cs | 2 +- FrEee.WinForms/Forms/RecycleForm.cs | 9 +- FrEee.WinForms/Forms/ResearchForm.cs | 3 +- FrEee.WinForms/Forms/ScoresForm.cs | 3 +- FrEee.WinForms/Forms/ShipListForm.cs | 2 +- FrEee.WinForms/Forms/StatusForm.cs | 2 +- FrEee.WinForms/Forms/VehicleDesignForm.cs | 2 +- FrEee.WinForms/GamePropertyGrid.cs | 2 +- .../GalaxyViewModes/ConstructionMode.cs | 2 +- .../GalaxyViewModes/ResearchIntelMode.cs | 2 +- .../Objects/GalaxyViewModes/ResourcesMode.cs | 2 +- .../Objects/GalaxyViewModes/SpaceYardMode.cs | 2 +- FrEee.WinForms/Program.cs | 5 +- .../Utility/Extensions/GuiExtensions.cs | 2 +- FrEee.WinForms/Utility/Gui.cs | 6 - FrEee/Enumerations/AbilityTargets.cs | 2 +- FrEee/Enumerations/AbilityValueRule.cs | 3 +- FrEee/Enumerations/AllianceLevel.cs | 3 +- FrEee/Enumerations/AllowedTrades.cs | 3 +- FrEee/Enumerations/EmpirePlacement.cs | 3 +- FrEee/Enumerations/ScoreDisplay.cs | 2 +- FrEee/Enumerations/VehicleTypes.cs | 3 +- FrEee/Enumerations/WeaponTargets.cs | 2 +- FrEee/Enumerations/WeaponTypes.cs | 3 +- FrEee/Extensions/AbilityExtensions.cs | 10 +- FrEee/Extensions/ChecksExtensions.cs | 4 +- FrEee/Extensions/CommonExtensions.cs | 6 +- FrEee/Extensions/ComparisonExtensions.cs | 11 -- FrEee/Extensions/ConversionExtensions.cs | 2 +- FrEee/Extensions/CopyingExtensions.cs | 3 +- FrEee/Extensions/EnumerableExtensions.cs | 6 +- FrEee/Extensions/GameEnumerableExtensions.cs | 4 +- FrEee/Extensions/MathExtensions.cs | 5 +- FrEee/Extensions/Parser.cs | 3 +- FrEee/Interfaces/IConstructable.cs | 3 +- FrEee/Interfaces/IConstructionOrder.cs | 4 +- FrEee/Interfaces/IConstructionTemplate.cs | 3 +- FrEee/Interfaces/IConstructor.cs | 5 - FrEee/Interfaces/IDamageable.cs | 4 +- FrEee/Interfaces/IDesign.cs | 2 +- FrEee/Interfaces/IHull.cs | 2 +- FrEee/Interfaces/IIncomeProducer.cs | 3 +- FrEee/Interfaces/IMineableSpaceObject.cs | 3 +- FrEee/Interfaces/IMobileSpaceObject.cs | 2 +- FrEee/Interfaces/IMovementOrder.cs | 2 +- FrEee/Interfaces/IOwnable.cs | 1 - FrEee/Interfaces/IPlanetOrder.cs | 4 +- FrEee/Interfaces/IRecyclable.cs | 3 +- FrEee/Interfaces/IReference.cs | 14 +- FrEee/Interfaces/ISpaceObject.cs | 4 +- .../IStarSystemPlacementStrategy.cs | 2 +- FrEee/Interfaces/IVehicle.cs | 2 +- FrEee/Modding/ComputedFormula.cs | 16 +-- FrEee/Modding/EventType.cs | 4 +- FrEee/Modding/Field.cs | 1 - FrEee/Modding/Formula.cs | 6 +- .../Interfaces/IStellarObjectLocation.cs | 2 +- FrEee/Modding/LiteralFormula.cs | 8 +- FrEee/Modding/Loaders/ComponentLoader.cs | 2 +- FrEee/Modding/Loaders/EmpireAILoader.cs | 2 +- FrEee/Modding/Loaders/EventLoader.cs | 1 - FrEee/Modding/Loaders/EventTypeLoader.cs | 1 - FrEee/Modding/Loaders/FacilityLoader.cs | 2 +- FrEee/Modding/Loaders/HullLoader.cs | 2 +- FrEee/Modding/Loaders/ModSettingsLoader.cs | 1 - FrEee/Modding/Loaders/MountLoader.cs | 1 - FrEee/Modding/MetaRecord.cs | 2 +- FrEee/Modding/Mod.cs | 2 +- FrEee/Modding/ModReference.cs | 4 +- FrEee/Modding/ObjectFormula.cs | 12 +- FrEee/Modding/Scripts/CSScript.cs | 19 +-- FrEee/Modding/Scripts/PythonScript.cs | 12 +- FrEee/Modding/Scripts/PythonScriptEngine.cs | 10 +- .../CircleRadiusStellarObjectLocation.cs | 2 +- .../CoordStellarObjectLocation.cs | 2 +- .../RingStellarObjectLocation.cs | 2 +- .../SameAsStellarObjectLocation.cs | 2 +- FrEee/Modding/StellarObjectSize.cs | 4 +- .../Templates/AsteroidFieldTemplate.cs | 2 +- FrEee/Modding/Templates/ComponentTemplate.cs | 6 +- FrEee/Modding/Templates/GalaxyTemplate.cs | 2 +- FrEee/Modding/Templates/PlanetTemplate.cs | 2 +- .../Templates/RandomAbilityTemplate.cs | 2 +- FrEee/Modding/Templates/StarSystemTemplate.cs | 2 +- FrEee/Objects/AI/AI.cs | 2 +- FrEee/Objects/AI/CSAI.cs | 7 +- FrEee/Objects/AI/PythonAI.cs | 7 +- FrEee/Objects/Abilities/AbilityRule.cs | 2 +- FrEee/Objects/Civilization/Culture.cs | 2 +- .../Diplomacy/AcceptProposalAction.cs | 2 +- .../Objects/Civilization/Diplomacy/Action.cs | 2 +- .../Civilization/Diplomacy/Clauses/Clause.cs | 2 +- .../Clauses/CooperativeResearchClause.cs | 2 +- .../Diplomacy/Clauses/FreeTradeClause.cs | 2 +- .../Diplomacy/Clauses/TributeClause.cs | 2 +- .../Objects/Civilization/Diplomacy/Message.cs | 2 +- .../Civilization/Diplomacy/Proposal.cs | 2 +- .../Diplomacy/RejectProposalAction.cs | 2 +- FrEee/Objects/Civilization/Empire.cs | 1 - FrEee/Objects/Civilization/PlayerInfo.cs | 5 - .../Civilization/SpaceObjectWaypoint.cs | 2 +- FrEee/Objects/Civilization/Waypoint.cs | 2 +- FrEee/Objects/Combat/Grid/Battle.cs | 4 +- FrEee/Objects/Combat/Grid/BattleEvent.cs | 10 +- .../Combat/Grid/CombatantAppearsEvent.cs | 3 +- .../Combat/Grid/CombatantDestroyedEvent.cs | 3 +- .../Combat/Grid/CombatantDisappearsEvent.cs | 2 +- .../Combat/Grid/CombatantMovesEvent.cs | 3 +- FrEee/Objects/Combat/Grid/Extensions.cs | 1 - FrEee/Objects/Combat/Grid/GroundBattle.cs | 5 +- FrEee/Objects/Combat/Grid/IBattleEvent.cs | 3 +- FrEee/Objects/Combat/Grid/SpaceBattle.cs | 7 +- FrEee/Objects/Combat/IBattle.cs | 3 +- FrEee/Objects/Combat/WeaponDisplayEffect.cs | 2 +- .../Commands/ClearPlayerNoteCommand.cs | 6 +- .../Commands/ClearPrivateNameCommand.cs | 2 +- FrEee/Objects/Commands/Command.cs | 2 +- .../Objects/Commands/DeleteMessageCommand.cs | 2 +- FrEee/Objects/Commands/JoinFleetCommand.cs | 2 +- .../Objects/Commands/MinisterToggleCommand.cs | 2 +- FrEee/Objects/Commands/OrderCommand.cs | 2 +- .../Commands/SetObsoleteFlagCommand.cs | 2 +- .../Objects/Commands/SetPlayerInfoCommand.cs | 2 - .../Objects/Commands/SetPlayerNoteCommand.cs | 2 +- .../Objects/Commands/SetPrivateNameCommand.cs | 2 +- .../Commands/ToggleOrdersOnHoldCommand.cs | 5 - .../Commands/ToggleRepeatOrdersCommand.cs | 5 - FrEee/Objects/Events/Event.cs | 2 +- FrEee/Objects/Events/EventMessage.cs | 5 - FrEee/Objects/Orders/ActivateAbilityOrder.cs | 2 +- FrEee/Objects/Orders/ColonizeOrder.cs | 2 +- FrEee/Objects/Orders/EvadeOrder.cs | 2 +- FrEee/Objects/Orders/PathfindingOrder.cs | 4 +- FrEee/Objects/Orders/PursueOrder.cs | 2 +- .../Orders/RecycleFacilityOrCargoOrder.cs | 2 +- .../Orders/RecycleVehicleInSpaceOrder.cs | 2 +- FrEee/Objects/Orders/SentryOrder.cs | 2 +- FrEee/Objects/Orders/TransferCargoOrder.cs | 2 +- FrEee/Objects/Space/Galaxy.cs | 18 ++- FrEee/Objects/Space/ObjectLocation.cs | 4 +- FrEee/Objects/Space/Sector.cs | 13 +- FrEee/Objects/Space/StarSystem.cs | 4 +- .../Objects/Technology/ComponentReference.cs | 8 +- FrEee/Objects/Technology/FacilityUpgrade.cs | 2 +- FrEee/Objects/Technology/Hull.cs | 4 +- FrEee/Objects/Technology/Mount.cs | 3 +- .../Technology/MountedComponentTemplate.cs | 6 +- ...ntedComponentTemplateContainerPopulator.cs | 7 +- FrEee/Objects/Technology/Technology.cs | 2 +- .../Technology/TechnologyRequirement.cs | 2 +- FrEee/Objects/Vehicles/Base.cs | 4 - FrEee/Objects/Vehicles/Design.cs | 2 +- FrEee/Objects/Vehicles/Fighter.cs | 3 +- FrEee/Objects/Vehicles/MajorSpaceVehicle.cs | 2 - FrEee/Objects/Vehicles/Ship.cs | 3 - FrEee/Objects/Vehicles/Troop.cs | 2 +- FrEee/Objects/Vehicles/WeaponPlatform.cs | 2 +- FrEee/Processes/TurnProcessor.cs | 4 +- FrEee/Serialization/DataScalar.cs | 2 +- FrEee/Serialization/GalaxyReference.cs | 9 +- FrEee/Serialization/IDataObject.cs | 3 +- FrEee/Serialization/JsonContractResolver.cs | 5 +- FrEee/Serialization/JsonSerializer.cs | 4 +- FrEee/Serialization/LegacySerializer.cs | 6 +- FrEee/Serialization/ObjectGraphParser.cs | 2 +- FrEee/Serialization/Serializer.cs | 1 - FrEee/Serialization/SimpleDataObject.cs | 2 +- .../DoubleLiteralFormulaStringifier.cs | 6 - .../Stringifiers/IStringifier.cs | 4 - .../IntLiteralFormulaStringifier.cs | 6 - .../Stringifiers/PointStringifier.cs | 6 +- .../PopulationModifierStringifier.cs | 5 - .../ResourceQuantityStringifier.cs | 7 - .../Stringifiers/SizeStringifier.cs | 6 +- .../StringLiteralFormulaStringifier.cs | 6 - .../Serialization/Stringifiers/Stringifier.cs | 7 +- .../Stringifiers/StringifierLibrary.cs | 6 +- .../ClusteredStarSystemPlacementStrategy.cs | 2 +- .../DiffuseStarSystemPlacementStrategy.cs | 2 +- .../GridStarSystemPlacementStrategy.cs | 2 +- .../RandomStarSystemPlacementStrategy.cs | 2 +- .../SpiralStarSystemPlacementStrategy.cs | 2 +- ...RandomAlignedWarpPointPlacementStrategy.cs | 2 +- .../RandomWarpPointPlacementStrategy.cs | 3 +- FrEee/Utility/DynamicDictionary.cs | 4 +- FrEee/Utility/IPopulator.cs | 7 - FrEee/Utility/IntVector2.cs | 9 +- FrEee/Utility/MathX.cs | 4 - FrEee/Utility/PRNG.cs | 9 +- FrEee/Utility/PopulateAttribute.cs | 4 - FrEee/Utility/Resource.cs | 6 +- FrEee/Utility/ResourceQuantity.cs | 6 +- 243 files changed, 314 insertions(+), 701 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2ebcdee75..a86730e72 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,117 +1,4 @@ -# To learn more about .editorconfig see https://aka.ms/editorconfigdocs -############################### -# Core EditorConfig Options # -############################### -# All files -[*] -indent_style = tab -# Code files -[*.{cs,csx,vb,vbx}] -indent_size = 4 -insert_final_newline = true -charset = utf-8 -############################### -# .NET Coding Conventions # -############################### -[*.{cs,vb}] -# Organize usings -dotnet_sort_system_directives_first = true -# this. preferences -dotnet_style_qualification_for_field = false:silent -dotnet_style_qualification_for_property = false:silent -dotnet_style_qualification_for_method = false:silent -dotnet_style_qualification_for_event = false:silent -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -# Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -dotnet_style_readonly_field = true:suggestion -# Expression-level preferences -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_auto_properties = true:silent -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent -############################### -# Naming Conventions # -############################### -# Style Definitions -dotnet_naming_style.pascal_case_style.capitalization = pascal_case -# Use PascalCase for constant fields -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.applicable_accessibilities = * -dotnet_naming_symbols.constant_fields.required_modifiers = const -############################### -# C# Coding Conventions # -############################### -[*.cs] -# var preferences -csharp_style_var_for_built_in_types = true:silent -csharp_style_var_when_type_is_apparent = true:silent -csharp_style_var_elsewhere = true:silent -# Expression-bodied members -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent -# Pattern matching preferences -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion -# Null-checking preferences -csharp_style_throw_expression = true:suggestion -csharp_style_conditional_delegate_call = true:suggestion -# Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion -# Expression-level preferences -csharp_prefer_braces = true:silent -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_pattern_local_over_anonymous_function = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -############################### -# C# Formatting Rules # -############################### -# New line preferences -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 preferences -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = flush_left -# Space preferences -csharp_space_after_cast = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -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_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -# Wrapping preferences -csharp_preserve_single_line_statements = true -csharp_preserve_single_line_blocks = true +[*.cs] + +# CS0105: Using directive appeared previously in this namespace +dotnet_diagnostic.CS0105.severity = suggestion diff --git a/FrEee.Assets/FrEee.Assets.csproj b/FrEee.Assets/FrEee.Assets.csproj index 9145612ed..f987cd313 100644 --- a/FrEee.Assets/FrEee.Assets.csproj +++ b/FrEee.Assets/FrEee.Assets.csproj @@ -34,6 +34,9 @@ PreserveNewest + + + false diff --git a/FrEee.Tests/Objects/Abilities/AbilityTest.cs b/FrEee.Tests/Objects/Abilities/AbilityTest.cs index 1b843c374..4815e4972 100644 --- a/FrEee.Tests/Objects/Abilities/AbilityTest.cs +++ b/FrEee.Tests/Objects/Abilities/AbilityTest.cs @@ -2,9 +2,7 @@ using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; -using FrEee.Modding; using FrEee.Modding.Templates; using FrEee.Extensions; using NUnit.Framework; diff --git a/FrEee.Tests/TestUtilities.cs b/FrEee.Tests/TestUtilities.cs index a2e7d09f6..b3f578e83 100644 --- a/FrEee.Tests/TestUtilities.cs +++ b/FrEee.Tests/TestUtilities.cs @@ -4,8 +4,6 @@ using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; using FrEee.Modding; -using System; -using System.Reflection; namespace FrEee.Tests; diff --git a/FrEee.Tests/Utility/DataTest.cs b/FrEee.Tests/Utility/DataTest.cs index ba836b726..2d59f221a 100644 --- a/FrEee.Tests/Utility/DataTest.cs +++ b/FrEee.Tests/Utility/DataTest.cs @@ -1,14 +1,8 @@ -using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using NUnit.Framework; -using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Security; -using System.Security.Permissions; -using System.Security.Policy; namespace FrEee.Tests.Utility; diff --git a/FrEee.Tests/Utility/Extensions/EnumerableExtensionsTest.cs b/FrEee.Tests/Utility/Extensions/EnumerableExtensionsTest.cs index e77d7a30b..f8b139e60 100644 --- a/FrEee.Tests/Utility/Extensions/EnumerableExtensionsTest.cs +++ b/FrEee.Tests/Utility/Extensions/EnumerableExtensionsTest.cs @@ -1,6 +1,5 @@ using FrEee.Extensions; using NUnit.Framework; -using System.Collections.Generic; using System.Linq; namespace FrEee.Tests.Utility.Extensions; diff --git a/FrEee.Tests/Utility/Extensions/ParserTest.cs b/FrEee.Tests/Utility/Extensions/ParserTest.cs index 9943781ff..2466ce7db 100644 --- a/FrEee.Tests/Utility/Extensions/ParserTest.cs +++ b/FrEee.Tests/Utility/Extensions/ParserTest.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using NUnit.Framework; using System; diff --git a/FrEee.Tests/Utility/MathXTest.cs b/FrEee.Tests/Utility/MathXTest.cs index 26517a595..4cd7dbcc8 100644 --- a/FrEee.Tests/Utility/MathXTest.cs +++ b/FrEee.Tests/Utility/MathXTest.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using NUnit.Framework; namespace FrEee.Tests.Utility; diff --git a/FrEee.Tests/Utility/PrngTest.cs b/FrEee.Tests/Utility/PrngTest.cs index fdb834826..69fc7a62c 100644 --- a/FrEee.Tests/Utility/PrngTest.cs +++ b/FrEee.Tests/Utility/PrngTest.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using NUnit.Framework; namespace FrEee.Tests.Utility; diff --git a/FrEee.Tests/Utility/SerializerTest.cs b/FrEee.Tests/Utility/SerializerTest.cs index 5fb3201ec..c7aab91d0 100644 --- a/FrEee.Tests/Utility/SerializerTest.cs +++ b/FrEee.Tests/Utility/SerializerTest.cs @@ -4,11 +4,11 @@ using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using NUnit.Framework; using System.Collections.Generic; -using System.IO; using System.Linq; namespace FrEee.Tests.Utility; diff --git a/FrEee.Tests/Utility/VectorTest.cs b/FrEee.Tests/Utility/VectorTest.cs index 2bef17e40..8d302bf81 100644 --- a/FrEee.Tests/Utility/VectorTest.cs +++ b/FrEee.Tests/Utility/VectorTest.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using NUnit.Framework; namespace FrEee.Tests.Utility; diff --git a/FrEee.WinForms/Controls/AsteroidFieldReport.cs b/FrEee.WinForms/Controls/AsteroidFieldReport.cs index 1ac30b4c0..75384df58 100644 --- a/FrEee.WinForms/Controls/AsteroidFieldReport.cs +++ b/FrEee.WinForms/Controls/AsteroidFieldReport.cs @@ -1,8 +1,7 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; -using System; using System.Drawing; using System.Windows.Forms; diff --git a/FrEee.WinForms/Controls/BattleView.cs b/FrEee.WinForms/Controls/BattleView.cs index 7278590bf..c32d5fddf 100644 --- a/FrEee.WinForms/Controls/BattleView.cs +++ b/FrEee.WinForms/Controls/BattleView.cs @@ -3,9 +3,8 @@ using FrEee.Objects.Combat.Grid; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; -using NAudio.MediaFoundation; using System; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee.WinForms/Controls/ComponentReport.cs b/FrEee.WinForms/Controls/ComponentReport.cs index 2da9bcf14..531e57e68 100644 --- a/FrEee.WinForms/Controls/ComponentReport.cs +++ b/FrEee.WinForms/Controls/ComponentReport.cs @@ -1,7 +1,7 @@ using FrEee.Objects.Combat; using FrEee.Objects.Technology; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using System; diff --git a/FrEee.WinForms/Controls/DesignReport.cs b/FrEee.WinForms/Controls/DesignReport.cs index b6b906ab7..dd525b36a 100644 --- a/FrEee.WinForms/Controls/DesignReport.cs +++ b/FrEee.WinForms/Controls/DesignReport.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Technology; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Controls/FacilityReport.cs b/FrEee.WinForms/Controls/FacilityReport.cs index 367b7779f..acd4afc47 100644 --- a/FrEee.WinForms/Controls/FacilityReport.cs +++ b/FrEee.WinForms/Controls/FacilityReport.cs @@ -1,6 +1,6 @@ using FrEee.Objects.Technology; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using System; diff --git a/FrEee.WinForms/Controls/FleetReport.cs b/FrEee.WinForms/Controls/FleetReport.cs index 3c11614ef..79ff5edec 100644 --- a/FrEee.WinForms/Controls/FleetReport.cs +++ b/FrEee.WinForms/Controls/FleetReport.cs @@ -3,7 +3,7 @@ using FrEee.Objects.Commands; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Controls/GalaxyView.cs b/FrEee.WinForms/Controls/GalaxyView.cs index d5fc2bc38..bafd3e9a2 100644 --- a/FrEee.WinForms/Controls/GalaxyView.cs +++ b/FrEee.WinForms/Controls/GalaxyView.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Objects.GalaxyViewModes; using System; @@ -27,7 +27,7 @@ public GalaxyView() /// /// An image to display as the background for this galaxy view. /// - public override Image BackgroundImage + public override Image? BackgroundImage { get { @@ -78,7 +78,7 @@ public int StarSystemDrawSize } } - private Image backgroundImage; + private Image? backgroundImage; private IGalaxyViewMode mode = GalaxyViewModes.All.First(); diff --git a/FrEee.WinForms/Controls/GamePanel.cs b/FrEee.WinForms/Controls/GamePanel.cs index f1e1a89cd..8b124a00e 100644 --- a/FrEee.WinForms/Controls/GamePanel.cs +++ b/FrEee.WinForms/Controls/GamePanel.cs @@ -43,13 +43,10 @@ protected override void OnPaint(PaintEventArgs pe) // http://support.microsoft.com/kb/953934 protected override void OnSizeChanged(EventArgs e) { - if (this.Handle != null) + this.BeginInvoke((MethodInvoker)delegate { - this.BeginInvoke((MethodInvoker)delegate - { - base.OnSizeChanged(e); - }); - } + base.OnSizeChanged(e); + }); } private void GamePanel_SizeChanged(object sender, EventArgs e) diff --git a/FrEee.WinForms/Controls/GameProgressBar.cs b/FrEee.WinForms/Controls/GameProgressBar.cs index 1120eb54c..751ba5496 100644 --- a/FrEee.WinForms/Controls/GameProgressBar.cs +++ b/FrEee.WinForms/Controls/GameProgressBar.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Drawing; diff --git a/FrEee.WinForms/Controls/MountReport.cs b/FrEee.WinForms/Controls/MountReport.cs index 88a9b0890..03368ad35 100644 --- a/FrEee.WinForms/Controls/MountReport.cs +++ b/FrEee.WinForms/Controls/MountReport.cs @@ -1,6 +1,6 @@ using FrEee.Objects.Technology; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Controls/PlanetReport.cs b/FrEee.WinForms/Controls/PlanetReport.cs index c991ce844..d2fae4be5 100644 --- a/FrEee.WinForms/Controls/PlanetReport.cs +++ b/FrEee.WinForms/Controls/PlanetReport.cs @@ -3,7 +3,7 @@ using FrEee.Objects.Commands; using FrEee.Objects.Space; using FrEee.Objects.Technology; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Controls/ResourceDisplay.cs b/FrEee.WinForms/Controls/ResourceDisplay.cs index 7e31fbb2d..6142f3f4a 100644 --- a/FrEee.WinForms/Controls/ResourceDisplay.cs +++ b/FrEee.WinForms/Controls/ResourceDisplay.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.ComponentModel; diff --git a/FrEee.WinForms/Controls/ResourceQuantityDisplay.cs b/FrEee.WinForms/Controls/ResourceQuantityDisplay.cs index 2c01f1670..2260c747d 100644 --- a/FrEee.WinForms/Controls/ResourceQuantityDisplay.cs +++ b/FrEee.WinForms/Controls/ResourceQuantityDisplay.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.WinForms.Interfaces; using System.Windows.Forms; diff --git a/FrEee.WinForms/Controls/SpaceVehicleReport.cs b/FrEee.WinForms/Controls/SpaceVehicleReport.cs index 30812d284..7f5b15e86 100644 --- a/FrEee.WinForms/Controls/SpaceVehicleReport.cs +++ b/FrEee.WinForms/Controls/SpaceVehicleReport.cs @@ -1,10 +1,9 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Commands; -using FrEee.Objects.Space; using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; @@ -375,14 +374,14 @@ public MountedComponentTemplate Template public static bool operator ==(ComponentGroup g1, ComponentGroup g2) { - if (g1.IsNull() && g2.IsNull()) + if (g1 is null && g2 is null) return true; - if (g1.IsNull() || g2.IsNull()) + if (g1 is null || g2 is null) return false; return g1.Template == g2.Template && g1.Hitpoints == g2.Hitpoints; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var x = obj as ComponentGroup; if (x == null) diff --git a/FrEee.WinForms/Controls/StarReport.cs b/FrEee.WinForms/Controls/StarReport.cs index 2a52ad643..07cbf46ac 100644 --- a/FrEee.WinForms/Controls/StarReport.cs +++ b/FrEee.WinForms/Controls/StarReport.cs @@ -1,7 +1,6 @@ using FrEee.Objects.Space; using FrEee.Extensions; using FrEee.WinForms.Interfaces; -using System; using System.Drawing; using System.Windows.Forms; diff --git a/FrEee.WinForms/Controls/StormReport.cs b/FrEee.WinForms/Controls/StormReport.cs index 2bcb984fb..29ac9ffe6 100644 --- a/FrEee.WinForms/Controls/StormReport.cs +++ b/FrEee.WinForms/Controls/StormReport.cs @@ -1,7 +1,6 @@ using FrEee.Objects.Space; using FrEee.Extensions; using FrEee.WinForms.Interfaces; -using System; using System.Drawing; using System.Windows.Forms; diff --git a/FrEee.WinForms/Controls/WarpPointReport.cs b/FrEee.WinForms/Controls/WarpPointReport.cs index d44d4b092..4dae8d29f 100644 --- a/FrEee.WinForms/Controls/WarpPointReport.cs +++ b/FrEee.WinForms/Controls/WarpPointReport.cs @@ -1,7 +1,6 @@ using FrEee.Objects.Space; using FrEee.Extensions; using FrEee.WinForms.Interfaces; -using System; using System.Drawing; using System.Windows.Forms; diff --git a/FrEee.WinForms/DataGridView/DataGridViewProgressCell.cs b/FrEee.WinForms/DataGridView/DataGridViewProgressCell.cs index 941524a79..73b43c228 100644 --- a/FrEee.WinForms/DataGridView/DataGridViewProgressCell.cs +++ b/FrEee.WinForms/DataGridView/DataGridViewProgressCell.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Drawing; diff --git a/FrEee.WinForms/DataGridView/GridColumnConfig.cs b/FrEee.WinForms/DataGridView/GridColumnConfig.cs index da361948a..983cd3fa0 100644 --- a/FrEee.WinForms/DataGridView/GridColumnConfig.cs +++ b/FrEee.WinForms/DataGridView/GridColumnConfig.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System; using System.Drawing; using System.Windows.Forms; diff --git a/FrEee.WinForms/Forms/BattleResultsForm.cs b/FrEee.WinForms/Forms/BattleResultsForm.cs index 5a5d81fc4..21d3e33f3 100644 --- a/FrEee.WinForms/Forms/BattleResultsForm.cs +++ b/FrEee.WinForms/Forms/BattleResultsForm.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Combat; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.DataGridView; using FrEee.WinForms.Interfaces; @@ -160,7 +160,7 @@ private class CombatantInfo public string HullName { get; set; } public int HullSize { get; set; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var ci = obj as CombatantInfo; if (ci == null) diff --git a/FrEee.WinForms/Forms/CommandsForm.cs b/FrEee.WinForms/Forms/CommandsForm.cs index 9164b7552..0a11f68c4 100644 --- a/FrEee.WinForms/Forms/CommandsForm.cs +++ b/FrEee.WinForms/Forms/CommandsForm.cs @@ -1,18 +1,8 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Objects.Combat; -using FrEee.Objects.LogMessages; -using FrEee.Objects.Space; -using FrEee.Objects.Technology; -using FrEee.Modding.Templates; -using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; -using System.Collections.Generic; -using System.Data; using System.Drawing; -using System.Linq; -using System.Windows.Forms; namespace FrEee.WinForms.Forms; diff --git a/FrEee.WinForms/Forms/ConstructionQueueForm.cs b/FrEee.WinForms/Forms/ConstructionQueueForm.cs index a30b613b5..617feb3e9 100644 --- a/FrEee.WinForms/Forms/ConstructionQueueForm.cs +++ b/FrEee.WinForms/Forms/ConstructionQueueForm.cs @@ -5,7 +5,7 @@ using FrEee.Objects.Space; using FrEee.Objects.Technology; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Controls; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Forms/ConstructionQueueListForm.cs b/FrEee.WinForms/Forms/ConstructionQueueListForm.cs index 60856cc31..e31937d34 100644 --- a/FrEee.WinForms/Forms/ConstructionQueueListForm.cs +++ b/FrEee.WinForms/Forms/ConstructionQueueListForm.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/DebugForm.cs b/FrEee.WinForms/Forms/DebugForm.cs index db58cf59a..37c419288 100644 --- a/FrEee.WinForms/Forms/DebugForm.cs +++ b/FrEee.WinForms/Forms/DebugForm.cs @@ -3,7 +3,6 @@ using FrEee.Modding; using System; using System.Drawing; -using System.Windows.Forms; namespace FrEee.WinForms.Forms; diff --git a/FrEee.WinForms/Forms/DesignListForm.cs b/FrEee.WinForms/Forms/DesignListForm.cs index a6bd7022f..1bc076080 100644 --- a/FrEee.WinForms/Forms/DesignListForm.cs +++ b/FrEee.WinForms/Forms/DesignListForm.cs @@ -4,7 +4,7 @@ using FrEee.Objects.Commands; using FrEee.Objects.Space; using FrEee.Objects.Technology; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/DiplomacyForm.cs b/FrEee.WinForms/Forms/DiplomacyForm.cs index fd404e4da..c2d67c6bd 100644 --- a/FrEee.WinForms/Forms/DiplomacyForm.cs +++ b/FrEee.WinForms/Forms/DiplomacyForm.cs @@ -8,7 +8,7 @@ using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/EditorForm.cs b/FrEee.WinForms/Forms/EditorForm.cs index f1cfa8011..353626d45 100644 --- a/FrEee.WinForms/Forms/EditorForm.cs +++ b/FrEee.WinForms/Forms/EditorForm.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using FrEee.WinForms.Interfaces; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Forms/EmpireListForm.cs b/FrEee.WinForms/Forms/EmpireListForm.cs index 8ce338728..fcfa93c83 100644 --- a/FrEee.WinForms/Forms/EmpireListForm.cs +++ b/FrEee.WinForms/Forms/EmpireListForm.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Commands; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/EmpireSetupForm.cs b/FrEee.WinForms/Forms/EmpireSetupForm.cs index cbf4befad..5c1ab6d8b 100644 --- a/FrEee.WinForms/Forms/EmpireSetupForm.cs +++ b/FrEee.WinForms/Forms/EmpireSetupForm.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Space; using FrEee.Setup; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/FleetTransferForm.cs b/FrEee.WinForms/Forms/FleetTransferForm.cs index 23056ea9e..fd1ce7112 100644 --- a/FrEee.WinForms/Forms/FleetTransferForm.cs +++ b/FrEee.WinForms/Forms/FleetTransferForm.cs @@ -3,7 +3,7 @@ using FrEee.Objects.Commands; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Controls; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/Forms/GameForm.cs b/FrEee.WinForms/Forms/GameForm.cs index 4d4196490..6e6b058f8 100644 --- a/FrEee.WinForms/Forms/GameForm.cs +++ b/FrEee.WinForms/Forms/GameForm.cs @@ -1,17 +1,6 @@ -using FrEee.Interfaces; -using FrEee.Objects.Abilities; -using FrEee.Objects.Civilization; -using FrEee.Objects.Commands; -using FrEee.Objects.Orders; -using FrEee.Objects.Space; -using FrEee.Extensions; -using FrEee.WinForms.Objects; -using FrEee.WinForms.Utility.Extensions; +using FrEee.WinForms.Objects; using System; -using System.Collections.Generic; -using System.Data; using System.Diagnostics; -using System.Linq; using System.Windows.Forms; namespace FrEee.WinForms.Forms; diff --git a/FrEee.WinForms/Forms/GameOverForm.cs b/FrEee.WinForms/Forms/GameOverForm.cs index a6af489f6..4534fc7aa 100644 --- a/FrEee.WinForms/Forms/GameOverForm.cs +++ b/FrEee.WinForms/Forms/GameOverForm.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.WinForms.Objects; using System; using System.IO; diff --git a/FrEee.WinForms/Forms/GameSetupForm.cs b/FrEee.WinForms/Forms/GameSetupForm.cs index e78e971f5..c78313696 100644 --- a/FrEee.WinForms/Forms/GameSetupForm.cs +++ b/FrEee.WinForms/Forms/GameSetupForm.cs @@ -7,7 +7,7 @@ using FrEee.Setup.WarpPointPlacementStrategies; using FrEee.Modding; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/HostConsoleForm.cs b/FrEee.WinForms/Forms/HostConsoleForm.cs index f7ba9f8e3..967e96aea 100644 --- a/FrEee.WinForms/Forms/HostConsoleForm.cs +++ b/FrEee.WinForms/Forms/HostConsoleForm.cs @@ -1,19 +1,15 @@ -using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Processes; -using FrEee.Modding; -using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.WinForms.Utility.Extensions; using System; using System.Data; using System.Drawing; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using System.Windows.Forms; diff --git a/FrEee.WinForms/Forms/HullPickerForm.cs b/FrEee.WinForms/Forms/HullPickerForm.cs index b465e72f5..0942ef1c6 100644 --- a/FrEee.WinForms/Forms/HullPickerForm.cs +++ b/FrEee.WinForms/Forms/HullPickerForm.cs @@ -1,7 +1,7 @@ using FrEee.Enumerations; using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/MainGameForm.cs b/FrEee.WinForms/Forms/MainGameForm.cs index 9a0afad4b..3187a6f5d 100644 --- a/FrEee.WinForms/Forms/MainGameForm.cs +++ b/FrEee.WinForms/Forms/MainGameForm.cs @@ -8,7 +8,7 @@ using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; using FrEee.Processes; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Controls; using FrEee.WinForms.Interfaces; diff --git a/FrEee.WinForms/Forms/MainMenuForm.cs b/FrEee.WinForms/Forms/MainMenuForm.cs index c9da7cbdc..e3f8ebcd3 100644 --- a/FrEee.WinForms/Forms/MainMenuForm.cs +++ b/FrEee.WinForms/Forms/MainMenuForm.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Vehicles; using FrEee.Setup; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Objects; using FrEee.WinForms.Utility; diff --git a/FrEee.WinForms/Forms/MinistersForm.cs b/FrEee.WinForms/Forms/MinistersForm.cs index 6f7a9fd07..c67c935ed 100644 --- a/FrEee.WinForms/Forms/MinistersForm.cs +++ b/FrEee.WinForms/Forms/MinistersForm.cs @@ -1,17 +1,11 @@ -using FrEee.Interfaces; -using FrEee.Objects.Civilization; +using FrEee.Objects.Civilization; using FrEee.Objects.Commands; -using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; -using FrEee.WinForms.Utility.Extensions; +using FrEee.Utility; using System; using System.Collections.Generic; using System.Data; -using System.Diagnostics; using System.Drawing; using System.Linq; -using System.Windows.Forms; namespace FrEee.WinForms.Forms; diff --git a/FrEee.WinForms/Forms/ModPickerForm.cs b/FrEee.WinForms/Forms/ModPickerForm.cs index 314c29e81..da44beb91 100644 --- a/FrEee.WinForms/Forms/ModPickerForm.cs +++ b/FrEee.WinForms/Forms/ModPickerForm.cs @@ -1,6 +1,6 @@ using FrEee.Modding; using FrEee.Modding.Loaders; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/MountPickerForm.cs b/FrEee.WinForms/Forms/MountPickerForm.cs index 0158fcbde..241badbc3 100644 --- a/FrEee.WinForms/Forms/MountPickerForm.cs +++ b/FrEee.WinForms/Forms/MountPickerForm.cs @@ -1,5 +1,4 @@ using FrEee.Interfaces; -using FrEee.Objects.Civilization; using FrEee.Objects.Technology; using FrEee.Modding; using FrEee.Extensions; diff --git a/FrEee.WinForms/Forms/PlanetListForm.cs b/FrEee.WinForms/Forms/PlanetListForm.cs index 33700bb88..cee18b54e 100644 --- a/FrEee.WinForms/Forms/PlanetListForm.cs +++ b/FrEee.WinForms/Forms/PlanetListForm.cs @@ -3,7 +3,7 @@ using FrEee.Objects.Orders; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.DataGridView; using FrEee.WinForms.Objects; diff --git a/FrEee.WinForms/Forms/RecycleForm.cs b/FrEee.WinForms/Forms/RecycleForm.cs index 63ba16b88..f7970e789 100644 --- a/FrEee.WinForms/Forms/RecycleForm.cs +++ b/FrEee.WinForms/Forms/RecycleForm.cs @@ -70,7 +70,14 @@ private IEnumerable SelectedVehiclesInSpace { get { - return treeVehicles.GetAllNodes().Where(n => n.Tag is SpaceVehicle && n.Checked).Select(n => n.Tag as SpaceVehicle).Where(v => !(v is IUnit && ((IUnit)v).Container != null)); + return treeVehicles.GetAllNodes() + .Where(n => + n.Tag is SpaceVehicle && n.Checked) + .Select(n => + n.Tag as SpaceVehicle) + .Where(v => + !(v is IUnit && ((IUnit)v).Container != null)) + .ExceptNull(); } } diff --git a/FrEee.WinForms/Forms/ResearchForm.cs b/FrEee.WinForms/Forms/ResearchForm.cs index 9f13d8ab7..a8cbee05b 100644 --- a/FrEee.WinForms/Forms/ResearchForm.cs +++ b/FrEee.WinForms/Forms/ResearchForm.cs @@ -1,10 +1,9 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Commands; -using FrEee.Objects.Space; using FrEee.Objects.Technology; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Utility.Extensions; using System; diff --git a/FrEee.WinForms/Forms/ScoresForm.cs b/FrEee.WinForms/Forms/ScoresForm.cs index 4f12598a0..6b35e53d9 100644 --- a/FrEee.WinForms/Forms/ScoresForm.cs +++ b/FrEee.WinForms/Forms/ScoresForm.cs @@ -1,5 +1,4 @@ -using FrEee.Objects.Civilization; -using FrEee.Objects.Space; +using FrEee.Objects.Space; using FrEee.Extensions; using FrEee.WinForms.DataGridView; using System; diff --git a/FrEee.WinForms/Forms/ShipListForm.cs b/FrEee.WinForms/Forms/ShipListForm.cs index 348840b0e..b10370262 100644 --- a/FrEee.WinForms/Forms/ShipListForm.cs +++ b/FrEee.WinForms/Forms/ShipListForm.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.DataGridView; using FrEee.WinForms.Objects; diff --git a/FrEee.WinForms/Forms/StatusForm.cs b/FrEee.WinForms/Forms/StatusForm.cs index 3eb019bd3..a005346e7 100644 --- a/FrEee.WinForms/Forms/StatusForm.cs +++ b/FrEee.WinForms/Forms/StatusForm.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Threading; diff --git a/FrEee.WinForms/Forms/VehicleDesignForm.cs b/FrEee.WinForms/Forms/VehicleDesignForm.cs index d8a7df73c..8fcbdb201 100644 --- a/FrEee.WinForms/Forms/VehicleDesignForm.cs +++ b/FrEee.WinForms/Forms/VehicleDesignForm.cs @@ -4,7 +4,7 @@ using FrEee.Objects.Technology; using FrEee.Modding; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Controls; using FrEee.WinForms.Utility.Extensions; diff --git a/FrEee.WinForms/GamePropertyGrid.cs b/FrEee.WinForms/GamePropertyGrid.cs index 0dd9de8b1..d64834704 100644 --- a/FrEee.WinForms/GamePropertyGrid.cs +++ b/FrEee.WinForms/GamePropertyGrid.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Space; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using FrEee.WinForms.Controls; using FrEee.WinForms.Interfaces; diff --git a/FrEee.WinForms/Objects/GalaxyViewModes/ConstructionMode.cs b/FrEee.WinForms/Objects/GalaxyViewModes/ConstructionMode.cs index 932505564..34a0f0381 100644 --- a/FrEee.WinForms/Objects/GalaxyViewModes/ConstructionMode.cs +++ b/FrEee.WinForms/Objects/GalaxyViewModes/ConstructionMode.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Drawing; using System.Linq; diff --git a/FrEee.WinForms/Objects/GalaxyViewModes/ResearchIntelMode.cs b/FrEee.WinForms/Objects/GalaxyViewModes/ResearchIntelMode.cs index 885fbffa5..95b7c4e4d 100644 --- a/FrEee.WinForms/Objects/GalaxyViewModes/ResearchIntelMode.cs +++ b/FrEee.WinForms/Objects/GalaxyViewModes/ResearchIntelMode.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Drawing; using System.Linq; diff --git a/FrEee.WinForms/Objects/GalaxyViewModes/ResourcesMode.cs b/FrEee.WinForms/Objects/GalaxyViewModes/ResourcesMode.cs index 45abaf205..e330a2744 100644 --- a/FrEee.WinForms/Objects/GalaxyViewModes/ResourcesMode.cs +++ b/FrEee.WinForms/Objects/GalaxyViewModes/ResourcesMode.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Drawing; using System.Linq; diff --git a/FrEee.WinForms/Objects/GalaxyViewModes/SpaceYardMode.cs b/FrEee.WinForms/Objects/GalaxyViewModes/SpaceYardMode.cs index 1bf7c8378..338a34886 100644 --- a/FrEee.WinForms/Objects/GalaxyViewModes/SpaceYardMode.cs +++ b/FrEee.WinForms/Objects/GalaxyViewModes/SpaceYardMode.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Drawing; using System.Linq; diff --git a/FrEee.WinForms/Program.cs b/FrEee.WinForms/Program.cs index 7dbc68bb3..bd725f69f 100644 --- a/FrEee.WinForms/Program.cs +++ b/FrEee.WinForms/Program.cs @@ -1,11 +1,8 @@ -using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Processes; -using FrEee.Modding; -using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using FrEee.WinForms.Forms; using FrEee.WinForms.Utility; diff --git a/FrEee.WinForms/Utility/Extensions/GuiExtensions.cs b/FrEee.WinForms/Utility/Extensions/GuiExtensions.cs index 88621f365..aee10ede0 100644 --- a/FrEee.WinForms/Utility/Extensions/GuiExtensions.cs +++ b/FrEee.WinForms/Utility/Extensions/GuiExtensions.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.WinForms.Forms; using System; using System.Collections.Generic; diff --git a/FrEee.WinForms/Utility/Gui.cs b/FrEee.WinForms/Utility/Gui.cs index 8734f5cd9..ceefe92b9 100644 --- a/FrEee.WinForms/Utility/Gui.cs +++ b/FrEee.WinForms/Utility/Gui.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using FrEee.WinForms.Forms; using FrEee.WinForms.Objects; -using Microsoft.Scripting.Utils; namespace FrEee.WinForms.Utility; diff --git a/FrEee/Enumerations/AbilityTargets.cs b/FrEee/Enumerations/AbilityTargets.cs index 92a4c6879..aa2c055c1 100644 --- a/FrEee/Enumerations/AbilityTargets.cs +++ b/FrEee/Enumerations/AbilityTargets.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; namespace FrEee.Enumerations; diff --git a/FrEee/Enumerations/AbilityValueRule.cs b/FrEee/Enumerations/AbilityValueRule.cs index 874fcbdaf..c0c56e6d6 100644 --- a/FrEee/Enumerations/AbilityValueRule.cs +++ b/FrEee/Enumerations/AbilityValueRule.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; /// diff --git a/FrEee/Enumerations/AllianceLevel.cs b/FrEee/Enumerations/AllianceLevel.cs index 8567af755..16b004ea2 100644 --- a/FrEee/Enumerations/AllianceLevel.cs +++ b/FrEee/Enumerations/AllianceLevel.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; /// diff --git a/FrEee/Enumerations/AllowedTrades.cs b/FrEee/Enumerations/AllowedTrades.cs index 23dd8edff..e9d408eca 100644 --- a/FrEee/Enumerations/AllowedTrades.cs +++ b/FrEee/Enumerations/AllowedTrades.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; public enum AllowedTrades diff --git a/FrEee/Enumerations/EmpirePlacement.cs b/FrEee/Enumerations/EmpirePlacement.cs index bf62aa623..19fa07c5e 100644 --- a/FrEee/Enumerations/EmpirePlacement.cs +++ b/FrEee/Enumerations/EmpirePlacement.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; public enum EmpirePlacement diff --git a/FrEee/Enumerations/ScoreDisplay.cs b/FrEee/Enumerations/ScoreDisplay.cs index 33d541fdd..0cfecb35c 100644 --- a/FrEee/Enumerations/ScoreDisplay.cs +++ b/FrEee/Enumerations/ScoreDisplay.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; namespace FrEee.Enumerations; diff --git a/FrEee/Enumerations/VehicleTypes.cs b/FrEee/Enumerations/VehicleTypes.cs index b8f62eeff..00616d15c 100644 --- a/FrEee/Enumerations/VehicleTypes.cs +++ b/FrEee/Enumerations/VehicleTypes.cs @@ -1,6 +1,5 @@ using System; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; /// diff --git a/FrEee/Enumerations/WeaponTargets.cs b/FrEee/Enumerations/WeaponTargets.cs index 23f3ebc00..ab25770e9 100644 --- a/FrEee/Enumerations/WeaponTargets.cs +++ b/FrEee/Enumerations/WeaponTargets.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; namespace FrEee.Enumerations; diff --git a/FrEee/Enumerations/WeaponTypes.cs b/FrEee/Enumerations/WeaponTypes.cs index 9f3ba576d..b9b6a6b1f 100644 --- a/FrEee/Enumerations/WeaponTypes.cs +++ b/FrEee/Enumerations/WeaponTypes.cs @@ -1,6 +1,5 @@ using System; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Enumerations; /// diff --git a/FrEee/Extensions/AbilityExtensions.cs b/FrEee/Extensions/AbilityExtensions.cs index 3378321ac..be1e3b0e1 100644 --- a/FrEee/Extensions/AbilityExtensions.cs +++ b/FrEee/Extensions/AbilityExtensions.cs @@ -10,8 +10,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Extensions; @@ -25,15 +23,15 @@ public static class AbilityExtensions /// /// /// - public static IEnumerable Abilities(this IAbilityObject obj, Func sourceFilter = null) + public static IEnumerable Abilities(this IAbilityObject obj, Func? sourceFilter = null) { if (obj == null) return Enumerable.Empty(); - if (sourceFilter == null && Galaxy.Current != null && Galaxy.Current.IsAbilityCacheEnabled) + if (sourceFilter is null && Galaxy.Current is not null && Galaxy.Current.IsAbilityCacheEnabled) { // use the ability cache - if (Galaxy.Current.AbilityCache[obj] == null) + if (Galaxy.Current.AbilityCache[obj] is null) Galaxy.Current.AbilityCache[obj] = obj.UnstackedAbilities(true, sourceFilter).Stack(obj).ToArray(); return Galaxy.Current.AbilityCache[obj]; } @@ -41,7 +39,7 @@ public static IEnumerable Abilities(this IAbilityObject obj, Func AbilityTree(this IAbilityObject obj, Func sourceFilter = null) + public static ILookup AbilityTree(this IAbilityObject obj, Func? sourceFilter = null) { return obj.UnstackedAbilities(true, sourceFilter).StackToTree(obj); } diff --git a/FrEee/Extensions/ChecksExtensions.cs b/FrEee/Extensions/ChecksExtensions.cs index 1b00961df..cb7ee7c13 100644 --- a/FrEee/Extensions/ChecksExtensions.cs +++ b/FrEee/Extensions/ChecksExtensions.cs @@ -12,8 +12,7 @@ using System.Dynamic; using System.Linq; using System.Reflection; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Extensions; public static class ChecksExtensions @@ -289,6 +288,7 @@ public static bool StillExists(this T old, IEnumerable oldItems, IEnumerab /// The key. /// public static bool TestContainsKey(this IDictionary dict, TKey key) + where TKey: notnull { var hash = EqualityComparer.Default.GetHashCode(key); return dict.Any( diff --git a/FrEee/Extensions/CommonExtensions.cs b/FrEee/Extensions/CommonExtensions.cs index 5b2db43e1..8e6d2fa47 100644 --- a/FrEee/Extensions/CommonExtensions.cs +++ b/FrEee/Extensions/CommonExtensions.cs @@ -21,7 +21,7 @@ using FrEee.Objects.Vehicles; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Serialization; namespace FrEee.Extensions; @@ -254,11 +254,11 @@ public static void DealWithMines(this ISpaceObject sobj) /// /// /// - public static T Default(this object value, T def = default(T), bool throwIfWrongType = false) + public static T Default(this object value, T def = default, bool throwIfWrongType = false) { if (throwIfWrongType && !(value is T)) throw new InvalidCastException($"Cannot convert {value} to type {typeof(T)}."); - return value == null || !(value is T) ? def : (T)value; + return value is null or not T ? def : (T)value; } /// diff --git a/FrEee/Extensions/ComparisonExtensions.cs b/FrEee/Extensions/ComparisonExtensions.cs index 2879fa8a3..c0ceb4867 100644 --- a/FrEee/Extensions/ComparisonExtensions.cs +++ b/FrEee/Extensions/ComparisonExtensions.cs @@ -73,17 +73,6 @@ public static bool IsInt(this IFormula f) return f.Value.ToString().IsInt(); } - /// - /// Tests if an object is null. - /// Useful for writing == operators that don't infinitely recurse. - /// - /// - /// - public static bool IsNull(this object o) - { - return o == null; - } - /// /// Gets a description of an object's timestamp as a memory age. /// diff --git a/FrEee/Extensions/ConversionExtensions.cs b/FrEee/Extensions/ConversionExtensions.cs index b47f159c7..315fa8c05 100644 --- a/FrEee/Extensions/ConversionExtensions.cs +++ b/FrEee/Extensions/ConversionExtensions.cs @@ -1,5 +1,5 @@ using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Drawing; using System.Globalization; diff --git a/FrEee/Extensions/CopyingExtensions.cs b/FrEee/Extensions/CopyingExtensions.cs index 86f2d060f..c2808b70a 100644 --- a/FrEee/Extensions/CopyingExtensions.cs +++ b/FrEee/Extensions/CopyingExtensions.cs @@ -1,11 +1,10 @@ using FrEee.Interfaces; using FrEee.Objects.Technology; using FrEee.Serialization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Reflection; diff --git a/FrEee/Extensions/EnumerableExtensions.cs b/FrEee/Extensions/EnumerableExtensions.cs index 49bd2511d..0c20133c6 100644 --- a/FrEee/Extensions/EnumerableExtensions.cs +++ b/FrEee/Extensions/EnumerableExtensions.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Extensions; /// @@ -21,6 +20,9 @@ public static IEnumerable ExceptSingle(this IEnumerable src, T badguy) return src.Except(new T[] { badguy }); } + public static IEnumerable ExceptNull(this IEnumerable src) + => src.Where(q => q is not null).Cast(); + /// /// Flattens groupings into a single sequence. /// diff --git a/FrEee/Extensions/GameEnumerableExtensions.cs b/FrEee/Extensions/GameEnumerableExtensions.cs index 6b8e06c67..1d0ec1199 100644 --- a/FrEee/Extensions/GameEnumerableExtensions.cs +++ b/FrEee/Extensions/GameEnumerableExtensions.cs @@ -6,10 +6,8 @@ using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Extensions; /// diff --git a/FrEee/Extensions/MathExtensions.cs b/FrEee/Extensions/MathExtensions.cs index a5fde50e0..6d35d2c83 100644 --- a/FrEee/Extensions/MathExtensions.cs +++ b/FrEee/Extensions/MathExtensions.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Extensions; public static class MathExtensions diff --git a/FrEee/Extensions/Parser.cs b/FrEee/Extensions/Parser.cs index fc24135a7..0f85493f4 100644 --- a/FrEee/Extensions/Parser.cs +++ b/FrEee/Extensions/Parser.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Extensions; /// diff --git a/FrEee/Interfaces/IConstructable.cs b/FrEee/Interfaces/IConstructable.cs index 7283f8a94..8f1085e2e 100644 --- a/FrEee/Interfaces/IConstructable.cs +++ b/FrEee/Interfaces/IConstructable.cs @@ -1,6 +1,5 @@ using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IConstructionOrder.cs b/FrEee/Interfaces/IConstructionOrder.cs index d82d27faa..72316aea4 100644 --- a/FrEee/Interfaces/IConstructionOrder.cs +++ b/FrEee/Interfaces/IConstructionOrder.cs @@ -1,6 +1,4 @@ -using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; public interface IConstructionOrder : IOrder, INamed diff --git a/FrEee/Interfaces/IConstructionTemplate.cs b/FrEee/Interfaces/IConstructionTemplate.cs index a50646fce..29e2d15ec 100644 --- a/FrEee/Interfaces/IConstructionTemplate.cs +++ b/FrEee/Interfaces/IConstructionTemplate.cs @@ -1,6 +1,5 @@ using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IConstructor.cs b/FrEee/Interfaces/IConstructor.cs index 2180ae9ee..a9012e80e 100644 --- a/FrEee/Interfaces/IConstructor.cs +++ b/FrEee/Interfaces/IConstructor.cs @@ -1,9 +1,4 @@ using FrEee.Objects.Civilization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IDamageable.cs b/FrEee/Interfaces/IDamageable.cs index 6605e721b..939324706 100644 --- a/FrEee/Interfaces/IDamageable.cs +++ b/FrEee/Interfaces/IDamageable.cs @@ -1,7 +1,5 @@ using FrEee.Objects.Combat; -using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IDesign.cs b/FrEee/Interfaces/IDesign.cs index 7be4e4eb7..be27324c9 100644 --- a/FrEee/Interfaces/IDesign.cs +++ b/FrEee/Interfaces/IDesign.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Technology; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IHull.cs b/FrEee/Interfaces/IHull.cs index d6dbfd6bc..17eac9413 100644 --- a/FrEee/Interfaces/IHull.cs +++ b/FrEee/Interfaces/IHull.cs @@ -1,7 +1,7 @@ using FrEee.Enumerations; using FrEee.Objects.Technology; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee/Interfaces/IIncomeProducer.cs b/FrEee/Interfaces/IIncomeProducer.cs index e8d1db01f..9be15c819 100644 --- a/FrEee/Interfaces/IIncomeProducer.cs +++ b/FrEee/Interfaces/IIncomeProducer.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IMineableSpaceObject.cs b/FrEee/Interfaces/IMineableSpaceObject.cs index 67e49b95b..ffe8f07d7 100644 --- a/FrEee/Interfaces/IMineableSpaceObject.cs +++ b/FrEee/Interfaces/IMineableSpaceObject.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IMobileSpaceObject.cs b/FrEee/Interfaces/IMobileSpaceObject.cs index 85b3d9787..88db6b853 100644 --- a/FrEee/Interfaces/IMobileSpaceObject.cs +++ b/FrEee/Interfaces/IMobileSpaceObject.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IMovementOrder.cs b/FrEee/Interfaces/IMovementOrder.cs index d24b7e5c3..570b01bc8 100644 --- a/FrEee/Interfaces/IMovementOrder.cs +++ b/FrEee/Interfaces/IMovementOrder.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IOwnable.cs b/FrEee/Interfaces/IOwnable.cs index a4e4b4fef..6505b4604 100644 --- a/FrEee/Interfaces/IOwnable.cs +++ b/FrEee/Interfaces/IOwnable.cs @@ -1,6 +1,5 @@ using FrEee.Objects.Civilization; using FrEee.Serialization; -using FrEee.Utility; using FrEee.Serialization; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IPlanetOrder.cs b/FrEee/Interfaces/IPlanetOrder.cs index 2289264d3..00ee638a0 100644 --- a/FrEee/Interfaces/IPlanetOrder.cs +++ b/FrEee/Interfaces/IPlanetOrder.cs @@ -1,6 +1,4 @@ -using FrEee.Objects.Space; - -namespace FrEee.Interfaces; +namespace FrEee.Interfaces; /// /// An order that can be issued to a planet. diff --git a/FrEee/Interfaces/IRecyclable.cs b/FrEee/Interfaces/IRecyclable.cs index 55f6a6166..b6b3769b6 100644 --- a/FrEee/Interfaces/IRecyclable.cs +++ b/FrEee/Interfaces/IRecyclable.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; /// diff --git a/FrEee/Interfaces/IReference.cs b/FrEee/Interfaces/IReference.cs index 56eaeabd5..958fcdcb7 100644 --- a/FrEee/Interfaces/IReference.cs +++ b/FrEee/Interfaces/IReference.cs @@ -29,25 +29,13 @@ public interface IReference : IReference [Serializable] public class ReferenceException : Exception, ISerializable { - public ReferenceException(string message, TID id = default(TID)) + public ReferenceException(string message, TID id = default) : base(message) { ID = id; } - protected ReferenceException(SerializationInfo info, StreamingContext ctx) - : base(info, ctx) - { - ID = (TID)info.GetValue("ID", typeof(TID)); - } - public TID ID { get; private set; } public Type Type { get { return typeof(TValue); } } - - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue("ID", ID); - } } \ No newline at end of file diff --git a/FrEee/Interfaces/ISpaceObject.cs b/FrEee/Interfaces/ISpaceObject.cs index 65cae2fdd..7ba56fb50 100644 --- a/FrEee/Interfaces/ISpaceObject.cs +++ b/FrEee/Interfaces/ISpaceObject.cs @@ -1,6 +1,4 @@ -using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Interfaces; public interface ISpaceObject : IOwnableAbilityObject, IPictorial, IReferrable, IFoggable, INamed, ILocated diff --git a/FrEee/Interfaces/IStarSystemPlacementStrategy.cs b/FrEee/Interfaces/IStarSystemPlacementStrategy.cs index 1351368fd..745ed371f 100644 --- a/FrEee/Interfaces/IStarSystemPlacementStrategy.cs +++ b/FrEee/Interfaces/IStarSystemPlacementStrategy.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Drawing; namespace FrEee.Interfaces; diff --git a/FrEee/Interfaces/IVehicle.cs b/FrEee/Interfaces/IVehicle.cs index 8757c8859..e2e1b4c58 100644 --- a/FrEee/Interfaces/IVehicle.cs +++ b/FrEee/Interfaces/IVehicle.cs @@ -1,6 +1,6 @@ using FrEee.Objects.Technology; using FrEee.Serialization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Interfaces; diff --git a/FrEee/Modding/ComputedFormula.cs b/FrEee/Modding/ComputedFormula.cs index 693572d21..806bdf655 100644 --- a/FrEee/Modding/ComputedFormula.cs +++ b/FrEee/Modding/ComputedFormula.cs @@ -3,9 +3,9 @@ using System.Globalization; using System.Linq; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; +using FrEee.Utility; using FrEee.Serialization; +using FrEee.Extensions; namespace FrEee.Modding; @@ -85,9 +85,9 @@ public static implicit operator T(ComputedFormula f) public static bool operator ==(ComputedFormula f1, ComputedFormula f2) { - if (f1.IsNull() && f2.IsNull()) + if (f1 is null && f2 is null) return true; - if (f1.IsNull() || f2.IsNull()) + if (f1 is null || f2 is null) return false; return f1.Value.SafeEquals(f2.Value); } @@ -101,17 +101,17 @@ public Formula Compile() return new LiteralFormula(Value.ToStringInvariant()); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var x = obj as ComputedFormula; - if (x == null) + if (x is null) return false; return Equals(x); } - public bool Equals(ComputedFormula other) + public bool Equals(ComputedFormula? other) { - return IsDynamic == other.IsDynamic && Text == other.Text && Context == other.Context; + return other is not null && IsDynamic == other.IsDynamic && Text == other.Text && Context == other.Context; } public override T Evaluate(object host, IDictionary variables = null) diff --git a/FrEee/Modding/EventType.cs b/FrEee/Modding/EventType.cs index 755c037cc..c8b23223c 100644 --- a/FrEee/Modding/EventType.cs +++ b/FrEee/Modding/EventType.cs @@ -1,6 +1,4 @@ -using FrEee.Enumerations; -using FrEee.Interfaces; -using FrEee.Objects.Events; +using FrEee.Interfaces; using FrEee.Modding.Interfaces; using FrEee.Serialization; using System.Collections.Generic; diff --git a/FrEee/Modding/Field.cs b/FrEee/Modding/Field.cs index 889d5953b..e3f39dd49 100644 --- a/FrEee/Modding/Field.cs +++ b/FrEee/Modding/Field.cs @@ -1,5 +1,4 @@ using FrEee.Interfaces; -using FrEee.Extensions; using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Formula.cs b/FrEee/Modding/Formula.cs index d0e369f43..681cab3ed 100644 --- a/FrEee/Modding/Formula.cs +++ b/FrEee/Modding/Formula.cs @@ -174,19 +174,19 @@ public static implicit operator T(Formula f) return new ComputedFormula(string.Format("({0}) + str({1})", f1.Text, f2.Text), f1.Context, false); } - public int CompareTo(object obj) + public int CompareTo(object? obj) { if (obj is IFormula) return Value.CompareTo(((IFormula)obj).Value); return Value.CompareTo(obj); } - public int CompareTo(T other) + public int CompareTo(T? other) { return Value.CompareTo(other); } - public int CompareTo(Formula other) + public int CompareTo(Formula? other) { return Value.CompareTo(other.Value); } diff --git a/FrEee/Modding/Interfaces/IStellarObjectLocation.cs b/FrEee/Modding/Interfaces/IStellarObjectLocation.cs index 24d6d4cb0..63fc325b7 100644 --- a/FrEee/Modding/Interfaces/IStellarObjectLocation.cs +++ b/FrEee/Modding/Interfaces/IStellarObjectLocation.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Drawing; namespace FrEee.Modding.Interfaces; diff --git a/FrEee/Modding/LiteralFormula.cs b/FrEee/Modding/LiteralFormula.cs index 45acb6145..e3546fb8d 100644 --- a/FrEee/Modding/LiteralFormula.cs +++ b/FrEee/Modding/LiteralFormula.cs @@ -82,14 +82,14 @@ public static implicit operator T(LiteralFormula f) public static bool operator ==(LiteralFormula f1, Formula f2) { - if (f1.IsNull() && f2.IsNull()) + if (f1 is null && f2 is null) return true; - if (f1.IsNull() || f2.IsNull()) + if (f1 is null || f2 is null) return false; return f1.Value.SafeEquals(f2.Value); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var x = obj as LiteralFormula; if (ReferenceEquals(x, null)) @@ -97,7 +97,7 @@ public override bool Equals(object obj) return Equals(x); } - public bool Equals(LiteralFormula other) + public bool Equals(LiteralFormula? other) { return Text == other.Text; } diff --git a/FrEee/Modding/Loaders/ComponentLoader.cs b/FrEee/Modding/Loaders/ComponentLoader.cs index f1d57a9a4..748b80abb 100644 --- a/FrEee/Modding/Loaders/ComponentLoader.cs +++ b/FrEee/Modding/Loaders/ComponentLoader.cs @@ -4,7 +4,7 @@ using FrEee.Modding.Enumerations; using FrEee.Modding.Interfaces; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Modding/Loaders/EmpireAILoader.cs b/FrEee/Modding/Loaders/EmpireAILoader.cs index a4ede3982..caeb39986 100644 --- a/FrEee/Modding/Loaders/EmpireAILoader.cs +++ b/FrEee/Modding/Loaders/EmpireAILoader.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; using System.IO; using System.Reflection; diff --git a/FrEee/Modding/Loaders/EventLoader.cs b/FrEee/Modding/Loaders/EventLoader.cs index e2b111f4e..abcf84bf4 100644 --- a/FrEee/Modding/Loaders/EventLoader.cs +++ b/FrEee/Modding/Loaders/EventLoader.cs @@ -1,7 +1,6 @@ using FrEee.Enumerations; using FrEee.Objects.Events; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Loaders/EventTypeLoader.cs b/FrEee/Modding/Loaders/EventTypeLoader.cs index d01fb63e9..a75906341 100644 --- a/FrEee/Modding/Loaders/EventTypeLoader.cs +++ b/FrEee/Modding/Loaders/EventTypeLoader.cs @@ -1,7 +1,6 @@ using FrEee.Interfaces; using FrEee.Modding.Interfaces; using FrEee.Serialization; -using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Loaders/FacilityLoader.cs b/FrEee/Modding/Loaders/FacilityLoader.cs index 4a15957ea..75b16c288 100644 --- a/FrEee/Modding/Loaders/FacilityLoader.cs +++ b/FrEee/Modding/Loaders/FacilityLoader.cs @@ -1,7 +1,7 @@ using FrEee.Objects.Technology; using FrEee.Modding.Enumerations; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Loaders/HullLoader.cs b/FrEee/Modding/Loaders/HullLoader.cs index 9a9aef830..2b0db4019 100644 --- a/FrEee/Modding/Loaders/HullLoader.cs +++ b/FrEee/Modding/Loaders/HullLoader.cs @@ -3,7 +3,7 @@ using FrEee.Objects.Vehicles; using FrEee.Modding.Enumerations; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Loaders/ModSettingsLoader.cs b/FrEee/Modding/Loaders/ModSettingsLoader.cs index b122d0bc2..91ea5eaa2 100644 --- a/FrEee/Modding/Loaders/ModSettingsLoader.cs +++ b/FrEee/Modding/Loaders/ModSettingsLoader.cs @@ -1,7 +1,6 @@ using FrEee.Enumerations; using FrEee.Objects.Civilization; using FrEee.Modding.Interfaces; -using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Loaders/MountLoader.cs b/FrEee/Modding/Loaders/MountLoader.cs index fb513b7d8..3ee49c13c 100644 --- a/FrEee/Modding/Loaders/MountLoader.cs +++ b/FrEee/Modding/Loaders/MountLoader.cs @@ -3,7 +3,6 @@ using FrEee.Modding.Enumerations; using FrEee.Modding.Interfaces; using FrEee.Extensions; -using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/MetaRecord.cs b/FrEee/Modding/MetaRecord.cs index 46f1c803b..5a2d54fcc 100644 --- a/FrEee/Modding/MetaRecord.cs +++ b/FrEee/Modding/MetaRecord.cs @@ -25,7 +25,7 @@ public MetaRecord(IEnumerable lines) public string Filename { get; set; } - public IEnumerable Parameters + public new IEnumerable Parameters { get { diff --git a/FrEee/Modding/Mod.cs b/FrEee/Modding/Mod.cs index 2cf53a091..21b031dfe 100644 --- a/FrEee/Modding/Mod.cs +++ b/FrEee/Modding/Mod.cs @@ -12,7 +12,7 @@ using FrEee.Modding.Interfaces; using FrEee.Modding.Loaders; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; namespace FrEee.Modding; diff --git a/FrEee/Modding/ModReference.cs b/FrEee/Modding/ModReference.cs index 6997dca21..8308358e5 100644 --- a/FrEee/Modding/ModReference.cs +++ b/FrEee/Modding/ModReference.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; @@ -114,7 +114,7 @@ public static implicit operator T(ModReference r) return r.Value; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var mref = obj as ModReference; if (mref == null) diff --git a/FrEee/Modding/ObjectFormula.cs b/FrEee/Modding/ObjectFormula.cs index 890873a76..72973130b 100644 --- a/FrEee/Modding/ObjectFormula.cs +++ b/FrEee/Modding/ObjectFormula.cs @@ -1,6 +1,6 @@ using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; +using FrEee.Utility; +using FrEee.Serialization; using System; using System.Collections.Generic; using System.Globalization; @@ -87,7 +87,7 @@ public static implicit operator T(ObjectFormula f) return f.Value; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var x = obj as ObjectFormula; if (x == null) @@ -147,17 +147,17 @@ protected T ComputeValue() return Evaluate(Context, null); } - public int CompareTo(object obj) + public int CompareTo(object? obj) { throw new NotSupportedException(); } - public int CompareTo(T other) + public int CompareTo(T ?other) { throw new NotSupportedException(); } - public int CompareTo(ObjectFormula other) + public int CompareTo(ObjectFormula? other) { throw new NotSupportedException(); } diff --git a/FrEee/Modding/Scripts/CSScript.cs b/FrEee/Modding/Scripts/CSScript.cs index cc77e6d9a..45cfc8385 100644 --- a/FrEee/Modding/Scripts/CSScript.cs +++ b/FrEee/Modding/Scripts/CSScript.cs @@ -1,23 +1,18 @@ -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; +using FrEee.Utility; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Scripting; using Microsoft.CodeAnalysis.Scripting; using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Modding; [Serializable] public class CSScript : IScript - { - public string ModuleName { get; set; } - public string Text { get; set; } + { + public string ModuleName { get; set; } + public string Text { get; set; } /// /// The directory that this script is found in. @@ -82,14 +77,14 @@ public Microsoft.CodeAnalysis.Scripting.ScriptRunner CreateScriptObject public static bool operator ==(CSScript s1, CSScript s2) { - if (s1.IsNull() && s2.IsNull()) + if (s1 is null && s2 is null) return true; - if (s1.IsNull() || s2.IsNull()) + if (s1 is null || s2 is null) return false; return s1.ModuleName == s2.ModuleName && s1.Text == s2.Text;// && s1.ExternalScripts.SafeSequenceEqual(s2.ExternalScripts); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is CSScript) { diff --git a/FrEee/Modding/Scripts/PythonScript.cs b/FrEee/Modding/Scripts/PythonScript.cs index 0c6bce9dc..48bf04696 100644 --- a/FrEee/Modding/Scripts/PythonScript.cs +++ b/FrEee/Modding/Scripts/PythonScript.cs @@ -1,9 +1,8 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; using System.IO; -using System.Linq; namespace FrEee.Modding; @@ -155,18 +154,17 @@ public static PythonScript Load(string path) public static bool operator ==(PythonScript s1, PythonScript s2) { - if (s1.IsNull() && s2.IsNull()) + if (s1 is null && s2 is null) return true; - if (s1.IsNull() || s2.IsNull()) + if (s1 is null || s2 is null) return false; return s1.ModuleName == s2.ModuleName && s1.Text == s2.Text && s1.ExternalScripts.SafeSequenceEqual(s2.ExternalScripts); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { - if (obj is PythonScript) + if (obj is PythonScript s) { - var s = (PythonScript)obj; return s == this; } return false; diff --git a/FrEee/Modding/Scripts/PythonScriptEngine.cs b/FrEee/Modding/Scripts/PythonScriptEngine.cs index cc85b0949..1c11e638a 100644 --- a/FrEee/Modding/Scripts/PythonScriptEngine.cs +++ b/FrEee/Modding/Scripts/PythonScriptEngine.cs @@ -404,12 +404,12 @@ public CompiledCodeWithVariables(CompiledCode code, IDictionary return c1.Equals(c2); } - public bool Equals(CompiledCodeWithVariables other) + public bool Equals(CompiledCodeWithVariables? other) { return Code == other.Code && Variables.Keys.Count == other.Variables.Keys.Count && Variables.All(kvp => kvp.Value.SafeEquals(other.Variables[kvp.Key])); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is CompiledCodeWithVariables c) return this.Equals(c); @@ -442,14 +442,14 @@ public ScriptCode(string moduleName, string code, params PythonScript[] external public static bool operator ==(ScriptCode sc1, ScriptCode sc2) { - if (sc1.IsNull() && sc2.IsNull()) + if (sc1 is null && sc2 is null) return true; - if (sc1.IsNull() || sc2.IsNull()) + if (sc1 is null || sc2 is null) return false; return sc1.ModuleName == sc2.ModuleName && sc1.Code == sc2.Code && sc1.ExternalScripts.SequenceEqual(sc2.ExternalScripts); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj as ScriptCode == this; } diff --git a/FrEee/Modding/StellarObjectLocations/CircleRadiusStellarObjectLocation.cs b/FrEee/Modding/StellarObjectLocations/CircleRadiusStellarObjectLocation.cs index 361f1a4ed..bfb1059ad 100644 --- a/FrEee/Modding/StellarObjectLocations/CircleRadiusStellarObjectLocation.cs +++ b/FrEee/Modding/StellarObjectLocations/CircleRadiusStellarObjectLocation.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Modding/StellarObjectLocations/CoordStellarObjectLocation.cs b/FrEee/Modding/StellarObjectLocations/CoordStellarObjectLocation.cs index b7cf29da7..d5914249d 100644 --- a/FrEee/Modding/StellarObjectLocations/CoordStellarObjectLocation.cs +++ b/FrEee/Modding/StellarObjectLocations/CoordStellarObjectLocation.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Drawing; diff --git a/FrEee/Modding/StellarObjectLocations/RingStellarObjectLocation.cs b/FrEee/Modding/StellarObjectLocations/RingStellarObjectLocation.cs index 35732cf8e..f8fc383fe 100644 --- a/FrEee/Modding/StellarObjectLocations/RingStellarObjectLocation.cs +++ b/FrEee/Modding/StellarObjectLocations/RingStellarObjectLocation.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Modding/StellarObjectLocations/SameAsStellarObjectLocation.cs b/FrEee/Modding/StellarObjectLocations/SameAsStellarObjectLocation.cs index 4f9971733..f5e5678f8 100644 --- a/FrEee/Modding/StellarObjectLocations/SameAsStellarObjectLocation.cs +++ b/FrEee/Modding/StellarObjectLocations/SameAsStellarObjectLocation.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Space; using FrEee.Modding.Interfaces; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Drawing; diff --git a/FrEee/Modding/StellarObjectSize.cs b/FrEee/Modding/StellarObjectSize.cs index 1317ae6e9..8dc1022a0 100644 --- a/FrEee/Modding/StellarObjectSize.cs +++ b/FrEee/Modding/StellarObjectSize.cs @@ -84,7 +84,7 @@ public string ModID /// public IDictionary TemplateParameters { get; set; } - public int CompareTo(object obj) + public int CompareTo(object? obj) { if (obj is StellarSize) return StellarSize.CompareTo(obj); @@ -93,7 +93,7 @@ public int CompareTo(object obj) return StellarSize.CompareTo(obj); } - public int CompareTo(StellarObjectSize obj) + public int CompareTo(StellarObjectSize? obj) { return StellarSize.CompareTo(obj.StellarSize); } diff --git a/FrEee/Modding/Templates/AsteroidFieldTemplate.cs b/FrEee/Modding/Templates/AsteroidFieldTemplate.cs index e16bc3aa9..c6e525fd7 100644 --- a/FrEee/Modding/Templates/AsteroidFieldTemplate.cs +++ b/FrEee/Modding/Templates/AsteroidFieldTemplate.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Modding/Templates/ComponentTemplate.cs b/FrEee/Modding/Templates/ComponentTemplate.cs index 17c967e57..158aa386a 100644 --- a/FrEee/Modding/Templates/ComponentTemplate.cs +++ b/FrEee/Modding/Templates/ComponentTemplate.cs @@ -2,10 +2,10 @@ using FrEee.Interfaces; using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; -using FrEee.Objects.Space; using FrEee.Objects.Technology; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; @@ -318,7 +318,7 @@ public override string ToString() return Name; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj is ComponentTemplate t && t == this; } diff --git a/FrEee/Modding/Templates/GalaxyTemplate.cs b/FrEee/Modding/Templates/GalaxyTemplate.cs index 9537a2951..ea682f18c 100644 --- a/FrEee/Modding/Templates/GalaxyTemplate.cs +++ b/FrEee/Modding/Templates/GalaxyTemplate.cs @@ -6,7 +6,7 @@ using FrEee.Objects.Space; using FrEee.Setup; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; namespace FrEee.Modding.Templates; diff --git a/FrEee/Modding/Templates/PlanetTemplate.cs b/FrEee/Modding/Templates/PlanetTemplate.cs index a26634ad0..11650ec71 100644 --- a/FrEee/Modding/Templates/PlanetTemplate.cs +++ b/FrEee/Modding/Templates/PlanetTemplate.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Space; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Modding/Templates/RandomAbilityTemplate.cs b/FrEee/Modding/Templates/RandomAbilityTemplate.cs index 74b0b9b82..11147241d 100644 --- a/FrEee/Modding/Templates/RandomAbilityTemplate.cs +++ b/FrEee/Modding/Templates/RandomAbilityTemplate.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Abilities; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Modding/Templates/StarSystemTemplate.cs b/FrEee/Modding/Templates/StarSystemTemplate.cs index c97eb60de..f79678983 100644 --- a/FrEee/Modding/Templates/StarSystemTemplate.cs +++ b/FrEee/Modding/Templates/StarSystemTemplate.cs @@ -4,7 +4,7 @@ using FrEee.Objects.Space; using FrEee.Modding.Interfaces; using FrEee.Modding.StellarObjectLocations; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee/Objects/AI/AI.cs b/FrEee/Objects/AI/AI.cs index fdf2b3ce0..afc5f3b48 100644 --- a/FrEee/Objects/AI/AI.cs +++ b/FrEee/Objects/AI/AI.cs @@ -1,6 +1,6 @@ using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/AI/CSAI.cs b/FrEee/Objects/AI/CSAI.cs index 5814dd4b1..b13e7bb63 100644 --- a/FrEee/Objects/AI/CSAI.cs +++ b/FrEee/Objects/AI/CSAI.cs @@ -1,17 +1,14 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using Microsoft.CodeAnalysis.Scripting; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.AI; - [Serializable] +[Serializable] public class CSAI : AI where TDomain : Empire where TContext : Galaxy { public CSAI(string name, CSScript script, SafeDictionary> ministerNames) diff --git a/FrEee/Objects/AI/PythonAI.cs b/FrEee/Objects/AI/PythonAI.cs index 3a404d6c6..f4b8b73e2 100644 --- a/FrEee/Objects/AI/PythonAI.cs +++ b/FrEee/Objects/AI/PythonAI.cs @@ -1,14 +1,11 @@ using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.AI; - [Serializable] +[Serializable] public class PythonAI : AI { public PythonAI(string name, PythonScript script, SafeDictionary> ministerNames) : base(name, script, ministerNames) diff --git a/FrEee/Objects/Abilities/AbilityRule.cs b/FrEee/Objects/Abilities/AbilityRule.cs index fbbb83c71..ecfb53948 100644 --- a/FrEee/Objects/Abilities/AbilityRule.cs +++ b/FrEee/Objects/Abilities/AbilityRule.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Civilization/Culture.cs b/FrEee/Objects/Civilization/Culture.cs index fd24ec48d..c59676a5b 100644 --- a/FrEee/Objects/Civilization/Culture.cs +++ b/FrEee/Objects/Civilization/Culture.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Civilization/Diplomacy/AcceptProposalAction.cs b/FrEee/Objects/Civilization/Diplomacy/AcceptProposalAction.cs index f192680e7..3883daf7b 100644 --- a/FrEee/Objects/Civilization/Diplomacy/AcceptProposalAction.cs +++ b/FrEee/Objects/Civilization/Diplomacy/AcceptProposalAction.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; diff --git a/FrEee/Objects/Civilization/Diplomacy/Action.cs b/FrEee/Objects/Civilization/Diplomacy/Action.cs index 80bc2faac..7fdf22e4c 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Action.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Action.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Commands; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; namespace FrEee.Objects.Civilization.Diplomacy; diff --git a/FrEee/Objects/Civilization/Diplomacy/Clauses/Clause.cs b/FrEee/Objects/Civilization/Diplomacy/Clauses/Clause.cs index d2d2bd86d..9078bf2dc 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Clauses/Clause.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Clauses/Clause.cs @@ -1,7 +1,7 @@ using FrEee.Enumerations; using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System.Collections.Generic; namespace FrEee.Objects.Civilization.Diplomacy.Clauses; diff --git a/FrEee/Objects/Civilization/Diplomacy/Clauses/CooperativeResearchClause.cs b/FrEee/Objects/Civilization/Diplomacy/Clauses/CooperativeResearchClause.cs index bfe653b2e..e26666eb3 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Clauses/CooperativeResearchClause.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Clauses/CooperativeResearchClause.cs @@ -1,5 +1,5 @@ using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Linq; using Tech = FrEee.Objects.Technology.Technology; diff --git a/FrEee/Objects/Civilization/Diplomacy/Clauses/FreeTradeClause.cs b/FrEee/Objects/Civilization/Diplomacy/Clauses/FreeTradeClause.cs index 6dbe5afdc..62397945c 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Clauses/FreeTradeClause.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Clauses/FreeTradeClause.cs @@ -1,5 +1,5 @@ using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; diff --git a/FrEee/Objects/Civilization/Diplomacy/Clauses/TributeClause.cs b/FrEee/Objects/Civilization/Diplomacy/Clauses/TributeClause.cs index f717d2d1c..6502c1a8e 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Clauses/TributeClause.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Clauses/TributeClause.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Linq; diff --git a/FrEee/Objects/Civilization/Diplomacy/Message.cs b/FrEee/Objects/Civilization/Diplomacy/Message.cs index a715db0d8..ca44c3347 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Message.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Message.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Commands; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee/Objects/Civilization/Diplomacy/Proposal.cs b/FrEee/Objects/Civilization/Diplomacy/Proposal.cs index aeebd25e5..a1dce3b14 100644 --- a/FrEee/Objects/Civilization/Diplomacy/Proposal.cs +++ b/FrEee/Objects/Civilization/Diplomacy/Proposal.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Commands; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Civilization/Diplomacy/RejectProposalAction.cs b/FrEee/Objects/Civilization/Diplomacy/RejectProposalAction.cs index c6f817d24..40ee4d53b 100644 --- a/FrEee/Objects/Civilization/Diplomacy/RejectProposalAction.cs +++ b/FrEee/Objects/Civilization/Diplomacy/RejectProposalAction.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; diff --git a/FrEee/Objects/Civilization/Empire.cs b/FrEee/Objects/Civilization/Empire.cs index 4f02128b8..86bf4f804 100644 --- a/FrEee/Objects/Civilization/Empire.cs +++ b/FrEee/Objects/Civilization/Empire.cs @@ -10,7 +10,6 @@ using FrEee.Objects.Vehicles; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Modding.Loaders; using FrEee.Utility; using FrEee.Serialization; using FrEee.Extensions; diff --git a/FrEee/Objects/Civilization/PlayerInfo.cs b/FrEee/Objects/Civilization/PlayerInfo.cs index 7cc36cf18..3c82de402 100644 --- a/FrEee/Objects/Civilization/PlayerInfo.cs +++ b/FrEee/Objects/Civilization/PlayerInfo.cs @@ -1,10 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Civilization; diff --git a/FrEee/Objects/Civilization/SpaceObjectWaypoint.cs b/FrEee/Objects/Civilization/SpaceObjectWaypoint.cs index 89a183380..b1ecef8c1 100644 --- a/FrEee/Objects/Civilization/SpaceObjectWaypoint.cs +++ b/FrEee/Objects/Civilization/SpaceObjectWaypoint.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; diff --git a/FrEee/Objects/Civilization/Waypoint.cs b/FrEee/Objects/Civilization/Waypoint.cs index b558ca101..410721114 100644 --- a/FrEee/Objects/Civilization/Waypoint.cs +++ b/FrEee/Objects/Civilization/Waypoint.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Orders; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Combat/Grid/Battle.cs b/FrEee/Objects/Combat/Grid/Battle.cs index 1d5a8b030..35bab9343 100644 --- a/FrEee/Objects/Combat/Grid/Battle.cs +++ b/FrEee/Objects/Combat/Grid/Battle.cs @@ -6,14 +6,14 @@ using FrEee.Objects.Technology; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using static System.Math; -using FrEee.Serialization; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/Grid/BattleEvent.cs b/FrEee/Objects/Combat/Grid/BattleEvent.cs index 9320ba796..28a3c89d1 100644 --- a/FrEee/Objects/Combat/Grid/BattleEvent.cs +++ b/FrEee/Objects/Combat/Grid/BattleEvent.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Interfaces; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/Grid/CombatantAppearsEvent.cs b/FrEee/Objects/Combat/Grid/CombatantAppearsEvent.cs index d5ccc7202..7e8661a25 100644 --- a/FrEee/Objects/Combat/Grid/CombatantAppearsEvent.cs +++ b/FrEee/Objects/Combat/Grid/CombatantAppearsEvent.cs @@ -1,6 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; -using System; +using FrEee.Utility; using System.Linq; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/Grid/CombatantDestroyedEvent.cs b/FrEee/Objects/Combat/Grid/CombatantDestroyedEvent.cs index 3a9128e60..aed43a8ef 100644 --- a/FrEee/Objects/Combat/Grid/CombatantDestroyedEvent.cs +++ b/FrEee/Objects/Combat/Grid/CombatantDestroyedEvent.cs @@ -1,6 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Objects.Combat.Grid; public class CombatantDestroyedEvent : BattleEvent diff --git a/FrEee/Objects/Combat/Grid/CombatantDisappearsEvent.cs b/FrEee/Objects/Combat/Grid/CombatantDisappearsEvent.cs index 6bd039515..98224c888 100644 --- a/FrEee/Objects/Combat/Grid/CombatantDisappearsEvent.cs +++ b/FrEee/Objects/Combat/Grid/CombatantDisappearsEvent.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/Grid/CombatantMovesEvent.cs b/FrEee/Objects/Combat/Grid/CombatantMovesEvent.cs index b7eea53f7..561c25f15 100644 --- a/FrEee/Objects/Combat/Grid/CombatantMovesEvent.cs +++ b/FrEee/Objects/Combat/Grid/CombatantMovesEvent.cs @@ -1,6 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Objects.Combat.Grid; public class CombatantMovesEvent : BattleEvent diff --git a/FrEee/Objects/Combat/Grid/Extensions.cs b/FrEee/Objects/Combat/Grid/Extensions.cs index 04455f0bf..3d4f38b16 100644 --- a/FrEee/Objects/Combat/Grid/Extensions.cs +++ b/FrEee/Objects/Combat/Grid/Extensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; public static class Extensions diff --git a/FrEee/Objects/Combat/Grid/GroundBattle.cs b/FrEee/Objects/Combat/Grid/GroundBattle.cs index 9f13c7ea2..f3ff6f9db 100644 --- a/FrEee/Objects/Combat/Grid/GroundBattle.cs +++ b/FrEee/Objects/Combat/Grid/GroundBattle.cs @@ -1,16 +1,13 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Objects.LogMessages; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/Grid/IBattleEvent.cs b/FrEee/Objects/Combat/Grid/IBattleEvent.cs index 29ebdfbc4..87876ffbc 100644 --- a/FrEee/Objects/Combat/Grid/IBattleEvent.cs +++ b/FrEee/Objects/Combat/Grid/IBattleEvent.cs @@ -1,6 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Objects.Combat.Grid; public interface IBattleEvent diff --git a/FrEee/Objects/Combat/Grid/SpaceBattle.cs b/FrEee/Objects/Combat/Grid/SpaceBattle.cs index 2a6e9a35f..5663eab91 100644 --- a/FrEee/Objects/Combat/Grid/SpaceBattle.cs +++ b/FrEee/Objects/Combat/Grid/SpaceBattle.cs @@ -1,16 +1,11 @@ using FrEee.Interfaces; -using FrEee.Objects.LogMessages; using FrEee.Objects.Space; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; -using Microsoft.Scripting.Runtime; using System; using System.Collections.Generic; using System.Linq; -using System.Security.Principal; -using System.Text; -using System.Threading.Tasks; using static System.Math; namespace FrEee.Objects.Combat.Grid; diff --git a/FrEee/Objects/Combat/IBattle.cs b/FrEee/Objects/Combat/IBattle.cs index 1ca26dca0..67f2f97b0 100644 --- a/FrEee/Objects/Combat/IBattle.cs +++ b/FrEee/Objects/Combat/IBattle.cs @@ -1,8 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.LogMessages; -using FrEee.Objects.Technology; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Objects.Combat; diff --git a/FrEee/Objects/Combat/WeaponDisplayEffect.cs b/FrEee/Objects/Combat/WeaponDisplayEffect.cs index 62e49c018..82749c97e 100644 --- a/FrEee/Objects/Combat/WeaponDisplayEffect.cs +++ b/FrEee/Objects/Combat/WeaponDisplayEffect.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Commands/ClearPlayerNoteCommand.cs b/FrEee/Objects/Commands/ClearPlayerNoteCommand.cs index ce210f20e..7697685f9 100644 --- a/FrEee/Objects/Commands/ClearPlayerNoteCommand.cs +++ b/FrEee/Objects/Commands/ClearPlayerNoteCommand.cs @@ -1,7 +1,5 @@ -using FrEee.Interfaces; -using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; -using FrEee.Extensions; +using FrEee.Objects.Civilization; +using FrEee.Utility; using System.Collections.Generic; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/ClearPrivateNameCommand.cs b/FrEee/Objects/Commands/ClearPrivateNameCommand.cs index 07e89a4ff..76447e114 100644 --- a/FrEee/Objects/Commands/ClearPrivateNameCommand.cs +++ b/FrEee/Objects/Commands/ClearPrivateNameCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/Command.cs b/FrEee/Objects/Commands/Command.cs index 2b54f176b..7f9b76c14 100644 --- a/FrEee/Objects/Commands/Command.cs +++ b/FrEee/Objects/Commands/Command.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Commands/DeleteMessageCommand.cs b/FrEee/Objects/Commands/DeleteMessageCommand.cs index ab1419ad1..6759fbdd2 100644 --- a/FrEee/Objects/Commands/DeleteMessageCommand.cs +++ b/FrEee/Objects/Commands/DeleteMessageCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/JoinFleetCommand.cs b/FrEee/Objects/Commands/JoinFleetCommand.cs index 80f05098d..4ef6bd322 100644 --- a/FrEee/Objects/Commands/JoinFleetCommand.cs +++ b/FrEee/Objects/Commands/JoinFleetCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; diff --git a/FrEee/Objects/Commands/MinisterToggleCommand.cs b/FrEee/Objects/Commands/MinisterToggleCommand.cs index 1a2a9b256..4a495866b 100644 --- a/FrEee/Objects/Commands/MinisterToggleCommand.cs +++ b/FrEee/Objects/Commands/MinisterToggleCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/OrderCommand.cs b/FrEee/Objects/Commands/OrderCommand.cs index 8628fa5d6..8515c7239 100644 --- a/FrEee/Objects/Commands/OrderCommand.cs +++ b/FrEee/Objects/Commands/OrderCommand.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Commands/SetObsoleteFlagCommand.cs b/FrEee/Objects/Commands/SetObsoleteFlagCommand.cs index 024a70c1b..25a8919de 100644 --- a/FrEee/Objects/Commands/SetObsoleteFlagCommand.cs +++ b/FrEee/Objects/Commands/SetObsoleteFlagCommand.cs @@ -1,5 +1,5 @@ using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; diff --git a/FrEee/Objects/Commands/SetPlayerInfoCommand.cs b/FrEee/Objects/Commands/SetPlayerInfoCommand.cs index 76556b4ad..6d4dcb5d3 100644 --- a/FrEee/Objects/Commands/SetPlayerInfoCommand.cs +++ b/FrEee/Objects/Commands/SetPlayerInfoCommand.cs @@ -1,7 +1,5 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Objects.LogMessages; -using FrEee.Objects.Space; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Commands/SetPlayerNoteCommand.cs b/FrEee/Objects/Commands/SetPlayerNoteCommand.cs index 0ca4f732f..d7c08e9d1 100644 --- a/FrEee/Objects/Commands/SetPlayerNoteCommand.cs +++ b/FrEee/Objects/Commands/SetPlayerNoteCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/SetPrivateNameCommand.cs b/FrEee/Objects/Commands/SetPrivateNameCommand.cs index 9e1194836..f7149a3ab 100644 --- a/FrEee/Objects/Commands/SetPrivateNameCommand.cs +++ b/FrEee/Objects/Commands/SetPrivateNameCommand.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/ToggleOrdersOnHoldCommand.cs b/FrEee/Objects/Commands/ToggleOrdersOnHoldCommand.cs index 6d8cbabcd..f0167cc29 100644 --- a/FrEee/Objects/Commands/ToggleOrdersOnHoldCommand.cs +++ b/FrEee/Objects/Commands/ToggleOrdersOnHoldCommand.cs @@ -1,9 +1,4 @@ using FrEee.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Commands/ToggleRepeatOrdersCommand.cs b/FrEee/Objects/Commands/ToggleRepeatOrdersCommand.cs index d613a475f..4c1eccfe6 100644 --- a/FrEee/Objects/Commands/ToggleRepeatOrdersCommand.cs +++ b/FrEee/Objects/Commands/ToggleRepeatOrdersCommand.cs @@ -1,9 +1,4 @@ using FrEee.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Commands; diff --git a/FrEee/Objects/Events/Event.cs b/FrEee/Objects/Events/Event.cs index ed3f2c316..a324a3522 100644 --- a/FrEee/Objects/Events/Event.cs +++ b/FrEee/Objects/Events/Event.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.Space; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee/Objects/Events/EventMessage.cs b/FrEee/Objects/Events/EventMessage.cs index d1521e6c0..6b1f37bf3 100644 --- a/FrEee/Objects/Events/EventMessage.cs +++ b/FrEee/Objects/Events/EventMessage.cs @@ -1,9 +1,4 @@ using FrEee.Modding.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Events; diff --git a/FrEee/Objects/Orders/ActivateAbilityOrder.cs b/FrEee/Objects/Orders/ActivateAbilityOrder.cs index cc4c3906a..04ee2341b 100644 --- a/FrEee/Objects/Orders/ActivateAbilityOrder.cs +++ b/FrEee/Objects/Orders/ActivateAbilityOrder.cs @@ -5,7 +5,7 @@ using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Orders/ColonizeOrder.cs b/FrEee/Objects/Orders/ColonizeOrder.cs index 0919038dc..7035ee81d 100644 --- a/FrEee/Objects/Orders/ColonizeOrder.cs +++ b/FrEee/Objects/Orders/ColonizeOrder.cs @@ -5,7 +5,7 @@ using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Orders/EvadeOrder.cs b/FrEee/Objects/Orders/EvadeOrder.cs index d50a54f9d..1f381af0d 100644 --- a/FrEee/Objects/Orders/EvadeOrder.cs +++ b/FrEee/Objects/Orders/EvadeOrder.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Orders/PathfindingOrder.cs b/FrEee/Objects/Orders/PathfindingOrder.cs index fe1e22726..58ccfef0c 100644 --- a/FrEee/Objects/Orders/PathfindingOrder.cs +++ b/FrEee/Objects/Orders/PathfindingOrder.cs @@ -3,9 +3,9 @@ using FrEee.Objects.Civilization; using FrEee.Objects.LogMessages; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; -using System; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Orders/PursueOrder.cs b/FrEee/Objects/Orders/PursueOrder.cs index 70aad36eb..6ff209905 100644 --- a/FrEee/Objects/Orders/PursueOrder.cs +++ b/FrEee/Objects/Orders/PursueOrder.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Orders/RecycleFacilityOrCargoOrder.cs b/FrEee/Objects/Orders/RecycleFacilityOrCargoOrder.cs index 974ff5487..906025a73 100644 --- a/FrEee/Objects/Orders/RecycleFacilityOrCargoOrder.cs +++ b/FrEee/Objects/Orders/RecycleFacilityOrCargoOrder.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.LogMessages; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Orders/RecycleVehicleInSpaceOrder.cs b/FrEee/Objects/Orders/RecycleVehicleInSpaceOrder.cs index 6577d8a35..759657e03 100644 --- a/FrEee/Objects/Orders/RecycleVehicleInSpaceOrder.cs +++ b/FrEee/Objects/Orders/RecycleVehicleInSpaceOrder.cs @@ -3,7 +3,7 @@ using FrEee.Objects.LogMessages; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Orders/SentryOrder.cs b/FrEee/Objects/Orders/SentryOrder.cs index 6092b4425..c3d5ee98f 100644 --- a/FrEee/Objects/Orders/SentryOrder.cs +++ b/FrEee/Objects/Orders/SentryOrder.cs @@ -4,7 +4,7 @@ using FrEee.Objects.LogMessages; using FrEee.Objects.Space; using FrEee.Objects.Vehicles; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Orders/TransferCargoOrder.cs b/FrEee/Objects/Orders/TransferCargoOrder.cs index 504934a0d..96c86b32c 100644 --- a/FrEee/Objects/Orders/TransferCargoOrder.cs +++ b/FrEee/Objects/Orders/TransferCargoOrder.cs @@ -2,7 +2,7 @@ using FrEee.Objects.Civilization; using FrEee.Objects.LogMessages; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System.Collections.Generic; using System.Linq; diff --git a/FrEee/Objects/Space/Galaxy.cs b/FrEee/Objects/Space/Galaxy.cs index 1b8881af9..ab5e2bc5e 100644 --- a/FrEee/Objects/Space/Galaxy.cs +++ b/FrEee/Objects/Space/Galaxy.cs @@ -8,29 +8,27 @@ using FrEee.Objects.Commands; using FrEee.Objects.Events; using FrEee.Objects.LogMessages; -using FrEee.Objects.Vehicles; -using FrEee.Objects.VictoryConditions; using FrEee.Setup; using FrEee.Setup.WarpPointPlacementStrategies; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using Microsoft.Scripting.Utils; using System; using System.Collections; using System.Collections.Generic; -using System.Configuration; using System.IO; using System.Linq; using System.Reflection; namespace FrEee.Objects.Space; - /// - /// Prevents IDs from being assigned to objects when calling AssignIDs. - /// TODO - move to utility namespace? - /// - public class DoNotAssignIDAttribute : Attribute +/// +/// Prevents IDs from being assigned to objects when calling AssignIDs. +/// TODO - move to utility namespace? +/// +public class DoNotAssignIDAttribute : Attribute { public DoNotAssignIDAttribute(bool recurse = true) { @@ -77,7 +75,7 @@ public Galaxy() /// /// The current galaxy. Shouldn't change except at loading a game or turn processing. /// - public static Galaxy Current { get; set; } + public static Galaxy? Current { get; set; } public AbilityTargets AbilityTarget { diff --git a/FrEee/Objects/Space/ObjectLocation.cs b/FrEee/Objects/Space/ObjectLocation.cs index 19d6ee2d3..fbe3cc6a9 100644 --- a/FrEee/Objects/Space/ObjectLocation.cs +++ b/FrEee/Objects/Space/ObjectLocation.cs @@ -1,4 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Drawing; @@ -41,7 +41,7 @@ public ObjectLocation(T item, Point location) return l1.Item.Equals(l2.Item) && l1.Location.Equals(l2.Location); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return this == obj as ObjectLocation; } diff --git a/FrEee/Objects/Space/Sector.cs b/FrEee/Objects/Space/Sector.cs index 6f4dac238..27936e714 100644 --- a/FrEee/Objects/Space/Sector.cs +++ b/FrEee/Objects/Space/Sector.cs @@ -166,7 +166,7 @@ public IEnumerable SpaceObjects if (Empire.Current == null) result = result.Where(x => !x.IsMemory); - return result.ToArray(); + return result.ExceptNull().ToArray(); } } @@ -182,9 +182,9 @@ public IEnumerable SpaceObjects public static bool operator ==(Sector s1, Sector s2) { - if (s1.IsNull() && s2.IsNull()) + if (s1 is null && s2 is null) return true; - if (s1.IsNull() || s2.IsNull()) + if (s1 is null || s2 is null) return false; return s1.starSystem == s2.starSystem && s1.Coordinates == s2.Coordinates; } @@ -224,11 +224,10 @@ public Visibility CheckVisibility(Empire emp) throw new NotImplementedException(); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { - // TODO - upgrade equals to use "as" operator - if (obj is Sector) - return this == (Sector)obj; + if (obj is Sector s) + return this == s; return false; } diff --git a/FrEee/Objects/Space/StarSystem.cs b/FrEee/Objects/Space/StarSystem.cs index 1a9ad2f0c..702dc5498 100644 --- a/FrEee/Objects/Space/StarSystem.cs +++ b/FrEee/Objects/Space/StarSystem.cs @@ -3,14 +3,14 @@ using System.Drawing; using System.IO; using System.Linq; -using System.Reflection; using FrEee.Enumerations; using FrEee.Interfaces; using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; using FrEee.Modding; using FrEee.Modding.Templates; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Space; diff --git a/FrEee/Objects/Technology/ComponentReference.cs b/FrEee/Objects/Technology/ComponentReference.cs index 43574232e..f4ee4fc99 100644 --- a/FrEee/Objects/Technology/ComponentReference.cs +++ b/FrEee/Objects/Technology/ComponentReference.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using FrEee.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; namespace FrEee.Objects.Technology; diff --git a/FrEee/Objects/Technology/FacilityUpgrade.cs b/FrEee/Objects/Technology/FacilityUpgrade.cs index 9b69b74fd..bcca796ce 100644 --- a/FrEee/Objects/Technology/FacilityUpgrade.cs +++ b/FrEee/Objects/Technology/FacilityUpgrade.cs @@ -90,7 +90,7 @@ public IEnumerable OlderVersions return x.SafeEquals(y); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var fu = obj as FacilityUpgrade; if (fu == null) diff --git a/FrEee/Objects/Technology/Hull.cs b/FrEee/Objects/Technology/Hull.cs index ea7c58ea6..93d470f80 100644 --- a/FrEee/Objects/Technology/Hull.cs +++ b/FrEee/Objects/Technology/Hull.cs @@ -2,10 +2,10 @@ using FrEee.Interfaces; using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; -using FrEee.Objects.Space; using FrEee.Objects.Vehicles; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Technology/Mount.cs b/FrEee/Objects/Technology/Mount.cs index b9215692c..1a9f56087 100644 --- a/FrEee/Objects/Technology/Mount.cs +++ b/FrEee/Objects/Technology/Mount.cs @@ -2,10 +2,9 @@ using FrEee.Interfaces; using FrEee.Objects.Abilities; using FrEee.Objects.Civilization; -using FrEee.Objects.Space; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System.Collections.Generic; using System.Drawing; diff --git a/FrEee/Objects/Technology/MountedComponentTemplate.cs b/FrEee/Objects/Technology/MountedComponentTemplate.cs index 385436150..603b0a186 100644 --- a/FrEee/Objects/Technology/MountedComponentTemplate.cs +++ b/FrEee/Objects/Technology/MountedComponentTemplate.cs @@ -342,14 +342,14 @@ public int WeaponMinRange public static bool operator ==(MountedComponentTemplate t1, MountedComponentTemplate t2) { - if (t1.IsNull() && t2.IsNull()) + if (t1 is null && t2 is null) return true; - if (t1.IsNull() || t2.IsNull()) + if (t1 is null || t2 is null) return false; return t1.Container == t2.Container && t1.ComponentTemplate == t2.ComponentTemplate && t1.mount == t2.mount; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { // TODO - upgrade equals to use "as" operator if (obj is MountedComponentTemplate) diff --git a/FrEee/Objects/Technology/MountedComponentTemplateContainerPopulator.cs b/FrEee/Objects/Technology/MountedComponentTemplateContainerPopulator.cs index c8d9e6a0f..06a2d8a42 100644 --- a/FrEee/Objects/Technology/MountedComponentTemplateContainerPopulator.cs +++ b/FrEee/Objects/Technology/MountedComponentTemplateContainerPopulator.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Objects.Technology; /// diff --git a/FrEee/Objects/Technology/Technology.cs b/FrEee/Objects/Technology/Technology.cs index 5028b3e83..52f90d390 100644 --- a/FrEee/Objects/Technology/Technology.cs +++ b/FrEee/Objects/Technology/Technology.cs @@ -4,7 +4,7 @@ using FrEee.Objects.Space; using FrEee.Modding; using FrEee.Modding.Interfaces; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Technology/TechnologyRequirement.cs b/FrEee/Objects/Technology/TechnologyRequirement.cs index 8259654fe..5f1ce7c54 100644 --- a/FrEee/Objects/Technology/TechnologyRequirement.cs +++ b/FrEee/Objects/Technology/TechnologyRequirement.cs @@ -1,7 +1,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Modding; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using System; namespace FrEee.Objects.Technology; diff --git a/FrEee/Objects/Vehicles/Base.cs b/FrEee/Objects/Vehicles/Base.cs index 4c2e8da1d..d233ca217 100644 --- a/FrEee/Objects/Vehicles/Base.cs +++ b/FrEee/Objects/Vehicles/Base.cs @@ -1,10 +1,6 @@ using FrEee.Enumerations; using FrEee.Interfaces; -using FrEee.Objects.Civilization; -using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; using System; -using System.Linq; namespace FrEee.Objects.Vehicles; diff --git a/FrEee/Objects/Vehicles/Design.cs b/FrEee/Objects/Vehicles/Design.cs index 3e4e72fcc..b94c327bd 100644 --- a/FrEee/Objects/Vehicles/Design.cs +++ b/FrEee/Objects/Vehicles/Design.cs @@ -739,7 +739,7 @@ public void Dispose() emp.KnownDesigns.Remove(this); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is Design d) { diff --git a/FrEee/Objects/Vehicles/Fighter.cs b/FrEee/Objects/Vehicles/Fighter.cs index da8ddbd98..3ded53e59 100644 --- a/FrEee/Objects/Vehicles/Fighter.cs +++ b/FrEee/Objects/Vehicles/Fighter.cs @@ -1,10 +1,9 @@ using FrEee.Enumerations; using FrEee.Interfaces; using FrEee.Objects.Civilization; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; -using FrEee.Serialization; namespace FrEee.Objects.Vehicles; diff --git a/FrEee/Objects/Vehicles/MajorSpaceVehicle.cs b/FrEee/Objects/Vehicles/MajorSpaceVehicle.cs index e261f3ffc..45c23f4eb 100644 --- a/FrEee/Objects/Vehicles/MajorSpaceVehicle.cs +++ b/FrEee/Objects/Vehicles/MajorSpaceVehicle.cs @@ -7,8 +7,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Objects.Vehicles; diff --git a/FrEee/Objects/Vehicles/Ship.cs b/FrEee/Objects/Vehicles/Ship.cs index 82daf7953..88c577760 100644 --- a/FrEee/Objects/Vehicles/Ship.cs +++ b/FrEee/Objects/Vehicles/Ship.cs @@ -1,8 +1,5 @@ using FrEee.Enumerations; -using FrEee.Interfaces; -using FrEee.Objects.Space; using System; -using System.Linq; namespace FrEee.Objects.Vehicles; diff --git a/FrEee/Objects/Vehicles/Troop.cs b/FrEee/Objects/Vehicles/Troop.cs index 87ac2f62e..b057f9400 100644 --- a/FrEee/Objects/Vehicles/Troop.cs +++ b/FrEee/Objects/Vehicles/Troop.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Objects/Vehicles/WeaponPlatform.cs b/FrEee/Objects/Vehicles/WeaponPlatform.cs index 531f86ed6..f6d4b2c70 100644 --- a/FrEee/Objects/Vehicles/WeaponPlatform.cs +++ b/FrEee/Objects/Vehicles/WeaponPlatform.cs @@ -2,7 +2,7 @@ using FrEee.Interfaces; using FrEee.Objects.Civilization; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Serialization; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Processes/TurnProcessor.cs b/FrEee/Processes/TurnProcessor.cs index 5580cca63..887c1ef52 100644 --- a/FrEee/Processes/TurnProcessor.cs +++ b/FrEee/Processes/TurnProcessor.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using FrEee.Interfaces; using FrEee.Objects.Civilization.Diplomacy.Clauses; using FrEee.Objects.Civilization; @@ -14,7 +12,7 @@ using FrEee.Objects.VictoryConditions; using FrEee.Modding; using FrEee.Extensions; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Enumerations; namespace FrEee.Processes; diff --git a/FrEee/Serialization/DataScalar.cs b/FrEee/Serialization/DataScalar.cs index 8a6114a3d..750df1efd 100644 --- a/FrEee/Serialization/DataScalar.cs +++ b/FrEee/Serialization/DataScalar.cs @@ -1,5 +1,5 @@ using FrEee.Extensions; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using Newtonsoft.Json; using System; using System.Globalization; diff --git a/FrEee/Serialization/GalaxyReference.cs b/FrEee/Serialization/GalaxyReference.cs index 71f46de25..49d23a50f 100644 --- a/FrEee/Serialization/GalaxyReference.cs +++ b/FrEee/Serialization/GalaxyReference.cs @@ -3,8 +3,7 @@ using FrEee.Extensions; using System; using System.Collections.Generic; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Serialization; /// @@ -143,14 +142,14 @@ public static implicit operator T(GalaxyReference r) public static bool operator ==(GalaxyReference r1, GalaxyReference r2) { - if (r1.IsNull() && r2.IsNull()) + if (r1 is null && r2 is null) return true; - if (r1.IsNull() || r2.IsNull()) + if (r1 is null || r2 is null) return false; return r1.ID == r2.ID; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { // TODO - upgrade equals to use "as" operator if (obj is GalaxyReference) diff --git a/FrEee/Serialization/IDataObject.cs b/FrEee/Serialization/IDataObject.cs index 5663340d6..4b4fb0bae 100644 --- a/FrEee/Serialization/IDataObject.cs +++ b/FrEee/Serialization/IDataObject.cs @@ -1,5 +1,4 @@ -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Serialization; /// diff --git a/FrEee/Serialization/JsonContractResolver.cs b/FrEee/Serialization/JsonContractResolver.cs index 98b9b6be8..4d0969b53 100644 --- a/FrEee/Serialization/JsonContractResolver.cs +++ b/FrEee/Serialization/JsonContractResolver.cs @@ -1,15 +1,12 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization; - public class JsonContractResolver : DefaultContractResolver +public class JsonContractResolver : DefaultContractResolver { protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) diff --git a/FrEee/Serialization/JsonSerializer.cs b/FrEee/Serialization/JsonSerializer.cs index 097f31b91..626808b0b 100644 --- a/FrEee/Serialization/JsonSerializer.cs +++ b/FrEee/Serialization/JsonSerializer.cs @@ -17,7 +17,7 @@ static JsonSerializer() MissingMemberHandling = MissingMemberHandling.Ignore, ObjectCreationHandling = ObjectCreationHandling.Auto, TypeNameHandling = TypeNameHandling.All, - TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple, + TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple, ContractResolver = new JsonContractResolver() }; } @@ -93,7 +93,7 @@ public string SerializeToString(object o) MissingMemberHandling = MissingMemberHandling.Ignore, ObjectCreationHandling = ObjectCreationHandling.Auto, TypeNameHandling = TypeNameHandling.None, - TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple, + TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple, ContractResolver = new JsonContractResolver() }; diff --git a/FrEee/Serialization/LegacySerializer.cs b/FrEee/Serialization/LegacySerializer.cs index 18728c392..5e4cba6f5 100644 --- a/FrEee/Serialization/LegacySerializer.cs +++ b/FrEee/Serialization/LegacySerializer.cs @@ -1,5 +1,4 @@ using FrEee.Interfaces; -using FrEee.Objects.Civilization; using FrEee.Extensions; using FrEee.Serialization.Stringifiers; using System; @@ -14,8 +13,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Serialization; internal static class LegacySerializer @@ -185,7 +183,7 @@ private static object Deserialize(TextReader r, Type desiredType, bool isRoot, O type = new SafeType(typename).Type; } - catch (Exception ex) + catch { try { diff --git a/FrEee/Serialization/ObjectGraphParser.cs b/FrEee/Serialization/ObjectGraphParser.cs index b519d566a..29181264d 100644 --- a/FrEee/Serialization/ObjectGraphParser.cs +++ b/FrEee/Serialization/ObjectGraphParser.cs @@ -1,5 +1,5 @@ using FrEee.Extensions; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using System; using System.Collections; using System.Collections.Generic; diff --git a/FrEee/Serialization/Serializer.cs b/FrEee/Serialization/Serializer.cs index 04305b075..6a0e4a4af 100644 --- a/FrEee/Serialization/Serializer.cs +++ b/FrEee/Serialization/Serializer.cs @@ -2,7 +2,6 @@ using System; using System.IO; using System.Runtime.Serialization; -using System.Text; namespace FrEee.Serialization; diff --git a/FrEee/Serialization/SimpleDataObject.cs b/FrEee/Serialization/SimpleDataObject.cs index 6b22791e2..de907ea0f 100644 --- a/FrEee/Serialization/SimpleDataObject.cs +++ b/FrEee/Serialization/SimpleDataObject.cs @@ -1,5 +1,5 @@ using FrEee.Extensions; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using Newtonsoft.Json; using System; using static FrEee.Extensions.CommonExtensions; diff --git a/FrEee/Serialization/Stringifiers/DoubleLiteralFormulaStringifier.cs b/FrEee/Serialization/Stringifiers/DoubleLiteralFormulaStringifier.cs index 668a23c05..156253633 100644 --- a/FrEee/Serialization/Stringifiers/DoubleLiteralFormulaStringifier.cs +++ b/FrEee/Serialization/Stringifiers/DoubleLiteralFormulaStringifier.cs @@ -1,11 +1,5 @@ using FrEee.Modding; -using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/IStringifier.cs b/FrEee/Serialization/Stringifiers/IStringifier.cs index 4b5f1425b..409a466b4 100644 --- a/FrEee/Serialization/Stringifiers/IStringifier.cs +++ b/FrEee/Serialization/Stringifiers/IStringifier.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/IntLiteralFormulaStringifier.cs b/FrEee/Serialization/Stringifiers/IntLiteralFormulaStringifier.cs index f21578687..7e4fd077e 100644 --- a/FrEee/Serialization/Stringifiers/IntLiteralFormulaStringifier.cs +++ b/FrEee/Serialization/Stringifiers/IntLiteralFormulaStringifier.cs @@ -1,11 +1,5 @@ using FrEee.Modding; -using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/PointStringifier.cs b/FrEee/Serialization/Stringifiers/PointStringifier.cs index a325b2f92..37cea331c 100644 --- a/FrEee/Serialization/Stringifiers/PointStringifier.cs +++ b/FrEee/Serialization/Stringifiers/PointStringifier.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.ComponentModel.Composition; using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/PopulationModifierStringifier.cs b/FrEee/Serialization/Stringifiers/PopulationModifierStringifier.cs index 8e37d6ae6..895c56fd3 100644 --- a/FrEee/Serialization/Stringifiers/PopulationModifierStringifier.cs +++ b/FrEee/Serialization/Stringifiers/PopulationModifierStringifier.cs @@ -1,11 +1,6 @@ using FrEee.Modding; -using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/ResourceQuantityStringifier.cs b/FrEee/Serialization/Stringifiers/ResourceQuantityStringifier.cs index 12a24fa75..35e89993b 100644 --- a/FrEee/Serialization/Stringifiers/ResourceQuantityStringifier.cs +++ b/FrEee/Serialization/Stringifiers/ResourceQuantityStringifier.cs @@ -1,12 +1,5 @@ -using FrEee.Modding; using FrEee.Utility; -using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/SizeStringifier.cs b/FrEee/Serialization/Stringifiers/SizeStringifier.cs index 3beedecef..0b708bc59 100644 --- a/FrEee/Serialization/Stringifiers/SizeStringifier.cs +++ b/FrEee/Serialization/Stringifiers/SizeStringifier.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.ComponentModel.Composition; using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/StringLiteralFormulaStringifier.cs b/FrEee/Serialization/Stringifiers/StringLiteralFormulaStringifier.cs index a84c8ae1b..35dfffe06 100644 --- a/FrEee/Serialization/Stringifiers/StringLiteralFormulaStringifier.cs +++ b/FrEee/Serialization/Stringifiers/StringLiteralFormulaStringifier.cs @@ -1,11 +1,5 @@ using FrEee.Modding; -using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/Stringifier.cs b/FrEee/Serialization/Stringifiers/Stringifier.cs index 7478797f4..230454527 100644 --- a/FrEee/Serialization/Stringifiers/Stringifier.cs +++ b/FrEee/Serialization/Stringifiers/Stringifier.cs @@ -1,9 +1,4 @@ -using FrEee.Objects.Space; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Serialization/Stringifiers/StringifierLibrary.cs b/FrEee/Serialization/Stringifiers/StringifierLibrary.cs index 30b4ed272..bcc27a6bd 100644 --- a/FrEee/Serialization/Stringifiers/StringifierLibrary.cs +++ b/FrEee/Serialization/Stringifiers/StringifierLibrary.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Serialization.Stringifiers; diff --git a/FrEee/Setup/StarSystemPlacementStrategies/ClusteredStarSystemPlacementStrategy.cs b/FrEee/Setup/StarSystemPlacementStrategies/ClusteredStarSystemPlacementStrategy.cs index 9283a8ad4..3ba463d9e 100644 --- a/FrEee/Setup/StarSystemPlacementStrategies/ClusteredStarSystemPlacementStrategy.cs +++ b/FrEee/Setup/StarSystemPlacementStrategies/ClusteredStarSystemPlacementStrategy.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Setup/StarSystemPlacementStrategies/DiffuseStarSystemPlacementStrategy.cs b/FrEee/Setup/StarSystemPlacementStrategies/DiffuseStarSystemPlacementStrategy.cs index 1239b2242..ec58d7422 100644 --- a/FrEee/Setup/StarSystemPlacementStrategies/DiffuseStarSystemPlacementStrategy.cs +++ b/FrEee/Setup/StarSystemPlacementStrategies/DiffuseStarSystemPlacementStrategy.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Drawing; diff --git a/FrEee/Setup/StarSystemPlacementStrategies/GridStarSystemPlacementStrategy.cs b/FrEee/Setup/StarSystemPlacementStrategies/GridStarSystemPlacementStrategy.cs index 5fc07d660..077abc3aa 100644 --- a/FrEee/Setup/StarSystemPlacementStrategies/GridStarSystemPlacementStrategy.cs +++ b/FrEee/Setup/StarSystemPlacementStrategies/GridStarSystemPlacementStrategy.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Drawing; diff --git a/FrEee/Setup/StarSystemPlacementStrategies/RandomStarSystemPlacementStrategy.cs b/FrEee/Setup/StarSystemPlacementStrategies/RandomStarSystemPlacementStrategy.cs index bf1c2301a..159915f67 100644 --- a/FrEee/Setup/StarSystemPlacementStrategies/RandomStarSystemPlacementStrategy.cs +++ b/FrEee/Setup/StarSystemPlacementStrategies/RandomStarSystemPlacementStrategy.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Drawing; diff --git a/FrEee/Setup/StarSystemPlacementStrategies/SpiralStarSystemPlacementStrategy.cs b/FrEee/Setup/StarSystemPlacementStrategies/SpiralStarSystemPlacementStrategy.cs index 3b6fd3f4d..916a9669e 100644 --- a/FrEee/Setup/StarSystemPlacementStrategies/SpiralStarSystemPlacementStrategy.cs +++ b/FrEee/Setup/StarSystemPlacementStrategies/SpiralStarSystemPlacementStrategy.cs @@ -1,6 +1,6 @@ using FrEee.Interfaces; using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; using System.Collections.Generic; diff --git a/FrEee/Setup/WarpPointPlacementStrategies/RandomAlignedWarpPointPlacementStrategy.cs b/FrEee/Setup/WarpPointPlacementStrategies/RandomAlignedWarpPointPlacementStrategy.cs index e065c8109..1f3d4ae9d 100644 --- a/FrEee/Setup/WarpPointPlacementStrategies/RandomAlignedWarpPointPlacementStrategy.cs +++ b/FrEee/Setup/WarpPointPlacementStrategies/RandomAlignedWarpPointPlacementStrategy.cs @@ -1,5 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; +using FrEee.Utility; using FrEee.Extensions; using System; diff --git a/FrEee/Setup/WarpPointPlacementStrategies/RandomWarpPointPlacementStrategy.cs b/FrEee/Setup/WarpPointPlacementStrategies/RandomWarpPointPlacementStrategy.cs index add2acb52..0a7c6f8b5 100644 --- a/FrEee/Setup/WarpPointPlacementStrategies/RandomWarpPointPlacementStrategy.cs +++ b/FrEee/Setup/WarpPointPlacementStrategies/RandomWarpPointPlacementStrategy.cs @@ -1,6 +1,5 @@ using FrEee.Objects.Space; -using FrEee.Utility; using FrEee.Serialization; - +using FrEee.Utility; namespace FrEee.Setup.WarpPointPlacementStrategies; /// diff --git a/FrEee/Utility/DynamicDictionary.cs b/FrEee/Utility/DynamicDictionary.cs index 03c7e9825..da40dda08 100644 --- a/FrEee/Utility/DynamicDictionary.cs +++ b/FrEee/Utility/DynamicDictionary.cs @@ -141,14 +141,14 @@ public bool TryGetValue(object key, out object value) return true; } - public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) + public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object? value) { var key = string.Join(",", indexes.Select(o => o.ToString()).ToArray()); dict[key] = value; return true; } - public override bool TrySetMember(SetMemberBinder binder, object value) + public override bool TrySetMember(SetMemberBinder binder, object? value) { dict[binder.Name] = value; return true; diff --git a/FrEee/Utility/IPopulator.cs b/FrEee/Utility/IPopulator.cs index 0ad7514da..b8ff9d017 100644 --- a/FrEee/Utility/IPopulator.cs +++ b/FrEee/Utility/IPopulator.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - namespace FrEee.Utility; public interface IPopulator diff --git a/FrEee/Utility/IntVector2.cs b/FrEee/Utility/IntVector2.cs index 8b953c624..d1c8819bc 100644 --- a/FrEee/Utility/IntVector2.cs +++ b/FrEee/Utility/IntVector2.cs @@ -1,6 +1,5 @@ using FrEee.Extensions; using System; -using System.Collections; using System.Collections.Generic; using System.Linq; @@ -143,16 +142,16 @@ public int DistanceToManhattan(IntVector2 dest) return (dest - this).LengthManhattan; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is IntVector2 v) - return this.Equals(v); + return Equals(v); return false; } - public bool Equals(IntVector2 other) + public bool Equals(IntVector2? other) { - return X == other.X && Y == other.Y; + return other is not null && X == other.X && Y == other.Y; } public override int GetHashCode() diff --git a/FrEee/Utility/MathX.cs b/FrEee/Utility/MathX.cs index 68d3eb7eb..a02017efe 100644 --- a/FrEee/Utility/MathX.cs +++ b/FrEee/Utility/MathX.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Utility; diff --git a/FrEee/Utility/PRNG.cs b/FrEee/Utility/PRNG.cs index 8440b39cb..68a6874da 100644 --- a/FrEee/Utility/PRNG.cs +++ b/FrEee/Utility/PRNG.cs @@ -1,5 +1,4 @@ -using FrEee.Extensions; -using System; +using System; namespace FrEee.Utility; @@ -34,14 +33,14 @@ public PRNG(int seed) public static bool operator ==(PRNG r1, PRNG r2) { - if (r1.IsNull() && r2.IsNull()) + if (r1 is null && r2 is null) return true; - if (r1.IsNull() || r2.IsNull()) + if (r1 is null || r2 is null) return false; return r1.Seed == r2.Seed && r1.Iteration == r2.Iteration; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { // TODO - upgrade equals to use "as" operator if (obj is PRNG) diff --git a/FrEee/Utility/PopulateAttribute.cs b/FrEee/Utility/PopulateAttribute.cs index 82dcd39d7..947f460f8 100644 --- a/FrEee/Utility/PopulateAttribute.cs +++ b/FrEee/Utility/PopulateAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FrEee.Utility; diff --git a/FrEee/Utility/Resource.cs b/FrEee/Utility/Resource.cs index 70893c043..92d2b2d40 100644 --- a/FrEee/Utility/Resource.cs +++ b/FrEee/Utility/Resource.cs @@ -222,14 +222,14 @@ public static Resource Find(string name) public static bool operator ==(Resource r1, Resource r2) { - if (r1.IsNull() && r2.IsNull()) + if (r1 is null && r2 is null) return true; - if (r1.IsNull() || r2.IsNull()) + if (r1 is null || r2 is null) return false; return r1.Name == r2.Name && r1.Color == r2.Color && r1.IsGlobal == r2.IsGlobal && r1.IsLocal == r2.IsLocal && r1.PictureName == r2.PictureName; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { var r = obj as Resource; if (ReferenceEquals(r, null)) diff --git a/FrEee/Utility/ResourceQuantity.cs b/FrEee/Utility/ResourceQuantity.cs index d4baa0c25..842e0ddc5 100644 --- a/FrEee/Utility/ResourceQuantity.cs +++ b/FrEee/Utility/ResourceQuantity.cs @@ -126,9 +126,9 @@ public static ResourceQuantity Min(ResourceQuantity r1, ResourceQuantity r2) public static bool operator ==(ResourceQuantity r1, ResourceQuantity r2) { - if (r1.IsNull() && r2.IsNull()) + if (r1 is null && r2 is null) return true; - if (r1.IsNull() || r2.IsNull()) + if (r1 is null || r2 is null) return false; foreach (var key in r1.Keys.Union(r2.Keys)) { @@ -211,7 +211,7 @@ public int CompareTo(object obj) return this.Sum(kvp => kvp.Value).CompareTo(obj.ToString().ToInt()); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is ResourceQuantity rq) return this == rq;