Skip to content

Commit 0c2fc22

Browse files
committed
Fix VersionOptionFromMember
1 parent e81e13b commit 0c2fc22

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/CommandLineUtils/Attributes/VersionOptionFromMemberAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ internal CommandOption Configure(CommandLineApplication app, Type type, Func<obj
6464
};
6565
}
6666

67-
return app.VersionOption(Template, shortFormGetter, longFormGetter);
67+
var option = app.VersionOption(Template, shortFormGetter, longFormGetter);
68+
Configure(option);
69+
return option;
6870
}
6971
}
7072
}

test/CommandLineUtils.Tests/VersionOptionFromMemberAttributeTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Linq;
56
using Xunit;
67

78
namespace McMaster.Extensions.CommandLineUtils.Tests
@@ -67,5 +68,19 @@ public void ThrowWhenMemberDoesNotExist()
6768
});
6869
Assert.Equal(Strings.NoPropertyOrMethodFound("Version", typeof(MissingMethod)), ex.Message);
6970
}
71+
72+
[VersionOptionFromMember(Description = "42")]
73+
private class Description
74+
{
75+
}
76+
77+
[Fact]
78+
public void GetsDescriptionFromOption()
79+
{
80+
var app = new CommandLineApplication<Description>();
81+
app.Conventions.UseVersionOptionFromMemberAttribute();
82+
83+
Assert.Equal("42", app.Options.First().Description);
84+
}
7085
}
7186
}

0 commit comments

Comments
 (0)