From 2a31eb7fe0aadda8f09f383c7a759200cd10f6ed Mon Sep 17 00:00:00 2001 From: Matthias Koch Date: Thu, 4 Oct 2018 23:41:00 +0200 Subject: [PATCH 1/2] Fix RequirementService to also support shorthand for properties --- CHANGELOG.md | 1 + .../Execution/RequirementService.cs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 070604d4a..5f32e35fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [vNext] +- Fixed `RequirementService` to also support shorthand for properties ## [0.10.1] / 2018-10-02 - Fixed wizard to pass definitions for project file template diff --git a/source/Nuke.Common/Execution/RequirementService.cs b/source/Nuke.Common/Execution/RequirementService.cs index 59ac256ba..4f5db3578 100644 --- a/source/Nuke.Common/Execution/RequirementService.cs +++ b/source/Nuke.Common/Execution/RequirementService.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -26,10 +27,22 @@ public static void ValidateRequirements(IReadOnlyCollection ex var memberExpression = requirement.Body is MemberExpression ? (MemberExpression) requirement.Body : (MemberExpression) ((UnaryExpression) requirement.Body).Operand; - var field = (FieldInfo) memberExpression.Member; - ControlFlow.Assert(field.GetValue(build) != null, - $"Target '{target.Name}' requires that field '{field.Name}' must be not null."); + switch (memberExpression.Member) + { + case FieldInfo field: + ControlFlow.Assert( + field.GetValue(build) != null, + $"Target '{target.Name}' requires that field '{field.Name}' must be not null."); + break; + case PropertyInfo property: + ControlFlow.Assert( + property.GetValue(build) != null, + $"Target '{target.Name}' requires that property '{property.Name}' must be not null."); + break; + default: + throw new Exception($"Member type {memberExpression.Member} not supported."); + } } } } From e42b66b2a9b25e468c3511a4eadbe2e83640ef64 Mon Sep 17 00:00:00 2001 From: Matthias Koch Date: Thu, 4 Oct 2018 23:41:25 +0200 Subject: [PATCH 2/2] Finalize CHANGELOG.md for 0.10.2 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f32e35fe..fbbee639b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [vNext] + +## [0.10.2] / 2018-10-04 - Fixed `RequirementService` to also support shorthand for properties ## [0.10.1] / 2018-10-02 @@ -162,7 +164,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added CLT tasks for Git - Fixed background color in console output -[vNext]: https://github.com/nuke-build/nuke/compare/0.10.1...HEAD +[vNext]: https://github.com/nuke-build/nuke/compare/0.10.2...HEAD +[0.10.2]: https://github.com/nuke-build/nuke/compare/0.10.1...0.10.2 [0.10.1]: https://github.com/nuke-build/nuke/compare/0.10.0...0.10.1 [0.10.0]: https://github.com/nuke-build/nuke/compare/0.9.1...0.10.0 [0.9.1]: https://github.com/nuke-build/nuke/compare/0.9.0...0.9.1