Skip to content

Commit

Permalink
Random refactoring 2024 01 14 (#278)
Browse files Browse the repository at this point in the history
* Fix some warnings erlated to nullability

* Get rid of obsolete IsNull extension method; use is null operator instead

* Fix more warnings and unnecessary usings
  • Loading branch information
ekolis authored Jan 14, 2024
1 parent c88841b commit ad010ba
Show file tree
Hide file tree
Showing 243 changed files with 314 additions and 701 deletions.
121 changes: 4 additions & 117 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions FrEee.Assets/FrEee.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<Content Include="Scripts\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<PropertyGroup>
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
Expand Down
2 changes: 0 additions & 2 deletions FrEee.Tests/Objects/Abilities/AbilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions FrEee.Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using FrEee.Objects.Technology;
using FrEee.Objects.Vehicles;
using FrEee.Modding;
using System;
using System.Reflection;

namespace FrEee.Tests;

Expand Down
10 changes: 2 additions & 8 deletions FrEee.Tests/Utility/DataTest.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion FrEee.Tests/Utility/Extensions/EnumerableExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FrEee.Extensions;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;

namespace FrEee.Tests.Utility.Extensions;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Tests/Utility/Extensions/ParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using FrEee.Extensions;
using NUnit.Framework;
using System;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Tests/Utility/MathXTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using NUnit.Framework;

namespace FrEee.Tests.Utility;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Tests/Utility/PrngTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using NUnit.Framework;

namespace FrEee.Tests.Utility;
Expand Down
4 changes: 2 additions & 2 deletions FrEee.Tests/Utility/SerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Tests/Utility/VectorTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using NUnit.Framework;

namespace FrEee.Tests.Utility;
Expand Down
3 changes: 1 addition & 2 deletions FrEee.WinForms/Controls/AsteroidFieldReport.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 1 addition & 2 deletions FrEee.WinForms/Controls/BattleView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/ComponentReport.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/DesignReport.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/FacilityReport.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/FleetReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions FrEee.WinForms/Controls/GalaxyView.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -27,7 +27,7 @@ public GalaxyView()
/// <summary>
/// An image to display as the background for this galaxy view.
/// </summary>
public override Image BackgroundImage
public override Image? BackgroundImage
{
get
{
Expand Down Expand Up @@ -78,7 +78,7 @@ public int StarSystemDrawSize
}
}

private Image backgroundImage;
private Image? backgroundImage;

private IGalaxyViewMode mode = GalaxyViewModes.All.First();

Expand Down
9 changes: 3 additions & 6 deletions FrEee.WinForms/Controls/GamePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/GameProgressBar.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using FrEee.Extensions;
using System;
using System.Drawing;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/MountReport.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/PlanetReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/ResourceDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using FrEee.Extensions;
using System;
using System.ComponentModel;
Expand Down
2 changes: 1 addition & 1 deletion FrEee.WinForms/Controls/ResourceQuantityDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Utility; using FrEee.Serialization;
using FrEee.Utility;
using FrEee.WinForms.Interfaces;
using System.Windows.Forms;

Expand Down
9 changes: 4 additions & 5 deletions FrEee.WinForms/Controls/SpaceVehicleReport.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion FrEee.WinForms/Controls/StarReport.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FrEee.Objects.Space;
using FrEee.Extensions;
using FrEee.WinForms.Interfaces;
using System;
using System.Drawing;
using System.Windows.Forms;

Expand Down
1 change: 0 additions & 1 deletion FrEee.WinForms/Controls/StormReport.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FrEee.Objects.Space;
using FrEee.Extensions;
using FrEee.WinForms.Interfaces;
using System;
using System.Drawing;
using System.Windows.Forms;

Expand Down
1 change: 0 additions & 1 deletion FrEee.WinForms/Controls/WarpPointReport.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FrEee.Objects.Space;
using FrEee.Extensions;
using FrEee.WinForms.Interfaces;
using System;
using System.Drawing;
using System.Windows.Forms;

Expand Down
Loading

0 comments on commit ad010ba

Please sign in to comment.