.NET中的Attribute.IsDefined等效?

时间:2016-08-28 19:11:55

标签: c# custom-attributes .net-core

我有一段代码,我尝试转换为.NET Core

    public static bool IsAnonymousType(Type t)
    {
        return Attribute.IsDefined(t, typeof(CompilerGeneratedAttribute), false)
            && t.GetTypeInfo().IsGenericType
                && (t.Name.Contains("AnonymousType") || t.Name.Contains("AnonType"))
                    && (t.Name.StartsWith("<>", StringComparison.Ordinal) || t.Name.StartsWith("VB$", StringComparison.Ordinal))
                        && (t.GetTypeInfo().Attributes & AnonymousTypeAttributes) == AnonymousTypeAttributes;
    }

但我有

的问题
  Attribute.IsDefined(t, typeof(CompilerGeneratedAttribute), false)

任何人都可以指导我关于.NET Core的等价物吗?

0 个答案:

没有答案