private static T GetGenerationOptionsFromAttribute <T>(ITypeSymbol source, params string[] attributeNames) where T : class { var attributes = source.GetAttributes().Where(attr => attributeNames.Any(name => attr.AttributeClass.Name.Equals(name))).ToImmutableArray(); if (attributes.Length > 1) { throw new CodeGeneratorException(source, $"The {source.TypeKind} '{source.Name}' is decorated with multiple attributes of type {StringUtils.Join(attributeNames, ", ", " or ")}. Only one such attribute is allowed."); } if (attributes.Length == 0) { return(null); } return(AttributeParser.CreateInstanceFromAttribute <T>(attributes[0])); }