-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from winterheart/architecture-update
Introduce Architecture enum for supported aches
- Loading branch information
Showing
8 changed files
with
103 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.ComponentModel; | ||
|
||
namespace MelonLoader.Installer; | ||
|
||
/// <summary> | ||
/// Supported architectures by MelonLoader. | ||
/// </summary> | ||
public enum Architecture | ||
{ | ||
[Description("unknown")] | ||
Unknown, | ||
[Description("win-x86")] | ||
WindowsX86, | ||
[Description("win-x64")] | ||
WindowsX64, | ||
[Description("linux-x64")] | ||
LinuxX64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.ComponentModel; | ||
|
||
namespace MelonLoader.Installer.Utils; | ||
|
||
/// <summary> | ||
/// Class for converting Description annotations into string | ||
/// </summary> | ||
public static class EnumHelper | ||
{ | ||
public static string? GetDescription<T>(this T enumValue) | ||
where T : struct, IConvertible | ||
{ | ||
if (!typeof(T).IsEnum) | ||
return null; | ||
|
||
var description = enumValue.ToString(); | ||
var fieldInfo = enumValue.GetType().GetField(enumValue.ToString()); | ||
Check warning on line 17 in MelonLoader.Installer/Utils/EnumHelper.cs GitHub Actions / Build Installer
|
||
|
||
if (fieldInfo == null) | ||
return description; | ||
|
||
var attrs = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true); | ||
if (attrs.Length > 0) | ||
description = ((DescriptionAttribute)attrs[0]).Description; | ||
|
||
return description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters