postsharp

PostSharp - excluding a method using AttributeExclude doesn't work

我只是一个虾纸丫 提交于 2021-01-29 01:50:23
问题 We have a project where we're using PostSharp to enable logging. Works great. However, there are a couple of methods that are run in very tight loops, where the overhead of logging really adds up to a considerable amount. I'm trying to figure out the best way to exclude them from the logging code. From what I've read, this approach should work AssemblyInfo.cs // turn on logging for all methods in all classes [assembly: Log(LogType.Debug)] Code.cs // exclude this specific method [Log

PostSharp - excluding a method using AttributeExclude doesn't work

倖福魔咒の 提交于 2021-01-29 01:43:28
问题 We have a project where we're using PostSharp to enable logging. Works great. However, there are a couple of methods that are run in very tight loops, where the overhead of logging really adds up to a considerable amount. I'm trying to figure out the best way to exclude them from the logging code. From what I've read, this approach should work AssemblyInfo.cs // turn on logging for all methods in all classes [assembly: Log(LogType.Debug)] Code.cs // exclude this specific method [Log

PostSharp - excluding a method using AttributeExclude doesn't work

こ雲淡風輕ζ 提交于 2021-01-29 01:42:29
问题 We have a project where we're using PostSharp to enable logging. Works great. However, there are a couple of methods that are run in very tight loops, where the overhead of logging really adds up to a considerable amount. I'm trying to figure out the best way to exclude them from the logging code. From what I've read, this approach should work AssemblyInfo.cs // turn on logging for all methods in all classes [assembly: Log(LogType.Debug)] Code.cs // exclude this specific method [Log

Postsharp Build Errors after Update to Visual Studio Version 16.8.2

白昼怎懂夜的黑 提交于 2021-01-05 07:19:05
问题 After updating visual studio to version 16.8.2, my solution which uses Post Sharp no longer builds. I didn't upgrade any projects to use .Net 5. Here are the errors I'm seeing: Severity Code Description Project File Line Suppression State Error CS0006 Metadata file 'C:\Dev\repos\hinge\HingeSolution\HingeApi\bin\Debug\netcoreapp3.1\HingeApi.dll' could not be found HingeApi-tests C:\Dev\repos\hinge\HingeSolution\HingeApi-tests\CSC 1 N/A Error MSB4064 The "RuntimeGraphPath" parameter is not

Can postsharp aspects be used on website projects?

泄露秘密 提交于 2020-12-12 11:39:07
问题 I'm trying to use a PostSharp aspect in a website project in VS2012. It seems to work fine when I set up a web application project, but when I apply the aspect attribute to a method on a page in the website project it compiles and runs fine, but my OnMethodBoundaryAspect never gets hit. I tried setting breakpoints and logging from the aspect methods. Does PostSharp support website projects? if so, what am I missing? Please no comments about why I want to use a website instead of a web app.

10.AOP

一曲冷凌霜 提交于 2020-08-12 20:16:03
1.AOP:允许开发者动态修改静态的OO模型 2.AOP是一种编程思想,是OOP的补充 3.正是因为能够动态的扩展功能,所以在程序设计时就有以下好处: (1)聚焦核心业务逻辑,权限/异常/日志/缓存/事务 等通用功能通过AOP方式添加,程序设计简单 (2)动态扩展,集中管理,代码复用,规范化 4.实现AOP的方式 (1)静态实现:装饰器/代理模式 (2)动态实现:Remoting/Castle(Emit) (3)静态织入:PostSharp (4)依赖注入容器的AOP扩展 Unity容器: ①顺序问题:配置文件的注册顺序是调用顺序,然后才是业务方法,但扩展逻辑可以在业务方法后 ②接口方法不需要某个AOP扩展--》a.判断方法 b.使用特性 5.MVC的Filter:特性标记,然后该方法执行前/后就多了逻辑 invoke调用中心--负责反射调用方法--检查特性--有则执行额外逻辑 来源: oschina 链接: https://my.oschina.net/u/4399905/blog/4439742

代理模式是什么?如何在 C# 中实现代理模式

你离开我真会死。 提交于 2020-04-23 22:30:46
代理模式 并不是日常开发工作中常常用到的一种设计模式,也是一种不易被理解的一种设计模式。但是它会广泛的应用在系统框架、业务框架中。 定义 它的 定义 就如其它同大部分 设计模式 的定义类似,即不通俗也不易懂,而且随便百度一下就能找到 : 为其他对象提供一种代理,以控制对这个对象的访问。代理对象在客户端和目标对象之间起到中介的作用。 每个字都认识,连在一起就看不懂了 by. 某个攻城狮 我们一个词一个词看就明白了。 其他对象 所谓的 其它 ,其实就是你系统中 任意 一个类型,可以是 UserService 、 OrderRepository 、 DataDeletedEventListener 、等等。 控制对这个对象的访问 访问 其实就是调用这个对象上的方法、访问它的属性、设置它的属性等等,比如 User user = UserService.GetUserById(1); // 访问了 GetUserById 方法 int id = user.Id; // 访问了 Id 属性 Order order = OrderRepository.SelectByUserId(id); // 访问了 SelectByUserId 方法 控制访问 , 控制 的本质是包装,外部不再直接使用 其他对象 ,而是使用 代理 ,再由代理来访问 其它对象 。我们可以使用一个已有的 List<T> 实现一个

记录最佳实践[关闭]

风流意气都作罢 提交于 2020-03-13 18:41:46
我想了解人们如何处理跟踪和登录实际应用程序的故事。 以下是一些可能有助于解释您的答案的问题。 构架 你使用什么框架? log4net的 System.Diagnostics.Trace System.Diagnostics.TraceSource 记录应用程序块 其他? 如果使用跟踪,是否使用Trace.Correlation.StartLogicalOperation? 您是手动编写此代码,还是使用某种形式的面向方面编程来执行此操作? 小心共享代码片段? 您是否在跟踪源上提供任何形式的粒度? 例如,WPF TraceSources允许您在不同级别配置它们: System.Windows - 所有WPF的设置 System.Windows.Animation - 专门为动画覆盖。 听众 你使用什么日志输出? 文本文件 XML文件 事件簿 其他? 如果使用文件,您使用滚动日志还是仅使用单个文件? 如何使日志可供人们使用? 查看 您可以使用哪些工具查看日志? 记事本 尾巴 事件查看器 Systems Center Operations Manager / Microsoft Operations Manger WCF服务跟踪查看器 其他? 如果要构建ASP.NET解决方案,是否还使用ASP.NET运行状况监视? 您是否在运行状况监视器事件中包含跟踪输出? 那么Trace.axd呢?

Issue Using PostSharp 3.x with NuGet Auto Restore

徘徊边缘 提交于 2020-01-25 03:04:06
问题 I have a solution with many projects, some of which use PostSharp. I've recently switched from using NuGet MSBuild integrated restore to NuGet Auto Restore. This causes all necessary packages to be restored for all packages before a build starts. This works great, except for now I come across an issue frequently where PostSharp will fail the build with the error: The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http:/

AttributeTargetElements = MulticastTargets.Method isn't respected?

雨燕双飞 提交于 2020-01-16 01:19:29
问题 I applied this aspect: [Serializable] [MulticastAttributeUsage(MulticastTargets.Method)] // regular methods, excluding ctors! public class WmiClassMethodAspect : OnMethodBoundaryAspect { public WmiClassMethodAspect() { ApplyToStateMachine = false; } // PostSharp Express edition... public override void OnEntry(MethodExecutionArgs args) { //base.OnEntry(args); } public override void OnExit(MethodExecutionArgs args) { //base.OnExit(args); } } over certain namespace 's class: [assembly: