Skip to content

Commit

Permalink
Update utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornado-Technology committed Aug 15, 2024
1 parent ce71ab2 commit 770ec9f
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Hypercube.Client/Utilities/Helpers/AudioTypeHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Frozen;
using Hypercube.Client.Audio;
using Hypercube.Shared.Utilities.Extensions;
using Hypercube.Utilities.Extensions;

namespace Hypercube.Client.Utilities.Helpers;

Expand Down
2 changes: 1 addition & 1 deletion Hypercube.Dependencies/DependenciesContainer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;
using Hypercube.Shared.Logging;
using Hypercube.Shared.Utilities.Extensions;
using Hypercube.Utilities.Extensions;
using JetBrains.Annotations;

namespace Hypercube.Dependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Hypercube.Shared.Entities.Realisation.Components;
using Hypercube.Shared.Entities.Realisation.EventBus.EventArgs;
using Hypercube.Shared.Entities.Realisation.Systems;
using Hypercube.Shared.Utilities.Units;
using Hypercube.Utilities.Units;

namespace Hypercube.Shared.Entities.Realisation.EventBus;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Hypercube.Shared.Entities.Realisation.Components;
using Hypercube.Shared.Entities.Realisation.EventBus.EventArgs;
using Hypercube.Shared.Utilities.Units;
using Hypercube.Utilities.Units;

namespace Hypercube.Shared.Entities.Realisation.EventBus;

Expand Down
4 changes: 2 additions & 2 deletions Hypercube.Shared/EventBus/EventBus.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
using Hypercube.Shared.EventBus.Events;
using Hypercube.Shared.Utilities.Ref;
using Hypercube.Shared.Utilities.Units;
using Hypercube.Utilities.Ref;
using Hypercube.Utilities.Units;

namespace Hypercube.Shared.EventBus;

Expand Down
2 changes: 1 addition & 1 deletion Hypercube.Shared/EventBus/EventSubscription.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Hypercube.Shared.Utilities.Ref;
using Hypercube.Utilities.Ref;

namespace Hypercube.Shared.EventBus;

Expand Down
5 changes: 0 additions & 5 deletions Hypercube.Shared/Utilities/Ref/RefHandler.cs

This file was deleted.

29 changes: 0 additions & 29 deletions Hypercube.Shared/Utilities/SimpleCallbackContainer.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Hypercube.Shared/Utilities/Units/UnitBox.cs

This file was deleted.

5 changes: 4 additions & 1 deletion Hypercube.Utilities/Extensions/StringExtension.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Hypercube.Shared.Utilities.Extensions;
using JetBrains.Annotations;

namespace Hypercube.Utilities.Extensions;

[PublicAPI]
public static class StringExtension
{
public static string RemoveChar(this string str, char @char) {
Expand Down
4 changes: 3 additions & 1 deletion Hypercube.Utilities/Extensions/TypeExtension.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Reflection;
using JetBrains.Annotations;

namespace Hypercube.Shared.Utilities.Extensions;
namespace Hypercube.Utilities.Extensions;

[PublicAPI]
public static class TypeExtension
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Runtime.CompilerServices;
using Hypercube.Shared.Utilities.Units;
using Hypercube.Utilities.Units;
using JetBrains.Annotations;

namespace Hypercube.Shared.Utilities;
namespace Hypercube.Utilities.Helpers;

[PublicAPI]
public static class UnitHelper
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
5 changes: 5 additions & 0 deletions Hypercube.Utilities/Ref/RefHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Hypercube.Utilities.Units;

namespace Hypercube.Utilities.Ref;

public delegate void RefHandler(ref Unit ev);
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using System.Runtime;
using JetBrains.Annotations;
using SysRuntimeInformation = System.Runtime.InteropServices.RuntimeInformation;

namespace Hypercube.Shared.Utilities;
namespace Hypercube.Utilities;

[PublicAPI]
public static class RuntimeInformation
{
public static string[] GetInformationDump()
{
var version = typeof(RuntimeInformation).Assembly.GetName().Version;

return new[]
{
return
[
$"OS: {SysRuntimeInformation.OSDescription} {SysRuntimeInformation.OSArchitecture}",
$".NET Runtime: {SysRuntimeInformation.FrameworkDescription} {SysRuntimeInformation.RuntimeIdentifier}",
$"Server GC: {GCSettings.IsServerGC}",
$"Architecture: {SysRuntimeInformation.ProcessArchitecture}",
$"Hypercube Version: {version}",
};
$"Version: {version}"
];
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace Hypercube.Shared.Utilities.Units;
using JetBrains.Annotations;

namespace Hypercube.Utilities.Units;

/// <summary>
/// Whenever you see this struct it some other object, it should be resolved using Unsafe.As()
/// Whenever you see this struct it some other object, it should be resolved using Unsafe.As().
/// </summary>
[PublicAPI]
public readonly struct Unit;
21 changes: 21 additions & 0 deletions Hypercube.Utilities/Units/UnitBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Runtime.InteropServices;
using JetBrains.Annotations;

namespace Hypercube.Utilities.Units;

/// <summary>
/// Whenever you see this it is some other object, it should be resolved using Unsafe.As().
/// </summary>
/// <remarks>
/// Should be used whenever we want to pass value by ref.
/// </remarks>
[PublicAPI, StructLayout(LayoutKind.Sequential)]
public sealed class UnitBox
{
public Unit Value;

public static implicit operator Unit(UnitBox unitBox)
{
return unitBox.Value;
}
}

0 comments on commit 770ec9f

Please sign in to comment.