Rougamo.Fody
1.0.3
See the version list below for details.
dotnet add package Rougamo.Fody --version 1.0.3
NuGet\Install-Package Rougamo.Fody -Version 1.0.3
<PackageReference Include="Rougamo.Fody" Version="1.0.3" />
paket add Rougamo.Fody --version 1.0.3
#r "nuget: Rougamo.Fody, 1.0.3"
// Install Rougamo.Fody as a Cake Addin #addin nuget:?package=Rougamo.Fody&version=1.0.3 // Install Rougamo.Fody as a Cake Tool #tool nuget:?package=Rougamo.Fody&version=1.0.3
Rougamo - �����
rougamo��ʲô
��̬����֯��AOP��.NET��õ�AOPӦ����Castle DynamicProxy��rougamo�Ĺ����������ƣ�����ʵ��ȴ��Ȼ��ͬ�� DynamicProxy������ʱ����һ�������࣬ͨ��������д�ķ�ʽִ��֯����룬rougamo���Ǵ������ʱֱ����IL���룬 .NET��̬AOP������һ���ܺõ����PostSharp��rougamo��ע�뷽ʽҲ���������Ƶġ�
���ٿ�ʼ(MoAttribute)
// 1.NuGet����Rougamo.Fody
// 2.������̳�MoAttribute��ͬʱ������Ҫ֯��Ĵ���
public class LoggingAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
// ��context��������ȡ��������Ρ���ʵ����������������Ϣ
Log.Info("����ִ��ǰ");
}
public override void OnException(MethodContext context)
{
Log.Error("����ִ���쳣", context.Exception);
}
public override void OnExit(MethodContext context)
{
Log.Info("�����˳�ʱ�����۷���ִ�гɹ������쳣������ִ��");
}
public override void OnSuccess(MethodContext context)
{
Log.Info("����ִ�гɹ���");
}
}
// 3.Ӧ��Attribute
public class Service
{
[Logging]
public static int Sync(Model model)
{
// ...
}
[Logging]
public async Task<Data> Async(int id)
{
// ...
}
}
���ݷ����ɷ���������Ӧ��
�ڿ��ٿ�ʼ�н�������ν�����֯�뵽ָ�������ϣ���ʵ��ʹ��ʱ��һ���Ӵ����Ŀ���ÿ��������ܶ����ȥ�������Attribute
���ܻ�ܷ���������MoAttribute
���Ϊ����Ӧ���ڷ���(method)����(class)������(assembly)��ģ��(module)��ͬʱ������
�ɷ��������ԣ����������
// 1.�ڼ̳�MoAttribute��ͬʱ����дFlags���ԣ�δ��дʱĬ��InstancePublic(publicʵ������)
public class LoggingAttribute : MoAttribute
{
// ��Ϊ����public������Ч��������ʵ���������Ǿ�̬����
public override AccessFlags Flags => AccessFlags.Public;
// ������дʡ��
}
// 2.Ӧ��
// 2.1.Ӧ��������
[Logging]
public class Service
{
// ��̬֯�뽫��Ӧ��
public static void M1() { }
// ��̬֯�뽫��Ӧ��
public void M2() { }
// ����Ӧ�þ�̬֯��
protected void M3() { }
}
// 2.2.Ӧ���ڳ����ϣ��ó�������public��������Ӧ�þ�̬֯��
[assembly: Logging]
����֯��(IgnoreMoAttribute)
�ڿ��ٿ�ʼ�У����ǽ������������Ӧ�ã������������õĹ���ֻ���˷����ɷ����ԣ����Կ�����Щ���Ϲ���ķ���������Ӧ��֯�룬
��ʱ���ʹ��IgnoreMoAttribute
��ָ������/����б�ǣ���ô�÷���/��(�����з���)��������֯�롣�����IgnoreMoAttribute
Ӧ�õ�����(assembly)��ģ��(module)����ô�ó���(assembly)/ģ��(module)����������֯�롣���⣬��Ӧ��IgnoreMoAttribute
ʱ������ͨ��MoTypesָ�����Ե�֯�����͡�
// ��ǰ����������֯��
[assembly: IgnoreMo]
// ��ǰ������TheMoAttribute��֯��
[assembly: IgnoreMo(MoTypes = new[] { typeof(TheMoAttribute))]
// ��ǰ���������֯��
[IgnoreMo]
class Class1
{
// ...
}
// ��ǰ�����TheMoAttribute��֯��
[IgnoreMo(MoTypes = new[] { typeof(TheMoAttribute))]
class Class2
{
// ...
}
ͨ��ʵ�ֿսӿڵķ�ʽ����֯��(IRougamo<>)
���ÿ����������Attribute��Ǹо�̫����������ͨ�������ɷ����Խ�������֯���ֲ����Զ��壬��ô�÷�ʽ�����������������
// 1.������Ҫ֯��Ĵ��룬Ҳ����ֱ��ʹ�ÿ��ٿ�ʼ�ж����LoggingAttribute
public class LoggingMo : IMo
{
public override AccessFlags Flags => AccessFlags.All;
public override void OnEntry(MethodContext context)
{
// ��context��������ȡ��������Ρ���ʵ����������������Ϣ
Log.Info("����ִ��ǰ");
}
public override void OnException(MethodContext context)
{
Log.Error("����ִ���쳣", context.Exception);
}
public override void OnExit(MethodContext context)
{
Log.Info("�����˳�ʱ�����۷���ִ�гɹ������쳣������ִ��");
}
public override void OnSuccess(MethodContext context)
{
Log.Info("����ִ�гɹ���");
}
}
// 2.����սӿ�
public interface ILoggingRougamo : IRougamo<LoggingMo>
{
}
// 3.Ӧ�ÿսӿڣ��������ʱϰ�߽�ͬһ����/������ඨ��һ�����ӿ�/���࣬��ôֻ��Ҫ���ӿ�/����ʵ�ָýӿڼ���
public interface IRepository<TModel, TId> : ILoggingRougamo
{
// ...
}
֯�뻥��
�����ͻ���(IRougamo<,>)
����������Attribute��Ǻͽӿ�ʵ������֯�뷽ʽ����ô�Ϳ��ܳ���ͬʱӦ�õ���������������֯�����������ͬ�ģ��Ǿͻ���� �ظ�֯��������Ϊ�˾�����������������ڽӿڶ���ʱ�����Զ��廥�����ͣ�Ҳ����ͬʱֻ��һ������Ч�������ĸ���Ч������ ���ȼ�����
public class Mo1Attribute : MoAttribute
{
// ...
}
public class Mo2Attribute : MoAttribute
{
// ...
}
public class Mo3Attribute : MoAttribute
{
// ...
}
public class Test : IRougamo<Mo1Attribute, Mo2Attribute>
{
[Mo2]
public void M1()
{
// Mo2AttributeӦ���ڷ����ϣ����ȼ����ڽӿ�ʵ�ֵ�Mo1Attribute��Mo2Attribute����Ӧ��
}
[Mo3]
public void M2()
{
// Mo1Attribute��Mo3Attribute�����⣬����������Ӧ��
}
}
�����ͻ���(IRepulsionsRougamo<,>)
IRougamo<,>
ֻ����һ�����ͻ��⣬IRepulsionsRougamo<,>
������������ͻ���
public class Mo1Attribute : MoAttribute
{
}
public class Mo2Attribute : MoAttribute
{
}
public class Mo3Attribute : MoAttribute
{
}
public class Mo4Attribute : MoAttribute
{
}
public class Mo5Attribute : MoAttribute
{
}
public class TestRepulsion : MoRepulsion
{
public override Type[] Repulsions => new[] { typeof(Mo2Attribute), typeof(Mo3Attribute) };
}
[assembly: Mo2]
[assembly: Mo5]
public class Class2 : IRepulsionsRougamo<Mo1Attribute, TestRepulsion>
{
[Mo3]
public void M1()
{
// Mo1��Mo2��Mo3���⣬������Mo3���ȼ�����Mo1������Mo1����Чʱ�����л������Ͷ�����Ч
// ��������Mo2Attribute��Mo3Attribute��Mo5Attribute����Ӧ��
Console.WriteLine("m1");
}
[Mo4]
public void M2()
{
// Mo1��Mo2��Mo3���⣬������Mo1���ȼ�����Mo2������Mo2������Ч
// ����Mo1Attribute��Mo4Attribute��Mo5Attribute����Ӧ��
Console.WriteLine("m2");
}
}
<font color=red>ͨ����������ӣ������ע�����������ͻ��Ⲣ���Ƕ�����֮�以��⣬���ǵ�һ��������ڶ������Ͷ�������ͻ��⣬
�ڶ�������֮�䲢�����⣬Ҳ���������ʾ����������Mo1Attribute
����Чʱ�����������Mo2Attribute
��Mo3Attribute
��������
������Ҫ��⣬���廥���ԭ����Attribute�Ϳսӿ�ʵ�����ַ�ʽ���ܴ��ڵ��ظ�Ӧ�ã���������Ϊ���ų�����֯����ظ���ͬʱҲ���Ƽ�ʹ��
��ⶨ�壬�������׳��������ң�������Ӧ��֯��ǰ��ϸ˼��һ��ͳһ�Ĺ����������ⶨ�壬Ȼ����ͼʹ�ö�����������</font>
Attribute����֯��(MoProxyAttribute)
������Ѿ�ʹ��һЩ�����������һЩ����������Attribute��ǣ�������ϣ������Щ��ǹ��ķ�������aop���������ֲ���һ��һ���ֶ�����rougamo
��Attribute��ǣ���ʱ�����ͨ������ķ�ʽһ�����aop֯�롣�ٱ��������Ŀ�����кܶ�����ObsoleteAttribute
�Ĺ�ʱ��������ϣ��
�ڹ��ڷ����ڱ�����ʱ������ö�ջ��־�������Ų�������Щ�����ʹ����Щ���ڷ�����Ҳ����ͨ���÷�ʽ��ɡ�
public class ObsoleteProxyMoAttribute : MoAttribute
{
public override void OnEntry(MethodContext context)
{
Log.Warning("���ڷ����������ˣ�" + Environment.StackTrace);
}
}
[module: MoProxy(typeof(ObsoleteAttribute), typeof(ObsoleteProxyMoAttribute))]
public class Cls
{
[Obsolete]
private int GetId()
{
// �÷�����Ӧ��֯�����
return 123;
}
}
���ȼ�(Priority)
IgnoreMoAttribute
- Method
MoAttribute
- Method
MoProxyAttribute
- Type
MoAttribute
- Type
MoProxyAttribute
- Type
IRougamo<>
,IRougamo<,>
,IRepulsionsRougamo<,>
- Assembly & Module
MoAttribute
����(enable/disable)
Rougamo�ɸ��˿����������������ޣ���IL���о�Ҳ������ô����������������.NET�ķ�չҲ��ϵij���һЩ�µ����͡��µ����������µ�ILָ� Ҳ��˿��ܻ����һЩBUG������IL�����BUG���������ٶ�λ�����Ⲣ�������������ṩ��һ�����ؿ����ڲ�ȥ��Rougamo���õ�����²����д���֯�룬 Ҳ����Ƽ���λ��ʹ��Rougamo���д���֯��ʱ��֯��Ĵ����Dz�Ӱ��ҵ��ģ�������־��APM�����ϣ��ʹ���ȶ��������������ܹ����ٵõ�֧�ֵľ�̬֯�� ������Ƽ�ʹ��PostSharp
Rougamo����fody�Ļ������з��ģ�����Rougamo���״α��������һ��FodyWeavers.xml
�ļ���Ĭ����������
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Rougamo />
</Weavers>
��ϣ������Rougamoʱ����Ҫ�������ļ���Rougamo
�ڵ���������enabled
������ֵΪfalse
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Rougamo enabled="false" />
</Weavers>
��¼yield return IEnumerable/IAsyncEnumerable����ֵ
����֪����ʹ��yield return
���+IEnumerable
����ֵ�ķ������ڵ��÷��������÷����Ĵ���ʵ�ʲ�û��ִ�У������ʵ��ִ�����������
���IEnumerable
�������Ԫ��ʱ������ȥforeach���������ߵ���ToList/ToArray
��ʱ���ҷ��ص���ЩԪ�ز�û��һ������/�������
ͳһ�ı��棨����ԭ�������ﲻչ��˵���ˣ�������Ĭ���������û�а취ֱ�ӻ�ȡ��yield return IEnumerable
���ص�����Ԫ�ؼ��ϵġ�
��������Щ�Դ����رȽ��ϸ�ij�����Ҫ��¼���з���ֵ��������ʵ�����Ҵ�����һ�����鱣�������еķ���Ԫ�أ�����������������Ƕ��ⴴ���ģ���ռ
�ö�����ڴ�ռ䣬ͬʱ�ֲ�������IEnumerable
���ص�Ԫ�ؼ����ж������Ϊ�˱�����ܶ������������ڴ����ģ�Ĭ��������Dz����¼
yield return IEnumerable
����ֵ�ģ������Ҫ��¼����ֵ����Ҫ��FodyWeavers.xml
��Rougamo
�ڵ�������������enumerable-returns="true"
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Rougamo enumerable-returns="true" />
</Weavers>
todo
- ���Դ���
- Ӣ���ĵ�
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Fody (>= 6.2.5)
NuGet packages (43)
Showing the top 5 NuGet packages that depend on Rougamo.Fody:
Package | Downloads |
---|---|
HandeSoft.Core
Package Description |
|
HandeSoft.Web.Core
Package Description |
|
BotSharp.Abstraction
Package Description |
|
Ray.Infrastructure
This client library is a infrastructure that including extensions and helpers etc. |
|
HZY.Framework.Core
HZY Framework 核心 1、ScheduledAttribute 定时任务特性标记 2、IServerMetricMonitoringService 服务器指标监控 CPU、内存、硬盘、运行时长 3、HZY.Framework.DynamicApiController 动态Api控制器 4、HZY.Framework.DependencyInjection 依赖注入 |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on Rougamo.Fody:
Repository | Stars |
---|---|
RayWangQvQ/BiliBiliToolPro
B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。敏感肌也能用。
|
|
dotnetcore/FreeSql
🦄 .NET aot orm, C# orm, VB.NET orm, Mysql orm, Postgresql orm, SqlServer orm, Oracle orm, Sqlite orm, Firebird orm, 达梦 orm, 人大金仓 orm, 神通 orm, 翰高 orm, 南大通用 orm, 虚谷 orm, 国产 orm, Clickhouse orm, DuckDB orm, TDengine orm, QuestDB orm, MsAccess orm.
|
|
SciSharp/BotSharp
AI Multi-Agent Framework in .NET
|
|
2881099/FreeSql.AdminLTE
这是一个 .NETCore MVC 中间件,基于 AdminLTE 前端框架动态产生 FreeSql 实体的增删查改界面。
|
|
ThingsGateway/ThingsGateway
ThingsGateway is a cross platform high-performance edge acquisition gateway based on Net8, providing underlying PLC communication libraries, communication debugging software, and more.
|
Version | Downloads | Last updated | |
---|---|---|---|
4.0.4 | 2,486 | 9/29/2024 | |
4.0.4-preview-1727349912 | 92 | 9/26/2024 | |
4.0.3 | 1,225 | 9/16/2024 | |
4.0.3-preview-1726120802 | 96 | 9/12/2024 | |
4.0.3-preview-1725957423 | 104 | 9/10/2024 | |
4.0.2 | 504 | 9/9/2024 | |
4.0.2-preview-1725956948 | 95 | 9/10/2024 | |
4.0.2-preview-1725875652 | 94 | 9/9/2024 | |
4.0.2-preview-1725466232 | 96 | 9/4/2024 | |
4.0.1 | 2,622 | 9/2/2024 | |
4.0.1-preview-1725141430 | 88 | 8/31/2024 | |
4.0.0 | 6,044 | 8/10/2024 | |
4.0.0-priview-1723306347 | 109 | 8/10/2024 | |
4.0.0-priview-1722831925 | 86 | 8/5/2024 | |
3.1.0 | 1,501 | 7/16/2024 | |
3.0.2 | 437 | 7/8/2024 | |
3.0.2-priview-1720363148 | 103 | 7/7/2024 | |
3.0.2-priview-1720251661 | 101 | 7/6/2024 | |
3.0.1 | 185 | 7/4/2024 | |
3.0.1-priview-1720089186 | 106 | 7/4/2024 | |
3.0.1-priview-1720085112 | 89 | 7/4/2024 | |
3.0.0 | 3,394 | 5/4/2024 | |
3.0.0-priview-1714754497 | 78 | 5/3/2024 | |
3.0.0-priview-1714407561 | 131 | 4/29/2024 | |
2.3.1 | 7,373 | 4/23/2024 | |
2.3.1-priview-1713854631 | 114 | 4/23/2024 | |
2.3.1-priview-1713791514 | 102 | 4/22/2024 | |
2.3.0 | 3,776 | 3/10/2024 | |
2.3.0-priview-1709894403 | 113 | 3/8/2024 | |
2.2.0 | 2,950 | 1/20/2024 | |
2.2.0-priview-1705656978 | 109 | 1/19/2024 | |
2.2.0-priview-1705571301 | 103 | 1/18/2024 | |
2.2.0-priview-1705566213 | 109 | 1/18/2024 | |
2.2.0-priview-1702899195 | 184 | 12/18/2023 | |
2.1.1 | 4,611 | 12/14/2023 | |
2.1.1-priview-1702545048 | 142 | 12/14/2023 | |
2.1.1-priview-1702542781 | 140 | 12/14/2023 | |
2.0.1 | 1,246 | 11/16/2023 | |
2.0.0 | 2,986 | 10/8/2023 | |
2.0.0-priview-1696783135 | 135 | 10/8/2023 | |
2.0.0-priview-1696592398 | 130 | 10/6/2023 | |
2.0.0-priview-1695658688 | 156 | 9/25/2023 | |
2.0.0-priview-1695465141 | 149 | 9/23/2023 | |
2.0.0-priview-1680984436 | 221 | 4/8/2023 | |
2.0.0-priview-1680981587 | 181 | 4/8/2023 | |
1.4.1 | 11,398 | 3/12/2023 | |
1.4.1-priview-1678603084 | 188 | 3/12/2023 | |
1.4.1-priview-1678557697 | 189 | 3/11/2023 | |
1.4.1-priview-1678557463 | 187 | 3/11/2023 | |
1.4.0 | 2,648 | 3/1/2023 | |
1.4.0-beta | 362 | 2/27/2023 | |
1.4.0-alpha | 234 | 2/25/2023 | |
1.3.4 | 56,829 | 2/17/2023 | |
1.3.3 | 978 | 1/17/2023 | |
1.3.2 | 18,298 | 12/20/2022 | |
1.3.1 | 341 | 12/20/2022 | |
1.3.1-beta | 178 | 12/14/2022 | |
1.3.0 | 1,281 | 12/8/2022 | |
1.2.3 | 347 | 1/17/2023 | |
1.2.2 | 320 | 12/20/2022 | |
1.2.2-beta | 168 | 12/14/2022 | |
1.2.1 | 695 | 11/29/2022 | |
1.2.1-beta | 163 | 11/29/2022 | |
1.2.0 | 2,061 | 9/14/2022 | |
1.2.0-beta | 183 | 9/12/2022 | |
1.2.0-alpha2 | 173 | 9/12/2022 | |
1.2.0-alpha1 | 180 | 8/31/2022 | |
1.2.0-alpha | 173 | 8/30/2022 | |
1.1.4 | 373 | 11/29/2022 | |
1.1.4-alpha | 189 | 12/25/2022 | |
1.1.3 | 532 | 9/11/2022 | |
1.1.2 | 1,647 | 8/22/2022 | |
1.1.2-beta | 180 | 8/22/2022 | |
1.1.1 | 2,809 | 8/8/2022 | |
1.1.1-beta | 190 | 8/1/2022 | |
1.1.0 | 630 | 7/28/2022 | |
1.1.0-beta | 205 | 7/15/2022 | |
1.1.0-alpha4 | 188 | 6/24/2022 | |
1.1.0-alpha3 | 175 | 6/24/2022 | |
1.1.0-alpha2 | 174 | 6/23/2022 | |
1.1.0-alpha1 | 176 | 6/22/2022 | |
1.1.0-alpha | 190 | 5/22/2022 | |
1.0.3 | 712 | 5/6/2022 | |
1.0.3-beta | 195 | 4/26/2022 | |
1.0.2 | 696 | 12/23/2021 | |
1.0.1 | 7,736 | 11/23/2021 | |
1.0.1-beta | 4,919 | 11/23/2021 |
fix #2, Execute OnException, OnSuccess, OnExit in reverse order, add configuration 'reverse-call-ending' that can be adjusted for executeion order.