From a52934302a3d96a68e5ec1d45e15b01dde6e7116 Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Tue, 12 Nov 2024 16:38:28 +0200 Subject: [PATCH] :bug: AttributeUsage.Class doesn't apply to interfaces :/ --- .../PeanutButter.EasyArgs.Tests/TestParserExtensions.cs | 6 ++++++ .../Attributes/AllowDefaultFromEnvironment.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Utils/PeanutButter.EasyArgs.Tests/TestParserExtensions.cs b/source/Utils/PeanutButter.EasyArgs.Tests/TestParserExtensions.cs index 5de0ea9c1..b270c1cb0 100644 --- a/source/Utils/PeanutButter.EasyArgs.Tests/TestParserExtensions.cs +++ b/source/Utils/PeanutButter.EasyArgs.Tests/TestParserExtensions.cs @@ -1515,6 +1515,12 @@ public void ShouldReadAllDefaultsFromEnvironment() .To.Equal(expectedString); } + [AllowDefaultsFromEnvironment] + public interface IOptions + { + int Number { get; set; } + } + [AllowDefaultsFromEnvironment] public class AllFromEnv { diff --git a/source/Utils/PeanutButter.EasyArgs/Attributes/AllowDefaultFromEnvironment.cs b/source/Utils/PeanutButter.EasyArgs/Attributes/AllowDefaultFromEnvironment.cs index 9e469a149..1c7bf87a4 100644 --- a/source/Utils/PeanutButter.EasyArgs/Attributes/AllowDefaultFromEnvironment.cs +++ b/source/Utils/PeanutButter.EasyArgs/Attributes/AllowDefaultFromEnvironment.cs @@ -47,7 +47,7 @@ string environmentVariable /// Allows defaults for all options on the options /// object to be overridden from environment variables /// -[AttributeUsage(AttributeTargets.Class)] +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] #if BUILD_PEANUTBUTTER_EASYARGS_INTERNAL internal #else