protected void Mark <T>() where T : Attribute { if (_md.CustomAttributes.Any(ca => ca.AttributeType.IsTypeOf(typeof(T)))) { return; } var constructor = _typeSystem.CompilerGeneratedAttribute.Resolve() .Methods.First(m => m.IsConstructor && !m.IsStatic); _md.CustomAttributes.Add(new CustomAttribute(_typeSystem.Import(constructor))); }
public void Mark(TypeReference attribute) { if (_md.CustomAttributes.Any(ca => ca.AttributeType.FullName == attribute.FullName)) { return; } var constructor = _md.Module.ImportReference(attribute).Resolve() .Methods.First(m => m.IsConstructor && !m.IsStatic); _md.CustomAttributes.Add(new CustomAttribute(_typeSystem.Import(constructor))); }