I managed to get there myself; though kind of in a dirty way, but it does the job. If anyone does know how to actually target the attribute please do tell!
What it did is I used a bool that sets to true if the struct-attributes contain the text "StructLayout".
Then below I check if the attribute is false, and if it is I add violations if the field is not readonly.
public void IsStructNameCorrect(Struct structItem)
{
string attribText = "";
bool hasStructLayout = false;
foreach (Attribute attrib in structItem.Attributes)
attribText = attribText + attrib.Text;
if (attribText.Contains("StructLayout"))
hasStructLayout = true;
if (!hasStructLayout)
{
foreach (CsElement csElement in structItem.ChildElements)
{
if (csElement.ElementType == ElementType.Field)
{
Field field = (Field)csElement;
if (!field.Readonly)
{
AddViolation(field, field.LineNumber, "FieldNotReadOnly", field.Name);
}
}
}
}
}