private static bool?GetMemberRequiredFromAttributes( AttributedMembers attrMembers, Location?location, ImmutableArray <AttributeSyntax> attrs, ref ImmutableArray <Diagnostic> diags ) { var requiredByte = Utils.GetConstantsWithName <byte>(attrMembers, attrs, "MemberRequired", ref diags); var requiredBool = Utils.GetConstantsWithName <bool>(attrMembers, attrs, "IsRequired", ref diags); var total = requiredByte.Length + requiredBool.Length; if (total > 1) { var diag = Diagnostics.IsRequiredSpecifiedMultipleTimes(location); diags = diags.Add(diag); return(null); } if (total == 0) { return(null); } if (requiredByte.Length == 1) { var byteVal = requiredByte.Single(); var logicalVal = byteVal switch { 1 => true, 2 => false, _ => default(bool?) }; if (logicalVal == null) { var diag = Diagnostics.UnexpectedConstantValue(location, byteVal.ToString(), new[] { "Yes", "No" }); diags = diags.Add(diag); return(null); } return(logicalVal); } var boolVal = requiredBool.Single(); return(boolVal); }