Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Nov 12, 2024
1 parent 596ba7d commit 04cd109
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/Build.PublicApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool DefaultFilter(MemberInfo member)
if (!(member.IsPublic() || member.IsFamily() && !member.DeclaringType.NotNull().IsSealed))
return false;
if (member is FieldInfo field && field.IsSpecialName)
if (member is FieldInfo { IsSpecialName: true })
return false;
return true;
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.Build/Attributes/VerbosityMappingAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ internal static class VerbosityMapping
{
public static readonly LookupTable<Type, (Verbosity Verbosity, object MappedVerbosity)> Mappings = new();

public static void Apply(object obj)
public static void Apply(ToolOptions options)
{
foreach (var property in obj.GetType().GetProperties())
foreach (var property in options.GetType().GetProperties())
{
if (!Mappings.Contains(property.PropertyType))
continue;
Expand All @@ -62,7 +62,7 @@ public static void Apply(object obj)
foreach (var (verbosity, mappedVerbosity) in mappings)
{
if (verbosity == NukeBuild.Verbosity)
property.SetValue(obj, mappedVerbosity);
options.Set(property.Name, mappedVerbosity);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Build/Execution/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static int Execute<T>(Expression<Func<T, Target>>[] defaultTargetExpressi
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
Console.CancelKeyPress += (_, _) => s_cancellationHandlers.ForEach(x => x());
ToolOptions.Created += (settings, _) => VerbosityMapping.Apply(settings);
ToolOptions.Created += (options, _) => VerbosityMapping.Apply((ToolOptions)options);

var build = new T();

Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Tooling/Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ private static IReadOnlyCollection<TResult> Invoke<TOptions, TResult>(
try
{
var result = executor(x.DisableProcessOutputLogging());
invocations.Add((x, x.ProcessLogger, result, default));
invocations.Add((x, x.GetLogger(), result, default));
}
catch (Exception exception)
{
invocations.Add((x, x.ProcessLogger, default, exception));
invocations.Add((x, x.GetLogger(), default, exception));
if (!completeOnFailure)
throw;
Expand Down
9 changes: 7 additions & 2 deletions source/Nuke.Tooling/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ private static string GetOptionName(LambdaExpression lambdaExpression)
}

internal Options Set<T>(Expression<Func<T>> propertyProvider, object value)
{
return Set(GetOptionName(propertyProvider), value);
}

internal Options Set(string propertyName, object value)
{
if (value != null)
{
var internalOption = JValue.FromObject(value, JsonSerializer);
InternalOptions[GetOptionName(propertyProvider)] = internalOption;
InternalOptions[propertyName] = internalOption;
}
else
{
Remove(propertyProvider);
InternalOptions.Property(propertyName)?.Remove();
}

return this;
Expand Down

0 comments on commit 04cd109

Please sign in to comment.