private static bool?GetEmitDefaultValueFromAttributes(AttributedMembers attrMembers, Location?location, ImmutableArray <AttributeSyntax> attrs, ref ImmutableArray <Diagnostic> diags) { var(emitsByte, emitsBool) = Utils.GetConstantsWithName <byte, bool>(attrMembers, attrs, "EmitDefaultValue", ref diags); var total = emitsByte.Length + emitsBool.Length; if (total > 1) { var diag = Diagnostics.EmitDefaultValueSpecifiedMultipleTimes(location); diags = diags.Add(diag); return(null); } if (total == 0) { return(null); } if (emitsByte.Length == 1) { var byteVal = emitsByte.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 = emitsBool.Single(); return(boolVal); } }