weixin_39614146
weixin_39614146
2021-01-09 01:38

use of System.Diagnostics.ConditionalAttribute

I see there are many MvxBindingTrace.Trace or MvxTrace.Trace, is it possible to have [Conditional(DEBUG)] to eliminate the function call in release built ?

该提问来源于开源项目:MvvmCross/MvvmCross

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39537397 weixin_39537397 3月前

    Just provide your own Trace override which does that?

    Look at https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/master/N-42-Lifecycles/Lifecycle.Droid/DebugTrace.cs and see how it is hooked up in the Setup.cs file in the same project.

    点赞 评论 复制链接分享
  • weixin_39614146 weixin_39614146 3月前

    Trace override still have small overhead, ConditionalAttribute can even remove it. As I am target on very old end device with many UI binding.

    点赞 评论 复制链接分享
  • weixin_39614146 weixin_39614146 3月前

    btw, In Cirrious/Cirrious.MvvmCross.Binding/Bindings/Target/MvxConvertingTargetBinding.cs

    MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Firing changed to " + (newValue ?? "")); MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Receiving setValue to " + (value ?? ""));

    ->

    MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Firing changed to {0} ", newValue ?? "" ); MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Receiving setValue to {0} " + value ?? "");

    点赞 评论 复制链接分享
  • weixin_39537397 weixin_39537397 3月前

    I suggest you make a pull request and it will be reviewed.

    点赞 评论 复制链接分享

为你推荐