小编Nei*_*der的帖子

创建可识别程序集中类的构造函数参数类型的Roslyn C#分析器

背景:

我有一个属性,指示对象中字段的属性IsMagic。我还有一个Magician类可以运行在任何对象上,并MakesMagic提取每个字段和属性IsMagic并将其包装在Magic包装器中。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace MagicTest
{

    /// <summary>
    /// An attribute that allows us to decorate a class with information that identifies which member is magic.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
    class IsMagic : Attribute { }

    public class Magic
    {
        // Internal data storage
        readonly public dynamic value;

        #region My ever-growing list of constructors
        public Magic(int input) { value = input; …
Run Code Online (Sandbox Code Playgroud)

c# analyzer roslyn

5
推荐指数
1
解决办法
591
查看次数

标签 统计

analyzer ×1

c# ×1

roslyn ×1