mirror of
https://github.com/Ellpeck/DynamicEnums.git
synced 2024-11-27 18:58:33 +01:00
Compare commits
8 commits
88c75a2464
...
eb2c87a462
Author | SHA1 | Date | |
---|---|---|---|
eb2c87a462 | |||
be8a4b4f41 | |||
4eb15ccae2 | |||
ffbd154153 | |||
5146f7d8a8 | |||
ab37d8fc18 | |||
a5616b6873 | |||
9330354a2a |
5 changed files with 31 additions and 28 deletions
22
.github/workflows/main.yml
vendored
Normal file
22
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
on: [push, pull_request]
|
||||
jobs:
|
||||
build-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
- name: Test
|
||||
run: dotnet test --collect:"XPlat Code Coverage"
|
||||
- name: Pack
|
||||
run: dotnet pack --version-suffix ci.$GITHUB_RUN_NUMBER
|
||||
- name: Publish
|
||||
if: github.event_name == 'push' && github.ref_name == 'main'
|
||||
run: dotnet nuget push -s https://nuget.ellpeck.de/v3/index.json **/*.nupkg -k '${{ secrets.BAGET_KEY }}' -n
|
|
@ -1,20 +0,0 @@
|
|||
variables:
|
||||
- &image mcr.microsoft.com/dotnet/sdk:8.0-jammy
|
||||
steps:
|
||||
build:
|
||||
image: *image
|
||||
commands: dotnet build
|
||||
test:
|
||||
image: *image
|
||||
commands: dotnet test --collect:"XPlat Code Coverage"
|
||||
pack:
|
||||
image: *image
|
||||
commands: dotnet pack --version-suffix ci.$CI_PIPELINE_NUMBER
|
||||
publish:
|
||||
image: *image
|
||||
when:
|
||||
branch: main
|
||||
event: push
|
||||
commands: dotnet nuget push -s https://nuget.ellpeck.de/v3/index.json **/*.nupkg -k $BAGET_KEY -n
|
||||
secrets:
|
||||
- baget_key
|
|
@ -42,7 +42,8 @@ namespace DynamicEnums {
|
|||
/// </summary>
|
||||
/// <param name="name">The name of the enum value</param>
|
||||
/// <param name="value">The value</param>
|
||||
protected DynamicEnum(string name, BigInteger value) {
|
||||
/// <param name="defined">Whether this enum value <see cref="IsDefined(DynamicEnum)"/>, and thus, not a combined flag.</param>
|
||||
protected DynamicEnum(string name, BigInteger value, bool defined) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -121,7 +122,7 @@ namespace DynamicEnums {
|
|||
throw new ArgumentException($"Duplicate name {name}", nameof(name));
|
||||
}
|
||||
|
||||
var ret = DynamicEnum.Construct(typeof(T), name, value);
|
||||
var ret = DynamicEnum.Construct(typeof(T), name, value, true);
|
||||
storage.Values.Add(value, ret);
|
||||
return (T) ret;
|
||||
}
|
||||
|
@ -345,7 +346,7 @@ namespace DynamicEnums {
|
|||
|
||||
// otherwise, cache the combined value
|
||||
if (!storage.FlagCache.TryGetValue(value, out var combined)) {
|
||||
combined = DynamicEnum.Construct(type, null, value);
|
||||
combined = DynamicEnum.Construct(type, null, value, false);
|
||||
storage.FlagCache.Add(value, combined);
|
||||
}
|
||||
return combined;
|
||||
|
@ -431,8 +432,8 @@ namespace DynamicEnums {
|
|||
#if NET6_0_OR_GREATER
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
|
||||
#endif
|
||||
Type type, string name, BigInteger value) {
|
||||
return (DynamicEnum) Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] {name, value}, CultureInfo.InvariantCulture);
|
||||
Type type, string name, BigInteger value, bool defined) {
|
||||
return (DynamicEnum) Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] {name, value, defined}, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private class Storage {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<RepositoryUrl>https://github.com/Ellpeck/DynamicEnums</RepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<VersionPrefix>1.1.0</VersionPrefix>
|
||||
<VersionPrefix>1.2.0</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -86,7 +86,7 @@ public class EnumTests {
|
|||
|
||||
private class TestDynamicEnum : DynamicEnum {
|
||||
|
||||
public TestDynamicEnum(string name, BigInteger value) : base(name, value) {}
|
||||
public TestDynamicEnum(string name, BigInteger value, bool defined) : base(name, value, defined) {}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue