public static ICollection <ISymbol> GetMissingEnumMembers(ISwitchExpressionOperation operation) { var switchExpression = operation.Value; var switchExpressionType = switchExpression?.Type; var enumMembers = new Dictionary <long, ISymbol>(); // Check if the type of the expression is a nullable INamedTypeSymbol // if the type is both nullable and an INamedTypeSymbol extract the type argument from the nullable // and check if it is of enum type if (switchExpressionType != null) { switchExpressionType = switchExpressionType.IsNullable(out var underlyingType) ? underlyingType : switchExpressionType; } if (switchExpressionType?.TypeKind == TypeKind.Enum) { if (!PopulateSwitchStatementHelpers.TryGetAllEnumMembers(switchExpressionType, enumMembers) || !TryRemoveExistingEnumMembers(operation, enumMembers)) { return(SpecializedCollections.EmptyCollection <ISymbol>()); } } return(enumMembers.Values); }
public static ICollection <ISymbol> GetMissingEnumMembers(ISwitchExpressionOperation operation) { var switchExpression = operation.Value; var switchExpressionType = switchExpression?.Type; var enumMembers = new Dictionary <long, ISymbol>(); if (switchExpressionType?.TypeKind == TypeKind.Enum) { if (!PopulateSwitchStatementHelpers.TryGetAllEnumMembers(switchExpressionType, enumMembers) || !TryRemoveExistingEnumMembers(operation, enumMembers)) { return(SpecializedCollections.EmptyCollection <ISymbol>()); } } return(enumMembers.Values); }