private static void Analyze(SymbolAnalysisContext context, INamedTypeSymbol enumType) { IFieldSymbol[] fields = enumType.GetFields().ToArray(); switch (enumType.EnumUnderlyingType.SpecialType) { case SpecialType.System_SByte: { sbyte[] values = GetValues <sbyte>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (sbyte value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_Byte: { byte[] values = GetValues <byte>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (byte value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_Int16: { short[] values = GetValues <short>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (short value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_UInt16: { ushort[] values = GetValues <ushort>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (ushort value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_Int32: { int[] values = GetValues <int>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (int value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_UInt32: { uint[] values = GetValues <uint>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (uint value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_Int64: { long[] values = GetValues <long>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (long value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } case SpecialType.System_UInt64: { ulong[] values = GetValues <ulong>(fields); for (int i = 0; i < values.Length; i++) { if (values[i] != 0 && EnumHelper.IsComposite(values[i])) { foreach (ulong value in EnumHelper.Decompose(values[i])) { if (Array.IndexOf(values, value) == -1) { ReportDiagnostic(context, fields[i], value.ToString()); } } } } break; } default: { Debug.Assert(false, enumType.EnumUnderlyingType.SpecialType.ToString()); break; } } }