/
Fabric2.cs
28 lines (25 loc) · 1.05 KB
/
Fabric2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
using Metalama.Documentation.QuickStart;
using Metalama.Framework.Code;
using Metalama.Framework.Fabrics;
namespace DebugDemo2
{
public class AddLogAspectInGivenNamespaceFabric : ProjectFabric
{
/// <summary>
/// Amends the project by adding Log aspect
/// to many eligible methods inside given namespace.
/// </summary>
public override void AmendProject( IProjectAmender amender )
{
//Adding Log attribute to all mehtods of all types
//that are available inside "Outer.Inner" namespace
amender.Outbound.SelectMany(
t => t.GlobalNamespace
.DescendantsAndSelf()
.Where( z => z.FullName.StartsWith( "Outer.Inner", StringComparison.Ordinal ) ) )
.SelectMany( ns => ns.Types.SelectMany( t => t.Methods ) )
.AddAspectIfEligible<LogAttribute>();
}
}
}