Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

🚧Update to dotnet 8 #81

Merged
merged 8 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
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.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const


Expand Down Expand Up @@ -154,6 +154,9 @@ 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

# Opening square brackets should not be preceded by a space.
dotnet_diagnostic.SA1010.severity = none

# Wrapping preferences
csharp_preserve_single_line_blocks = true

Expand Down Expand Up @@ -197,3 +200,17 @@ csharp_prefer_simple_using_statement = true:suggestion
# Using directives must be placed inside of a namespace declaration
# IDE0065: Misplaced using directive
csharp_using_directive_placement = inside_namespace

#############################################################
# Resharper Rules #
# Resharper rule name syntax #
# resharper_<inspection_name>_highlighting=<severity_level> #
#############################################################

# noinspection EditorConfigKeyCorrectness

resharper_bad_parens_spaces_highlighting = none
resharper_bad_list_line_breaks_highlighting = none
resharper_bad_parens_line_breaks_highlighting = none

# inspection EditorConfigKeyCorrectness
2 changes: 0 additions & 2 deletions Plazma.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{8518113E-D0C3-4E63-8F2E-542EB6D1CCE9}"
ProjectSection(SolutionItems) = preProject
.github\workflows\add-new-issue-to-project.yml = .github\workflows\add-new-issue-to-project.yml
.github\workflows\build-status-check.yml = .github\workflows\build-status-check.yml
.github\workflows\release.yml = .github\workflows\release.yml
.github\workflows\sync-bot.yml = .github\workflows\sync-bot.yml
.github\workflows\sync-issue-to-pr.yml = .github\workflows\sync-issue-to-pr.yml
.github\workflows\sync-status-check.yml = .github\workflows\sync-status-check.yml
.github\workflows\triage-issue.yml = .github\workflows\triage-issue.yml
.github\workflows\unit-test-status-check.yml = .github\workflows\unit-test-status-check.yml
Expand Down
3 changes: 3 additions & 0 deletions Plazma.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">145</s:Int64>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=_002ATesting_002A_003B_002A_003B_002ATests_002A_003B_002A/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=_002ATesting_003B_002A_003B_002ATests_003B_002A/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=_002ATesting_003B_002A_003B_002A_003B_002A/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -11,6 +13,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=3AB1D2F8CB4D99439416065D7DD69EC8/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=3AB1D2F8CB4D99439416065D7DD69EC8/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=3AB1D2F8CB4D99439416065D7DD69EC8/Description/@EntryValue">XUnit Unit Test Method</s:String>
Expand Down
30 changes: 0 additions & 30 deletions Plazma/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,34 +117,4 @@ public static int Count<T>(this T[]? items, Predicate<T> predicate)
/// <returns>True if the string contains non number characters.</returns>
public static bool ContainsNonNumberCharacters(this string value) =>
!string.IsNullOrEmpty(value) && Array.Exists(value.ToCharArray(), c => !ValidNumChars.Contains(c));

/// <summary>
/// Returns a value indicating if each item in a given list position is
/// equal to the items in the same position of th given <paramref name="compareItems"/> list.
/// </summary>
/// <typeparam name="T">The type of item in the lists.</typeparam>
/// <param name="items">The current instance of <see cref="IEnumerable{T}"/> items.</param>
/// <param name="compareItems">The items to compare to the this list of items.</param>
/// <returns>True if each arrays are equal.</returns>
public static bool ItemsAreEqual<T>(this IEnumerable<T>? items, IEnumerable<T>? compareItems)
where T : class
{
var enumeratedItems = items is null ? Array.Empty<T>() : items.ToArray();
var enumeratedCompareItems = compareItems is null ? Array.Empty<T>() : compareItems.ToArray();

if (enumeratedItems.Length != enumeratedCompareItems.Length)
{
return false;
}

for (var i = 0; i < enumeratedItems.Length; i++)
{
if (!enumeratedItems[i].Equals(enumeratedCompareItems[i]))
{
return false;
}
}

return true;
}
}
4 changes: 2 additions & 2 deletions Plazma/Plazma.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>

<!--Update this for production and preview releases-->
Expand Down
73 changes: 36 additions & 37 deletions Testing/PlazmaTesting/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace PlazmaTesting;

using System.Drawing;
using System.Text;
using KdGui;
using KdGui.Factories;
using Scenes;
using Velaptor;
using Velaptor.Batching;
using Velaptor.Factories;
using Velaptor.UI;

/// <summary>
Expand All @@ -18,14 +18,14 @@ namespace PlazmaTesting;
public class MainWindow : Window
{
private static readonly char[] UpperCaseChars =
{
[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
};
private readonly Button nextButton;
private readonly Button previousButton;
private readonly IBatcher batcher;
];
private readonly IControlFactory ctrlFactory;
private IControlGroup? ctrlGroup;
private INextPrevious? nextPrevButton;

/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
Expand All @@ -34,9 +34,7 @@ public MainWindow()
{
TypeOfBorder = WindowBorder.Fixed;

this.batcher = RendererFactory.CreateBatcher();
this.nextButton = new Button { Text = "-->" };
this.previousButton = new Button { Text = "<--" };
this.ctrlFactory = new ControlFactory();

var horizontalMovementScene = new HorizontalMovementScene
{
Expand Down Expand Up @@ -64,36 +62,38 @@ public MainWindow()
SceneManager.AddScene(angleScene);
}

public static Rectangle ButtonsArea { get; private set; }

/// <summary>
/// Loads the applications content.
/// </summary>
protected override void OnLoad()
{
const int buttonSpacing = 15;
const int rightMargin = 15;
this.nextPrevButton = this.ctrlFactory.CreateNextPrevious();

this.nextButton.Click += (_, _) => SceneManager.NextScene();
this.ctrlGroup = this.ctrlFactory.CreateControlGroup();

this.previousButton.Click += (_, _) => SceneManager.PreviousScene();
// NOTE: Remember, every group needs to have a different title so the
// underlying ImGui group is unique.
this.ctrlGroup.Title = "Prev/Next Group";
this.ctrlGroup.Initialized += CtrlGroupOnInitialized;
this.ctrlGroup.Width = 200;
this.ctrlGroup.TitleBarVisible = false;
this.ctrlGroup.AutoSizeToFitContent = true;

this.nextButton.LoadContent();
this.previousButton.LoadContent();
this.ctrlGroup.Add(this.nextPrevButton);

var buttonTops = (int)(Height - (new[] { this.nextButton.Height, this.previousButton.Height }.Max() + 20));
var buttonGroupLeft = (int)(Width - (this.nextButton.Width + this.previousButton.Width + buttonSpacing + rightMargin));
this.previousButton.Position = new Point(buttonGroupLeft, buttonTops);
this.nextButton.Position = new Point(this.previousButton.Position.X + (int)this.previousButton.Width + buttonSpacing, buttonTops);
this.nextPrevButton.Next += NextPrev_OnNextClicked;
this.nextPrevButton.Previous += NextPrev_OnPreviousClicked;

var left = this.previousButton.Left;
var right = this.nextButton.Right;
var width = this.nextButton.Right - this.previousButton.Left;
var height = (int)Math.Max(this.previousButton.Height, this.nextButton.Height);
base.OnLoad();
}

ButtonsArea = new Rectangle(left, right, width, height);
protected override void OnUnload()
{
this.ctrlGroup.Initialized -= CtrlGroupOnInitialized;
this.nextPrevButton.Next -= NextPrev_OnNextClicked;
this.nextPrevButton.Previous -= NextPrev_OnPreviousClicked;

base.OnLoad();
base.OnUnload();
}

/// <summary>
Expand All @@ -104,9 +104,6 @@ protected override void OnUpdate(FrameTime frameTime)
{
Title = $"Scene: {SceneManager.CurrentScene?.Name ?? "No Scene Loaded"}";

this.nextButton.Update(frameTime);
this.previousButton.Update(frameTime);

base.OnUpdate(frameTime);
}

Expand All @@ -118,12 +115,7 @@ protected override void OnDraw(FrameTime frameTime)
{
base.OnDraw(frameTime);

this.batcher.Begin();

this.nextButton.Render();
this.previousButton.Render();

this.batcher.End();
this.ctrlGroup.Render();
}

/// <summary>
Expand Down Expand Up @@ -159,4 +151,11 @@ private static string SplitByUpperCase(string value)

return result.TrimEnd(' ');
}

private void CtrlGroupOnInitialized(object? sender, EventArgs e) =>
this.ctrlGroup.Position = new Point((int)Width - (this.ctrlGroup.Width + 15), (int)Height - (this.ctrlGroup.Height + 15));

private void NextPrev_OnNextClicked(object? sender, EventArgs e) => SceneManager.NextScene();

private void NextPrev_OnPreviousClicked(object? sender, EventArgs e) => SceneManager.PreviousScene();
}
1 change: 1 addition & 0 deletions Testing/PlazmaTesting/ParticleTextureLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace PlazmaTesting;

using Plazma;
using Velaptor.Content;
using Velaptor.ExtensionMethods;
using Velaptor.Factories;

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions Testing/PlazmaTesting/PlazmaTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KinsonDigital.Velaptor" Version="1.0.0-preview.32" />
<PackageReference Include="KinsonDigital.KdGui" Version="1.0.0-preview.1" />
<PackageReference Include="KinsonDigital.Velaptor" Version="1.0.0-preview.36" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 1 addition & 3 deletions Testing/PlazmaTesting/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
// Copyright (c) KinsonDigital. All rights reserved.
// </copyright>

using PlazmaTesting;

var game = new MainWindow();
var game = new PlazmaTesting.MainWindow();
game.Show();
22 changes: 0 additions & 22 deletions Testing/PlazmaTesting/Scenes/AngleScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace PlazmaTesting.Scenes;
using Velaptor.Factories;
using Velaptor.Graphics;
using Velaptor.Graphics.Renderers;
using Velaptor.Input;
using Velaptor.Scene;

/// <summary>
Expand All @@ -26,16 +25,13 @@ public class AngleScene : SceneBase
private const float TextureHalfHeight = 31.5f;
private readonly ITextureLoader<ITexture> textureLoader = new ParticleTextureLoader();
private readonly ITextureRenderer textureRenderer;
private readonly IAppInput<MouseState> mouse;
private readonly ParticleEngine<ITexture>? engine;
private MouseState prevMouseState;

/// <summary>
/// Initializes a new instance of the <see cref="AngleScene"/> class.
/// </summary>
public AngleScene()
{
this.mouse = HardwareFactory.GetMouse();
this.textureRenderer = RendererFactory.CreateTextureRenderer();
this.engine = new ParticleEngine<ITexture>();
}
Expand Down Expand Up @@ -80,7 +76,6 @@ public override void UnloadContent()
/// <param name="frameTime">The time passed for the current frame.</param>
public override void Update(FrameTime frameTime)
{
ProcessMouseInput();
this.engine.Update(frameTime.ElapsedTime);

base.Update(frameTime);
Expand Down Expand Up @@ -116,23 +111,6 @@ public override void Render()
base.Render();
}

/// <summary>
/// Processes mouse input.
/// </summary>
private void ProcessMouseInput()
{
var mouseState = this.mouse.GetState();

var mouseNotOverButtons = !MainWindow.ButtonsArea.Contains(mouseState.GetPosition());

if (this.prevMouseState.IsLeftButtonDown() && mouseState.IsLeftButtonUp() && mouseNotOverButtons)
{
this.engine.Enabled = !this.engine.Enabled;
}

this.prevMouseState = mouseState;
}

/// <summary>
/// Creates the settings.
/// </summary>
Expand Down
Loading
Loading