using Mono.Cecil; namespace CodeGenerator { public static class AttributeChecker { public static CustomAttribute? GetTargetttribute(this ICustomAttributeProvider definition) { var customAttributes = definition.CustomAttributes; return customAttributes.FirstOrDefault(_ => _.AttributeType.Name == nameof(JsonRPCAttribute)); } public static bool ContainsTargetAttribute(this ICustomAttributeProvider definition) => GetTargetttribute(definition) != null; public static bool IsCompilerGenerated(this ICustomAttributeProvider definition) { var customAttributes = definition.CustomAttributes; return customAttributes.Any(_ => _.AttributeType.Name == "CompilerGeneratedAttribute"); } public static void RemoveTargetAttribute(this ICustomAttributeProvider definition) { var customAttributes = definition.CustomAttributes; var targetAttribute = customAttributes.FirstOrDefault(_ => _.AttributeType.Name == nameof(JsonRPCAttribute)); if (targetAttribute != null) { customAttributes.Remove(targetAttribute); } } } }