Skip to content

Commit c15c210

Browse files
committed
Introduces the way to configure defaults using Tuners and syntax sugar.
1 parent 48b4a99 commit c15c210

21 files changed

Lines changed: 398 additions & 1985 deletions

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Packages/
55
private
66

77
# Compiling result files
8-
Bin/
9-
Obj/
8+
.out/
9+
[Bb]in/
10+
[Oo]bj/
1011

1112
# Visual Studion and ReSharper files
1213
_ReSharper.Caches/

.out/BeatyBit.Armature.Core.xml

Lines changed: 0 additions & 690 deletions
This file was deleted.

.out/BeatyBit.Armature.Interface.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.out/BeatyBit.Armature.xml

Lines changed: 0 additions & 1222 deletions
This file was deleted.

Armature.sln

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{4F748C60
3030
EndProject
3131
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Performance", "test\Test.Performance\Test.Performance.csproj", "{47000C08-6B61-4ADB-8BBF-D8EED737D2D1}"
3232
EndProject
33-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wiki", "wiki", "{FA14B96D-6F61-4888-92D8-A0B34DFD20AB}"
34-
ProjectSection(SolutionItems) = preProject
35-
wiki\_Sidebar.md = wiki\_Sidebar.md
36-
wiki\Armature-the-DSL-over-Armature.Core.md = wiki\Armature-the-DSL-over-Armature.Core.md
37-
wiki\Core-Concepts-of-Armature.Core.md = wiki\Core-Concepts-of-Armature.Core.md
38-
wiki\Default-Rules-For-Resolving-Unit-and-Its-Dependencies.md = wiki\Default-Rules-For-Resolving-Unit-and-Its-Dependencies.md
39-
wiki\Home.md = wiki\Home.md
40-
wiki\InjectAttribute.-Marking-Injection-Points-and-Customizing-Injection-Rules.md = wiki\InjectAttribute.-Marking-Injection-Points-and-Customizing-Injection-Rules.md
41-
wiki\Logging.md = wiki\Logging.md
42-
wiki\One-Process-to-Rule-Them-All.-Armature's-Universal-Dependency-Resolution.md = wiki\One-Process-to-Rule-Them-All.-Armature's-Universal-Dependency-Resolution.md
43-
wiki\Out-of-the-Box.md = wiki\Out-of-the-Box.md
44-
wiki\Propagation-of-Maybe.-Subscribing-Events.-And-Many-Many-More.md = wiki\Propagation-of-Maybe.-Subscribing-Events.-And-Many-Many-More.md
45-
wiki\Side-Tuners-Fine-Grained-Control-Over-Dependency-Injection.md = wiki\Side-Tuners-Fine-Grained-Control-Over-Dependency-Injection.md
46-
wiki\Weighted-Build-Actions-and-Patterns.-Prioritizing-Resolution-Paths.md = wiki\Weighted-Build-Actions-and-Patterns.-Prioritizing-Resolution-Paths.md
47-
EndProjectSection
48-
EndProject
4933
Global
5034
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5135
Debug|Any CPU = Debug|Any CPU

src/Armature.Core/src/BuildStackPatterns/BuildStackPatternBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class BuildStackPatternBase : IBuildStackPattern, IEnumerable, I
3434
/// <summary>
3535
/// Adds a <paramref name="node" /> as a child node if the node is not already added. Returns the new node, or the existing node if the node already added.
3636
/// </summary>
37-
/// <remarks>Call it first and then fill returned <see cref="IBuildStackPattern" /> with build actions or perform other needed actions due to
37+
/// <remarks>Call it first and then fill returned <see cref="IBuildStackPattern" /> with build actions or perform other necessary actions due to
3838
/// it can return another instance of <see cref="IBuildStackPattern"/> then passed <paramref name="node"/>.</remarks>
3939
public virtual T GetOrAddNode<T>(T node) where T : IBuildStackPattern
4040
{
@@ -84,13 +84,14 @@ protected bool GetOwnBuildActions(long inputWeight, out WeightedBuildActionBag?
8484

8585
foreach(var pair in RawBuildActions)
8686
{
87+
var buildStage = pair.Key;
8788
var actions = pair.Value;
8889
var weightedActions = new LeanList<Weighted<IBuildAction>>(actions.Count);
8990

9091
foreach(var buildAction in actions)
9192
weightedActions.Add(buildAction.WithWeight(matchingWeight));
9293

93-
actionBag.Add(pair.Key, weightedActions);
94+
actionBag.Add(buildStage, weightedActions);
9495
}
9596

9697
return true;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using BeatyBit.Armature.Core.Sdk;
4+
5+
namespace BeatyBit.Armature.Core;
6+
7+
/// <summary>
8+
/// It's a very special build stack pattern that matches with any 'unit'. See usages for details.
9+
/// </summary>
10+
public class IfAnyUnit : BuildStackPatternBase, IBuildStackPattern
11+
{
12+
public static readonly IfAnyUnit Instance = new();
13+
14+
private static readonly UnitId FakeUnitId = new(typeof(IfAnyUnit), null);
15+
16+
private IfAnyUnit() : base(0) { }
17+
18+
public override bool IsStatic(out UnitId unitId)
19+
{
20+
unitId = FakeUnitId;
21+
return true;
22+
}
23+
24+
public override bool GatherBuildActions(BuildSession.Stack stack, out WeightedBuildActionBag? actionBag, long inputWeight)
25+
=> GetOwnBuildActions(inputWeight, out actionBag);
26+
27+
public override bool Equals(IBuildStackPattern? other) => other is IfAnyUnit;
28+
29+
public override T GetOrAddNode<T>(T node) => throw new NotSupportedException();
30+
public override T AddNode<T>(T node) => throw new NotSupportedException();
31+
32+
long IInternal<long>. Member1 => 0;
33+
HashSet<IBuildStackPattern>? IInternal<long, HashSet<IBuildStackPattern>?>. Member2 => null;
34+
BuildActionBag IInternal<long, HashSet<IBuildStackPattern>?, BuildActionBag?>.Member3 => BuildActions;
35+
}

src/Armature.Core/src/Logging/LogExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public static string ToHoconString(this object? value)
5656
{
5757
null => "null",
5858
string str => str.QuoteIfNeeded(),
59-
BuildSession.Stack stack => stack.ToHoconString(),
59+
BuildSession.Stack stack => stack.ToHoconString(),
6060
ILogString logable => logable.ToHoconString(),
61-
IBuildAction buildAction => buildAction.GetType().GetShortName().QuoteIfNeeded(),
61+
// IBuildAction buildAction => buildAction.GetType().GetShortName().QuoteIfNeeded(),
6262
MethodBase methodInfo => methodInfo.ToString().QuoteIfNeeded(),
6363
Type type => $"typeof({(Log.LogFullTypeName ? type.GetFullName() : type.GetShortName())})".QuoteIfNeeded(),
6464
IEnumerable items => $"[{string.Join(", ", items.Cast<object>().Select(_ => _.ToHoconString()))}]",

src/Armature/src/BuildActions/BuildListArgumentBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ private static bool IsCollection(
103103

104104
[DebuggerStepThrough]
105105
public string ToHoconString() => $"{{ {GetType().GetShortName().QuoteIfNeeded()} {{ Tag: {_tag.ToHoconString()} }} }}";
106+
106107
[DebuggerStepThrough]
107108
public sealed override string ToString() => ToHoconString();
108109
}

src/Armature/src/BuildActions/Constructor/GetConstructorWithMaxParametersCount.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ private static ConstructorInfo GetConstructor(IReadOnlyList<ConstructorInfo> con
7373

7474
[DebuggerStepThrough]
7575
public override string ToString() => nameof(GetConstructorWithMaxParametersCount);
76+
public string ToHoconString() => $"{nameof(GetConstructorWithMaxParametersCount)} ";
7677
}

0 commit comments

Comments
 (0)