디버그 실행시 원하는 표현 형식으로 볼 수 있게 해주는 attribute 이다.

 

 

 

 

 

 

 

 

using System.Collections.Generic;
using System.Diagnostics;

namespace test_attribute
{
    [DebuggerDisplay("Count = {Count}")] // 디버그시 클래스 값에 표현될 형식
    [DebuggerTypeProxy(typeof(TestSystemAttributeDebuggingView))]
    public class TestSystemAttribute
    {
        public int Count { get; set; }
        public List<string> List;

        public TestSystemAttribute()
        {
            Count = 0;
            Count = 1;
            Count = 2;

            List = new List<string>();
            List.Add("a");
            List.Add("b");
            List.Add("c");
            List.Add("d");
        }
    }

    public class TestSystemAttributeDebuggingView
    {
        private TestSystemAttribute _obj;

        public TestSystemAttributeDebuggingView(TestSystemAttribute obj)
        {
            _obj = obj;
        }

        public int ObjCount { get => _obj.Count; }

        public string ListString
        {
            get
            {
                return string.Join(", ", _obj.List);
            }
        }

        // RootHidden: 변수 아래 내용이 바로 표현됨
        [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
        public List<string> ListOrigin { get => _obj.List; }
    }

}

 

 

'C#' 카테고리의 다른 글

c# method attribute 의 값을 해당 메소드에서 가져오기  (0) 2022.03.15
c# HttpClient  (0) 2022.03.15
c# channel  (0) 2022.03.15
object pool, object type pool  (0) 2022.03.11
GC TEST  (0) 2022.03.08
GC EventPipe 모니터링  (0) 2022.03.08
C# .net core 빌드 및 powershell 전송  (0) 2022.03.01
c# stack size 확인  (0) 2022.02.24