Skip to content

Commit 4135748

Browse files
committed
Added net9.0 netstandard2.x support.
1 parent e431d71 commit 4135748

36 files changed

+522
-92
lines changed

AndroidTests/AndroidTests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0-android</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

Hexa.NET.ImGui.Widgets.Extras/Hexa.NET.ImGui.Widgets.Extras.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</ItemGroup>
3939

4040
<ItemGroup>
41-
<PackageReference Include="Hexa.NET.Math" Version="2.0.2" />
41+
<PackageReference Include="Hexa.NET.Math" Version="2.0.3" />
4242
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
4343
</ItemGroup>
4444

Hexa.NET.ImGui.Widgets.Tests/Hexa.NET.ImGui.Widgets.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
16-
<PackageReference Include="NUnit" Version="3.14.0" />
17-
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
18-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
14+
<PackageReference Include="coverlet.collector" Version="6.0.2" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
16+
<PackageReference Include="NUnit" Version="4.2.2" />
17+
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
18+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

Hexa.NET.ImGui.Widgets/ComboHelper.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using Hexa.NET.ImGui;
44
using System;
5+
using System.Linq;
56
using System.Diagnostics.CodeAnalysis;
67

78
/// <summary>
@@ -10,8 +11,13 @@
1011
/// <typeparam name="T">The enum type.</typeparam>
1112
public static class ComboEnumHelper<T> where T : struct, Enum
1213
{
14+
#if NET5_0_OR_GREATER
1315
private static readonly T[] values = Enum.GetValues<T>();
1416
private static readonly string[] names = Enum.GetNames<T>();
17+
#else
18+
private static readonly T[] values = (T[])Enum.GetValues(typeof(T));
19+
private static readonly string[] names = Enum.GetNames(typeof(T));
20+
#endif
1521

1622
/// <summary>
1723
/// Displays a combo box to select an enum value.
@@ -54,9 +60,15 @@ public static class ComboEnumHelper
5460
{
5561
private static readonly Dictionary<Type, object[]> values = new();
5662
private static readonly Dictionary<Type, string[]> names = new();
63+
#if NET7_0_OR_GREATER
5764

5865
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "All members are included by [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)].")]
59-
private static void Get([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, out object[] values, out string[] names)
66+
#endif
67+
private static void Get(
68+
#if NET7_0_OR_GREATER
69+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
70+
#endif
71+
Type type, out object[] values, out string[] names)
6072
{
6173
if (ComboEnumHelper.values.TryGetValue(type, out var objects))
6274
{
@@ -78,7 +90,11 @@ private static void Get([DynamicallyAccessedMembers(DynamicallyAccessedMemberTyp
7890
/// <param name="type">The enum type to select values from.</param>
7991
/// <param name="value">The currently selected enum value (modified by user interaction).</param>
8092
/// <returns><c>true</c> if the user selects a new value, <c>false</c> otherwise.</returns>
81-
public static bool Combo(string label, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, ref object value)
93+
public static bool Combo(string label,
94+
#if NET7_0_OR_GREATER
95+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
96+
#endif
97+
Type type, ref object value)
8298
{
8399
Get(type, out var values, out var names);
84100
int index = Array.IndexOf(values, value);
@@ -95,7 +111,11 @@ public static bool Combo(string label, [DynamicallyAccessedMembers(DynamicallyAc
95111
/// </summary>
96112
/// <param name="type">The enum type to select values from.</param>
97113
/// <param name="value">The enum value to display.</param>
98-
public static void Text([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object value)
114+
public static void Text(
115+
#if NET7_0_OR_GREATER
116+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
117+
#endif
118+
Type type, object value)
99119
{
100120
Get(type, out var values, out var names);
101121
int index = Array.IndexOf(values, value);

Hexa.NET.ImGui.Widgets/Dialogs/CompareByDateModifiedComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
public int Compare(T a, T b)
66
{
7-
int cmp = IFileSystemItem.CompareByBase(a, b);
7+
int cmp = BaseComparer.CompareByBase(a, b);
88
if (cmp != 0)
99
{
1010
return cmp;

Hexa.NET.ImGui.Widgets/Dialogs/CompareByNameComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
public int Compare(T a, T b)
66
{
7-
int cmp = IFileSystemItem.CompareByBase(a, b);
7+
int cmp = BaseComparer.CompareByBase(a, b);
88
if (cmp != 0)
99
{
1010
return cmp;

Hexa.NET.ImGui.Widgets/Dialogs/CompareBySizeComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
public int Compare(T a, T b)
66
{
7-
int cmp = IFileSystemItem.CompareByBase(a, b);
7+
int cmp = BaseComparer.CompareByBase(a, b);
88
if (cmp != 0)
99
{
1010
return cmp;

Hexa.NET.ImGui.Widgets/Dialogs/CompareByTypeComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
public int Compare(T a, T b)
66
{
7-
int cmp = IFileSystemItem.CompareByBase(a, b);
7+
int cmp = BaseComparer.CompareByBase(a, b);
88
if (cmp != 0)
99
{
1010
return cmp;

Hexa.NET.ImGui.Widgets/Dialogs/DialogManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ public static void Draw()
4545
ImGui.EndDisabled();
4646
}
4747

48+
#if NETSTANDARD2_0
49+
50+
while (closing.Count > 0)
51+
{
52+
var dialog = closing.Dequeue();
53+
dialogs.Remove(dialog);
54+
}
55+
#else
4856
while (closing.TryDequeue(out var dialog))
4957
{
5058
dialogs.Remove(dialog);
5159
}
60+
#endif
5261

5362
WidgetManager.BlockInput = dialogs.Count > 0;
5463
}

Hexa.NET.ImGui.Widgets/Dialogs/FileDialogBase.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using Hexa.NET.ImGui;
44
using Hexa.NET.ImGui.Widgets;
5+
using Hexa.NET.ImGui.Widgets.Extensions;
56
using Hexa.NET.ImGui.Widgets.IO;
67
using Hexa.NET.ImGui.Widgets.Text;
78
using System.Diagnostics;
@@ -610,20 +611,40 @@ public virtual void GoHome()
610611

611612
public virtual void TryGoBack()
612613
{
614+
#if NETSTANDARD2_0
615+
616+
if (backHistory.Count > 0)
617+
{
618+
var historyItem = backHistory.Pop();
619+
forwardHistory.Push(CurrentFolder);
620+
SetInternal(historyItem);
621+
}
622+
#else
613623
if (backHistory.TryPop(out var historyItem))
614624
{
615625
forwardHistory.Push(CurrentFolder);
616626
SetInternal(historyItem);
617627
}
628+
#endif
618629
}
619630

620631
public virtual void TryGoForward()
621632
{
633+
#if NETSTANDARD2_0
634+
635+
if (forwardHistory.Count > 0)
636+
{
637+
var historyItem = forwardHistory.Pop();
638+
backHistory.Push(CurrentFolder);
639+
SetInternal(historyItem);
640+
}
641+
#else
622642
if (forwardHistory.TryPop(out var historyItem))
623643
{
624644
backHistory.Push(CurrentFolder);
625645
SetInternal(historyItem);
626646
}
647+
#endif
627648
}
628649

629650
public void ClearHistory()
@@ -733,7 +754,7 @@ protected virtual bool FileSystemItemSearchFilter(FileSystemItem arg)
733754

734755
protected virtual string IconSelector(FileMetadata file)
735756
{
736-
ReadOnlySpan<char> extension = Path.GetExtension(file.Path.AsSpan());
757+
ReadOnlySpan<char> extension = FileUtils.GetExtension(file.Path.AsSpan());
737758

738759
switch (extension)
739760
{

0 commit comments

Comments
 (0)